OLD | NEW |
(Empty) | |
| 1 (async function(testRunner) { |
| 2 let {page, session, dp} = await testRunner.startBlank('Testing that the Node I
D can be retrieved before the onload event is triggered'); |
| 3 |
| 4 /* |
| 5 1. Create an iframe and point it to a page with a debugger statement. |
| 6 2. Wait until the debugger statement is hit and pause using the inspector pro
tocol. |
| 7 3. Use the JS context to identify the 'window.document' object inside the ifr
ame. |
| 8 4. Use the JS object to retrieve the DOM agent nodeId for the document node. |
| 9 */ |
| 10 |
| 11 dp.Page.onLoadEventFired(() => { |
| 12 // We should finish the test before this event is triggered. |
| 13 // If you see this in the output, then the slow-image is not loaded correctl
y in the iframe. |
| 14 testRunner.log('FAIL: Iframe load event fired before the test finished.'); |
| 15 testRunner.completeTest(); |
| 16 }); |
| 17 |
| 18 testRunner.log('step1_bootstrap'); |
| 19 // Enable Page agent for the Page.loadEventFired event. |
| 20 dp.Page.enable(); |
| 21 // Make sure the debugger ready to break on the 'debugger' statement. |
| 22 dp.Debugger.enable(); |
| 23 await dp.DOM.getDocument(); |
| 24 |
| 25 testRunner.log('Adding iframe'); |
| 26 session.evaluate(` |
| 27 var frame = document.createElement('iframe'); |
| 28 frame.src = 'data:text/html,<script>debugger;</script>'; |
| 29 document.body.appendChild(frame); |
| 30 `); |
| 31 |
| 32 var response = await dp.Debugger.oncePaused(); |
| 33 testRunner.log('Paused on the debugger statement'); |
| 34 response = await dp.Runtime.callFunctionOn({ |
| 35 objectId: response.params.callFrames[0].this.objectId, |
| 36 functionDeclaration: 'function() { return this.document; }' |
| 37 }); |
| 38 |
| 39 var objectId = response.result.result.objectId; |
| 40 testRunner.log('step2_requestNode: Requesting DOM node for iframe\'s document
node'); |
| 41 response = await dp.DOM.requestNode({objectId: objectId}); |
| 42 testRunner.log(response.result.nodeId ? 'PASS: Received node for iframe\'s doc
ument node' : 'FAIL: Iframe\'s document node is not available'); |
| 43 await dp.Debugger.resume(); |
| 44 testRunner.log('Test finished'); |
| 45 testRunner.completeTest(); |
| 46 }) |
OLD | NEW |