| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| <script> |
| function triggerAddScriptElement() { |
| let script = document.createElement("script"); |
| script.text = "console.log('dynamically added script element');"; |
| document.body.appendChild(script); |
| } |
| |
| function test() |
| { |
| let suite = InspectorTest.createAsyncSuite("WI.Frame.extraScriptCollection"); |
| |
| let mainFrame = WI.networkManager.mainFrame; |
| |
| suite.addTestCase({ |
| name: "FrameHasNoExtraScriptsYet", |
| description: "No extra scripts yet.", |
| test(resolve, reject) { |
| InspectorTest.expectEqual(mainFrame.extraScriptCollection.size, 0, "Main frame should have no dynamic scripts."); |
| resolve(); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "AddExtraScript", |
| description: "Add extra script.", |
| test(resolve, reject) { |
| WI.networkManager.mainFrame.awaitEvent(WI.Frame.Event.ExtraScriptAdded) |
| .then((event) => { |
| InspectorTest.pass("ExtraScriptAdded event fired."); |
| InspectorTest.expectThat(event.data.script.dynamicallyAddedScriptElement, "Script should identify as dynamic."); |
| InspectorTest.expectEqual(mainFrame.extraScriptCollection.size, 1, "Main frame should have 1 dynamic script."); |
| }) |
| .then(resolve, reject); |
| |
| InspectorTest.evaluateInPage("triggerAddScriptElement()"); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>WI.Frame.extraScriptCollection.</p> |
| </body> |
| </html> |