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