| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| function triggerAddScriptElement() { |
| let script = document.createElement("script"); |
| script.text = "console.log('dynamically added script element');"; |
| document.body.appendChild(script); |
| let suite = InspectorTest.createAsyncSuite("WI.Frame.extraScriptCollection"); |
| let mainFrame = WI.networkManager.mainFrame; |
| name: "FrameHasNoExtraScriptsYet", |
| description: "No extra scripts yet.", |
| InspectorTest.expectEqual(mainFrame.extraScriptCollection.size, 0, "Main frame should have no dynamic scripts."); |
| description: "Add extra script.", |
| WI.networkManager.mainFrame.awaitEvent(WI.Frame.Event.ExtraScriptAdded) |
| 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."); |
| InspectorTest.evaluateInPage("triggerAddScriptElement()"); |
| suite.runTestCasesAndFinish(); |
| <body onload="runTest()"> |
| <p>WI.Frame.extraScriptCollection.</p> |