3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
5 <script src="../debugger-test.js"></script>
11 scriptElement = document.createElement("script");
12 scriptElement.src = "resources/long_script.cgi";
13 document.head.appendChild(scriptElement);
16 function unloadScript()
18 scriptElement.parentElement.removeChild(scriptElement);
24 window.internals.garbageCollectDocumentResources(document);
25 // In Oilpan, Resource objects are not destructed until GC.
26 if (window.GCController)
27 GCController.collectAll();
32 InspectorTest.hardReloadPage(step1);
36 InspectorTest.addConsoleSniffer(step2);
37 InspectorTest.evaluateInPage("loadScript()");
42 InspectorTest.evaluateInPage("unloadScript()", step3);
47 InspectorTest.waitForScriptSource("long_script.cgi", step4);
50 function step4(uiSourceCode)
52 InspectorTest.evaluateInPage("gc()", step5.bind(null, uiSourceCode));
55 function step5(uiSourceCode)
57 function requestContent()
59 InspectorTest.addResult("Fallback content is requested.");
61 InspectorTest.addSniffer(WebInspector.Script.prototype, "requestContent", requestContent);
63 uiSourceCode.requestContent(step6);
66 function step6(loadedScript)
68 var expected = "console.log('finished');\n";
69 InspectorTest.assertTrue(!!loadedScript, "No script content");
70 InspectorTest.assertEquals(1024 * 10240 + expected.length, loadedScript.length, "Loaded script length mismatch");
71 var actual = loadedScript.substring(loadedScript.length - expected.length);
72 InspectorTest.assertEquals(expected, actual, "Loaded script is corrupted");
74 InspectorTest.completeTest();
79 <body onload="runTest()">
80 <p> Tests long script content is correctly shown in source panel after page reload.</p>