3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script>
5 <script src="../../http/tests/inspector/workspace-test.js"></script>
6 <script src="resources/load-dynamic-script.js"></script>
11 InspectorTest.runDebuggerTestSuite([
12 function testOpenDevToolsAfterLoad(next)
14 var consoleMessagesCount = 2;
16 var messages = WebInspector.console.messages;
17 for (var i = 0; i < messages.length; ++i)
18 processMessage(messages[i]);
19 checkWhenScriptsLoaded();
21 function processMessage(message)
23 if (message._messageText.indexOf("DYNAMIC") !== -1)
24 --consoleMessagesCount;
27 function consoleMessageAppended(message)
29 processMessage(message);
30 checkWhenScriptsLoaded();
33 function checkWhenScriptsLoaded()
35 if (consoleMessagesCount) {
36 InspectorTest.addConsoleSniffer(consoleMessageAppended);
40 InspectorTest.addResult("Both dynamic scripts were loaded.");
41 var scripts = Object.values(WebInspector.debuggerModel.scripts);
43 function filterOutInlineAndStandaloneScripts(script)
45 return !script.isInlineScript() && script.sourceURL.indexOf("dynamic-script-tag.html") !== -1;
47 scripts = scripts.filter(filterOutInlineAndStandaloneScripts);
48 InspectorTest.addResult("Number of non-inline scripts with document url as a sourceURL: " + scripts.length + ".");
53 function testOpenDevToolsThenReload(next)
55 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, scriptParsed);
56 InspectorTest.addResult("Reloading page.");
57 InspectorTest.reloadPage(onPageReloaded);
59 var eventsCountBeforeNext = 2;
60 function onPageReloaded()
62 if (!--eventsCountBeforeNext)
66 function scriptParsed(event)
68 var script = event.data;
69 if (script.sourceURL.indexOf("dynamic-script-tag.html") !== -1) {
70 // Both dynamic scripts will be loaded before inline script on reload, so we are just checking
71 // that the first one that has document url as a sourceURL is inline.
72 InspectorTest.addResult("The first script with document url as a sourceURL to be seen is " + (script.isInlineScript() ? "" : "not ") + "inline script.");
73 InspectorTest.assertTrue(script.isInlineScript(), "Only inline scripts should have document url as a sourceURL.");
74 WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, scriptParsed);
75 if (!--eventsCountBeforeNext)
84 <body onload="runTest()">
85 <p>Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs.
86 <a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a>