1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3""" 4Copyright (c) 2024 Huawei Device Co., Ltd. 5Licensed under the Apache License, Version 2.0 (the "License"); 6you may not use this file except in compliance with the License. 7You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11Unless required by applicable law or agreed to in writing, software 12distributed under the License is distributed on an "AS IS" BASIS, 13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14See the License for the specific language governing permissions and 15limitations under the License. 16 17Description: Scenario test case. 18""" 19 20import logging 21import os 22import time 23 24import pytest 25 26from aw import Application 27from aw import Utils 28from aw import debugger 29from aw.api import debugger_api, runtime_api 30 31 32@pytest.mark.debug 33@pytest.mark.timeout(80) 34class TestWorkerDropFrame02: 35 """ 36 测试用例:多线程 debug 调试之 drop frame 37 测试步骤: 38 1. 连接 connect server 和主线程 debugger server 39 2. 主线程使能 Runtime 和 Debugger 40 3. 主线程 resume(Debugger.resume) 41 4. 触发点击事件,创建子线程,连接子线程 debugger server 42 5. 子线程使能 Runtime 和 Debugger 43 6. 创建 taskpool 线程,连接 debugger server,使能 Runtime 和 Debugger 44 7. 子线程 Worker.ets 文件设置断点(Debugger.getPossibleAndSetBreakpointByUrl) 45 8. 子线程 resume,停在断点处(Debugger.resume) 46 9. 子线程 evaluateOnCallFrame,观察指定变量的值(Debugger.evaluateOnCallFrame) 47 10. 子线程时光调试,回到方法调用前(Debugger.dropFrame) 48 11. 子线程 evaluateOnCallFrame,观察指定变量的值是否变化(Debugger.evaluateOnCallFrame) 49 12. 子线程重复步骤 6-10,测试 dropFrame 在不同方法内的执行情况 50 13. 执行到 taskpool 任务时切换到 taskpool 线程进行 dropFrame 操作(Debugger.dropFrame) 51 14. 所有线程去使能 debugger(Debugger.disable) 52 15. 关闭所有线程 debugger server 和 connect server 连接 53 """ 54 55 def setup_method(self): 56 logging.info('Start running TestWorkerDropFrame02: setup') 57 58 self.log_path = rf'{os.path.dirname(__file__)}\..\log' 59 self.hilog_file_name = 'test_worker_drop_frame_02.hilog.txt' 60 self.id_generator = Utils.message_id_generator() 61 62 # receive the hilog before the test start 63 Utils.clear_fault_log() 64 self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path, 65 file_name=self.hilog_file_name, 66 debug_on=True) 67 68 def teardown_method(self): 69 Application.uninstall(self.config['bundle_name']) 70 71 # terminate the hilog receive process after the test done 72 time.sleep(3) 73 self.hilog_process.stdout.close() 74 self.hilog_process.terminate() 75 self.hilog_process.wait() 76 self.write_thread.join() 77 78 Utils.save_fault_log(log_path=self.log_path) 79 logging.info('TestWorkerDropFrame02 done') 80 81 def test(self, test_suite_worker_07_debug): 82 logging.info('Start running TestWorkerDropFrame02: test') 83 self.config = test_suite_worker_07_debug 84 websocket = self.config['websocket'] 85 taskpool = self.config['taskpool'] 86 pid = self.config['pid'] 87 self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket) 88 self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket) 89 90 taskpool.submit(websocket.main_task(taskpool, self.procedure, pid)) 91 taskpool.await_taskpool() 92 taskpool.task_join() 93 if taskpool.task_exception: 94 raise taskpool.task_exception 95 96 async def procedure(self, websocket): 97 ################################################################################################################ 98 # main thread: connect the debugger server 99 ################################################################################################################ 100 main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True) 101 logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}') 102 ################################################################################################################ 103 # main thread: Runtime.enable 104 ################################################################################################################ 105 await self.runtime_impl.send("Runtime.enable", main_thread) 106 ################################################################################################################ 107 # main thread: Debugger.enable 108 ################################################################################################################ 109 await self.debugger_impl.send("Debugger.enable", main_thread) 110 ################################################################################################################ 111 # main thread: Runtime.runIfWaitingForDebugger 112 ################################################################################################################ 113 await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread) 114 ################################################################################################################ 115 # main thread: Debugger.scriptParsed 116 ################################################################################################################ 117 response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread) 118 assert response['params']['url'] == self.config['file_path']['entry_ability'] 119 assert response['params']['endLine'] == 0 120 ################################################################################################################ 121 # main thread: Debugger.paused 122 ################################################################################################################ 123 response = await self.debugger_impl.recv("Debugger.paused", main_thread) 124 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability'] 125 assert response['params']['reason'] == 'Break on start' 126 ################################################################################################################ 127 # main thread: Debugger.resume 128 ################################################################################################################ 129 await self.debugger_impl.send("Debugger.resume", main_thread) 130 ################################################################################################################ 131 # main thread: Debugger.scriptParsed 132 ################################################################################################################ 133 response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread) 134 assert response['params']['url'] == self.config['file_path']['index'] 135 assert response['params']['endLine'] == 0 136 ################################################################################################################ 137 # main thread: Debugger.paused 138 ################################################################################################################ 139 response = await self.debugger_impl.recv("Debugger.paused", main_thread) 140 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index'] 141 assert response['params']['reason'] == 'Break on start' 142 ################################################################################################################ 143 # main thread: Debugger.resume 144 ################################################################################################################ 145 await self.debugger_impl.send("Debugger.resume", main_thread) 146 ################################################################################################################ 147 # main thread: click on the screen 148 ################################################################################################################ 149 Application.click_on_middle() 150 ################################################################################################################ 151 # worker thread: connect the debugger server 152 ################################################################################################################ 153 worker_thread_1 = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], False) 154 logging.info(f'Connect to the debugger server of instance: {worker_thread_1.instance_id}') 155 ################################################################################################################ 156 # worker thread: Runtime.enable 157 ################################################################################################################ 158 await self.runtime_impl.send("Runtime.enable", worker_thread_1) 159 ################################################################################################################ 160 # worker thread: Debugger.enable 161 ################################################################################################################ 162 await self.debugger_impl.send("Debugger.enable", worker_thread_1) 163 ################################################################################################################ 164 # worker thread: Runtime.runIfWaitingForDebugger 165 ################################################################################################################ 166 await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", worker_thread_1) 167 ################################################################################################################ 168 # worker thread: Debugger.scriptParsed 169 ################################################################################################################ 170 response = await self.debugger_impl.recv("Debugger.scriptParsed", worker_thread_1) 171 assert response['params']['url'] == self.config['file_path']['worker'] 172 assert response['params']['endLine'] == 0 173 # worker thread: Debugger.paused 174 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 175 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 176 assert response['params']['reason'] == 'Break on start' 177 ################################################################################################################ 178 # worker thread: connect the debugger server 179 ################################################################################################################ 180 worker_thread_2 = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], False) 181 logging.info(f'Connect to the debugger server of instance: {worker_thread_2.instance_id}') 182 ################################################################################################################ 183 # worker thread: Runtime.enable 184 ################################################################################################################ 185 await self.runtime_impl.send("Runtime.enable", worker_thread_2) 186 ################################################################################################################ 187 # worker thread: Debugger.enable 188 ################################################################################################################ 189 await self.debugger_impl.send("Debugger.enable", worker_thread_2) 190 ################################################################################################################ 191 # worker thread: Runtime.runIfWaitingForDebugger 192 ################################################################################################################ 193 await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", worker_thread_2) 194 ################################################################################################################ 195 # worker thread: Debugger.removeBreakpointsByUrl 196 ################################################################################################################ 197 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 198 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 199 ################################################################################################################ 200 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 201 ################################################################################################################ 202 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=64)] 203 params = debugger.SetBreakpointsLocations(locations) 204 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 205 worker_thread_1, params) 206 assert response['result']['locations'][0]['id'] == 'id:64:0:' + self.config['file_path']['worker'] 207 ################################################################################################################ 208 # worker thread: Debugger.resume 209 ################################################################################################################ 210 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 211 # worker thread: Debugger.paused 212 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 213 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 214 assert response['params']['reason'] == 'other' 215 assert response['params']['hitBreakpoints'] == ['id:64:5:' + self.config['file_path']['worker']] 216 ################################################################################################################ 217 # worker thread: Debugger.evaluateOnCallFrame 218 ################################################################################################################ 219 P1_INTRODUCE = ( 220 'UEFOREEAAAAAAAAADAACAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAoQAAANQAAACAAAAAZAEAAAIAAA' 221 'BsAAAAAwAAAHQAAAD/////////////////////oQAAANQAAACAAAAAkgAAAJ0AAAAhZGVidWdnZXJHZXRWYWx1ZQATaW50cm9kdWNlAAVw' 222 'MQAzTF9FU1Nsb3ROdW1iZXJBbm5vdGF0aW9uOwAAAAAAgUAAAAIAABdmdW5jX21haW5fMAATTF9HTE9CQUw7AAAAAAABAAECAAABAP//xw' 223 'AAAIgCAR4BAAACAAVWAQAABhEBAAAAFVNsb3ROdW1iZXIAAAABAAUBAAAIAAAANwoDLwBEoESxRMJtYQZgBkIAAABhBz4CAGEIAmEJYAcr' 224 'AggJYQVgBUIEAQBhBGAELQYFZAtrAQ8A/////w8AAgAoAFEBAAA=') 225 ARR_JOIN = ( 226 'UEFOREEAAAAAAAAADAACAGABAAAAAAAAAAAAAAIAAAA8AAAAAQAAAFwBAAAAAAAARAAAAAEAAABEAAAAnQAAANAAAACAAAAAYAEAAAIAAA' 227 'BsAAAAAwAAAHQAAAD/////////////////////nQAAANAAAACAAAAAhQAAAJcAAAAHYXJyACFkZWJ1Z2dlckdldFZhbHVlAAlqb2luADNM' 228 'X0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEA///DAAAAiA' 229 'IBGgEAAAIABVIBAAAGDQEAAAAVU2xvdE51bWJlcgAAAAEAAQEAAAgAAAA3CgMvAESgRLFEwm1hBmAGQgABAGEHPgAAYQgCYQlgBysCCAlh' 230 'BWAFQgQCAGEEYAQtBgVkC2sBDwD/////DwACACgATQEAAA==') 231 params = debugger.EvaluateOnCallFrameParams(P1_INTRODUCE) 232 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 233 assert response['result']['result']['description'] == "name = Kate; age = 10" 234 params = debugger.EvaluateOnCallFrameParams('map') 235 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 236 assert response['result']['result']['description'].startswith("Map(2) {0 => 'str0', 1 => 'str1'}") 237 params = debugger.EvaluateOnCallFrameParams(ARR_JOIN) 238 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 239 assert response['result']['result']['description'] == "10,11,2,3" 240 ################################################################################################################ 241 # worker thread: Debugger.dropFrame 242 ################################################################################################################ 243 params = debugger.DropFrameParams() 244 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 245 # worker thread: Debugger.paused 246 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 247 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 248 assert response['params']['reason'] == 'other' 249 assert response['params']['hitBreakpoints'] == [] 250 ################################################################################################################ 251 # worker thread: Debugger.evaluateOnCallFrame 252 ################################################################################################################ 253 params = debugger.EvaluateOnCallFrameParams(P1_INTRODUCE) 254 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 255 assert response['result']['result']['description'] == "name = Kate; age = 10" 256 params = debugger.EvaluateOnCallFrameParams('map') 257 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 258 assert response['result']['result']['description'].startswith("Map(2) {0 => 'str0', 1 => 'str1'}") 259 params = debugger.EvaluateOnCallFrameParams(ARR_JOIN) 260 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 261 assert response['result']['result']['description'] == "10,11,2,3" 262 ################################################################################################################ 263 # worker thread: Debugger.removeBreakpointsByUrl 264 ################################################################################################################ 265 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 266 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 267 ################################################################################################################ 268 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 269 ################################################################################################################ 270 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=72)] 271 params = debugger.SetBreakpointsLocations(locations) 272 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 273 worker_thread_1, params) 274 assert response['result']['locations'][0]['id'] == 'id:72:0:' + self.config['file_path']['worker'] 275 ################################################################################################################ 276 # worker thread: Debugger.resume 277 ################################################################################################################ 278 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 279 # worker thread: Debugger.paused 280 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 281 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 282 assert response['params']['reason'] == 'other' 283 assert response['params']['hitBreakpoints'] == ['id:72:5:' + self.config['file_path']['worker']] 284 ################################################################################################################ 285 # worker thread: Debugger.evaluateOnCallFrame 286 ################################################################################################################ 287 params = debugger.EvaluateOnCallFrameParams(P1_INTRODUCE) 288 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 289 assert response['result']['result']['description'] == "name = Tony; age = 30" 290 params = debugger.EvaluateOnCallFrameParams('map') 291 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 292 assert response['result']['result']['description'].startswith("Map(1) {2 => 'str2'}") 293 params = debugger.EvaluateOnCallFrameParams(ARR_JOIN) 294 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 295 assert response['result']['result']['description'] == "4,3,2,1,0" 296 ################################################################################################################ 297 # worker thread: Debugger.dropFrame 298 ################################################################################################################ 299 params = debugger.DropFrameParams() 300 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 301 # worker thread: Debugger.paused 302 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 303 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 304 assert response['params']['reason'] == 'other' 305 assert response['params']['hitBreakpoints'] == [] 306 ################################################################################################################ 307 # worker thread: Debugger.evaluateOnCallFrame 308 ################################################################################################################ 309 params = debugger.EvaluateOnCallFrameParams(P1_INTRODUCE) 310 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 311 assert response['result']['result']['description'] == "name = Kate; age = 10" 312 params = debugger.EvaluateOnCallFrameParams('map') 313 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 314 assert response['result']['result']['description'].startswith("Map(2) {0 => 'str0', 1 => 'str1'}") 315 params = debugger.EvaluateOnCallFrameParams(ARR_JOIN) 316 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 317 assert response['result']['result']['description'] == "10,11,2,3" 318 ################################################################################################################ 319 # worker thread: Debugger.removeBreakpointsByUrl 320 ################################################################################################################ 321 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 322 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 323 ################################################################################################################ 324 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 325 ################################################################################################################ 326 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=79)] 327 params = debugger.SetBreakpointsLocations(locations) 328 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 329 worker_thread_1, params) 330 assert response['result']['locations'][0]['id'] == 'id:79:0:' + self.config['file_path']['worker'] 331 ################################################################################################################ 332 # worker thread: Debugger.resume 333 ################################################################################################################ 334 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 335 # worker thread: Debugger.paused 336 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 337 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 338 assert response['params']['reason'] == 'other' 339 assert response['params']['hitBreakpoints'] == ['id:79:19:' + self.config['file_path']['worker']] 340 ################################################################################################################ 341 # worker thread: Debugger.evaluateOnCallFrame 342 ################################################################################################################ 343 params = debugger.EvaluateOnCallFrameParams('c') 344 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 345 assert response['result']['result'] == {"type": "number", "unserializableValue": "3", "description": "3"} 346 ################################################################################################################ 347 # worker thread: Debugger.dropFrame 348 ################################################################################################################ 349 params = debugger.DropFrameParams() 350 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 351 # worker thread: Debugger.paused 352 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 353 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 354 assert response['params']['reason'] == 'other' 355 assert response['params']['hitBreakpoints'] == [] 356 ################################################################################################################ 357 # worker thread: Debugger.evaluateOnCallFrame 358 ################################################################################################################ 359 params = debugger.EvaluateOnCallFrameParams('c') 360 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 361 assert response['result']['result'] == {"type": "number", "unserializableValue": "2", "description": "2"} 362 ################################################################################################################ 363 # worker thread: Debugger.dropFrame 364 ################################################################################################################ 365 params = debugger.DropFrameParams() 366 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 367 # worker thread: Debugger.paused 368 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 369 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 370 assert response['params']['reason'] == 'other' 371 assert response['params']['hitBreakpoints'] == [] 372 ################################################################################################################ 373 # worker thread: Debugger.evaluateOnCallFrame 374 ################################################################################################################ 375 params = debugger.EvaluateOnCallFrameParams('c') 376 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 377 assert response['result']['result'] == {"type": "number", "unserializableValue": "1", "description": "1"} 378 ################################################################################################################ 379 # worker thread: Debugger.removeBreakpointsByUrl 380 ################################################################################################################ 381 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 382 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 383 ################################################################################################################ 384 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 385 ################################################################################################################ 386 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=94)] 387 params = debugger.SetBreakpointsLocations(locations) 388 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 389 worker_thread_1, params) 390 assert response['result']['locations'][0]['id'] == 'id:94:0:' + self.config['file_path']['worker'] 391 ################################################################################################################ 392 # worker thread: Debugger.resume 393 ################################################################################################################ 394 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 395 # worker thread: Debugger.paused 396 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 397 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 398 assert response['params']['reason'] == 'other' 399 assert response['params']['hitBreakpoints'] == ['id:94:22:' + self.config['file_path']['worker']] 400 ################################################################################################################ 401 # worker thread: Debugger.evaluateOnCallFrame 402 ################################################################################################################ 403 params = debugger.EvaluateOnCallFrameParams('b') 404 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 405 assert response['result']['result'] == {"type": "number", "unserializableValue": "2", "description": "2"} 406 ################################################################################################################ 407 # worker thread: Debugger.dropFrame 408 ################################################################################################################ 409 params = debugger.DropFrameParams() 410 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 411 # worker thread: Debugger.paused 412 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 413 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 414 assert response['params']['reason'] == 'other' 415 assert response['params']['hitBreakpoints'] == [] 416 ################################################################################################################ 417 # worker thread: Debugger.evaluateOnCallFrame 418 ################################################################################################################ 419 params = debugger.EvaluateOnCallFrameParams('b') 420 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 421 assert response['result']['result'] == {"type": "number", "unserializableValue": "1", "description": "1"} 422 ################################################################################################################ 423 # worker thread: Debugger.removeBreakpointsByUrl 424 ################################################################################################################ 425 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 426 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 427 ################################################################################################################ 428 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 429 ################################################################################################################ 430 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=100)] 431 params = debugger.SetBreakpointsLocations(locations) 432 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 433 worker_thread_1, params) 434 assert response['result']['locations'][0]['id'] == 'id:100:0:' + self.config['file_path']['worker'] 435 ################################################################################################################ 436 # worker thread: Debugger.resume 437 ################################################################################################################ 438 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 439 # worker thread: Debugger.paused 440 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 441 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 442 assert response['params']['reason'] == 'other' 443 assert response['params']['hitBreakpoints'] == ['id:100:8:' + self.config['file_path']['worker']] 444 ################################################################################################################ 445 # worker thread: Debugger.evaluateOnCallFrame 446 ################################################################################################################ 447 params = debugger.EvaluateOnCallFrameParams('b') 448 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 449 assert response['result']['result'] == {"type": "number", "unserializableValue": "3", "description": "3"} 450 ################################################################################################################ 451 # worker thread: Debugger.dropFrame 452 ################################################################################################################ 453 params = debugger.DropFrameParams() 454 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_1, params) 455 # worker thread: Debugger.paused 456 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_1) 457 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 458 assert response['params']['reason'] == 'other' 459 assert response['params']['hitBreakpoints'] == [] 460 ################################################################################################################ 461 # worker thread: Debugger.evaluateOnCallFrame 462 ################################################################################################################ 463 params = debugger.EvaluateOnCallFrameParams('b') 464 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_1, params) 465 assert response['result']['result'] == {"type": "number", "unserializableValue": "0", "description": "0"} 466 ################################################################################################################ 467 # worker thread: Debugger.removeBreakpointsByUrl 468 ################################################################################################################ 469 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 470 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_1, params) 471 ################################################################################################################ 472 # worker thread: Debugger.resume 473 ################################################################################################################ 474 await self.debugger_impl.send("Debugger.resume", worker_thread_1) 475 ################################################################################################################ 476 # worker thread: Debugger.scriptParsed 477 ################################################################################################################ 478 response = await self.debugger_impl.recv("Debugger.scriptParsed", worker_thread_2) 479 assert response['params']['url'] == self.config['file_path']['worker'] 480 assert response['params']['endLine'] == 0 481 # worker thread: Debugger.paused 482 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 483 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 484 assert response['params']['reason'] == 'Break on start' 485 ################################################################################################################ 486 # worker thread: Debugger.removeBreakpointsByUrl 487 ################################################################################################################ 488 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 489 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_2, params) 490 ################################################################################################################ 491 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 492 ################################################################################################################ 493 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=127)] 494 params = debugger.SetBreakpointsLocations(locations) 495 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 496 worker_thread_2, params) 497 assert response['result']['locations'][0]['id'] == 'id:127:0:' + self.config['file_path']['worker'] 498 ################################################################################################################ 499 # worker thread: Debugger.resume 500 ################################################################################################################ 501 await self.debugger_impl.send("Debugger.resume", worker_thread_2) 502 # worker thread: Debugger.paused 503 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 504 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 505 assert response['params']['reason'] == 'other' 506 assert response['params']['hitBreakpoints'] == ['id:127:9:' + self.config['file_path']['worker']] 507 ################################################################################################################ 508 # worker thread: Debugger.evaluateOnCallFrame 509 ################################################################################################################ 510 params = debugger.EvaluateOnCallFrameParams('ac') 511 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_2, params) 512 assert response['result']['result'] == {"type": "number", "unserializableValue": "20", "description": "20"} 513 ################################################################################################################ 514 # worker thread: Debugger.dropFrame 515 ################################################################################################################ 516 params = debugger.DropFrameParams() 517 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_2, params) 518 # worker thread: Debugger.paused 519 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 520 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 521 assert response['params']['reason'] == 'other' 522 assert response['params']['hitBreakpoints'] == [] 523 ################################################################################################################ 524 # worker thread: Debugger.evaluateOnCallFrame 525 ################################################################################################################ 526 params = debugger.EvaluateOnCallFrameParams('ac') 527 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_2, params) 528 assert response['result']['result'] == {"type": "number", "unserializableValue": "10", "description": "10"} 529 ################################################################################################################ 530 # worker thread: Debugger.dropFrame 531 ################################################################################################################ 532 params = debugger.DropFrameParams() 533 response = await self.debugger_impl.send("Debugger.dropFrame", worker_thread_2, params) 534 assert response['result']['message'] == 'Not yet support sendable method' 535 ################################################################################################################ 536 # worker thread: Debugger.removeBreakpointsByUrl 537 ################################################################################################################ 538 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 539 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_2, params) 540 ################################################################################################################ 541 # worker thread: Debugger.getPossibleAndSetBreakpointByUrl 542 ################################################################################################################ 543 locations = [debugger.BreakLocationUrl(url=self.config['file_path']['worker'], line_number=111)] 544 params = debugger.SetBreakpointsLocations(locations) 545 response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", 546 worker_thread_2, params) 547 assert response['result']['locations'][0]['id'] == 'id:111:0:' + self.config['file_path']['worker'] 548 ################################################################################################################ 549 # worker thread: Debugger.resume 550 ################################################################################################################ 551 await self.debugger_impl.send("Debugger.resume", worker_thread_2) 552 # worker thread: Debugger.paused 553 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 554 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 555 assert response['params']['reason'] == 'other' 556 assert response['params']['hitBreakpoints'] == ['id:111:9:' + self.config['file_path']['worker']] 557 ################################################################################################################ 558 # worker thread: Debugger.evaluateOnCallFrame 559 ################################################################################################################ 560 params = debugger.EvaluateOnCallFrameParams('ia') 561 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_2, params) 562 assert response['result']['result'] == {"type": "number", "unserializableValue": "200", "description": "200"} 563 ################################################################################################################ 564 # worker thread: Debugger.dropFrame 565 ################################################################################################################ 566 params = debugger.DropFrameParams() 567 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_2, params) 568 # worker thread: Debugger.paused 569 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 570 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 571 assert response['params']['reason'] == 'other' 572 assert response['params']['hitBreakpoints'] == [] 573 ################################################################################################################ 574 # worker thread: Debugger.evaluateOnCallFrame 575 ################################################################################################################ 576 params = debugger.EvaluateOnCallFrameParams('ia') 577 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_2, params) 578 assert response['result']['result'] == {"type": "number", "unserializableValue": "120", "description": "120"} 579 ################################################################################################################ 580 # worker thread: Debugger.dropFrame 581 ################################################################################################################ 582 params = debugger.DropFrameParams() 583 await self.debugger_impl.send("Debugger.dropFrame", worker_thread_2, params) 584 # worker thread: Debugger.paused 585 response = await self.debugger_impl.recv("Debugger.paused", worker_thread_2) 586 assert response['params']['callFrames'][0]['url'] == self.config['file_path']['worker'] 587 assert response['params']['reason'] == 'other' 588 assert response['params']['hitBreakpoints'] == [] 589 ################################################################################################################ 590 # worker thread: Debugger.evaluateOnCallFrame 591 ################################################################################################################ 592 params = debugger.EvaluateOnCallFrameParams('ia') 593 response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", worker_thread_2, params) 594 assert response['result']['result'] == {"type": "number", "unserializableValue": "100", "description": "100"} 595 ################################################################################################################ 596 # worker thread: Debugger.removeBreakpointsByUrl 597 ################################################################################################################ 598 params = debugger.RemoveBreakpointsUrl(self.config['file_path']['worker']) 599 await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread_2, params) 600 ################################################################################################################ 601 # worker thread: Debugger.resume 602 ################################################################################################################ 603 await self.debugger_impl.send("Debugger.resume", worker_thread_2) 604 ################################################################################################################ 605 # worker thread: Debugger.disable 606 ################################################################################################################ 607 await self.debugger_impl.send("Debugger.disable", worker_thread_2) 608 ################################################################################################################ 609 # worker thread: Debugger.disable 610 ################################################################################################################ 611 await self.debugger_impl.send("Debugger.disable", worker_thread_1) 612 ################################################################################################################ 613 # main thread: Debugger.disable 614 ################################################################################################################ 615 await self.debugger_impl.send("Debugger.disable", main_thread) 616 ################################################################################################################ 617 # close the websocket connections 618 ################################################################################################################ 619 await websocket.send_msg_to_debugger_server(worker_thread_2.instance_id, worker_thread_2.send_msg_queue, 620 'close') 621 await websocket.send_msg_to_debugger_server(worker_thread_1.instance_id, worker_thread_1.send_msg_queue, 622 'close') 623 await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close') 624 await websocket.send_msg_to_connect_server('close') 625 ################################################################################################################