Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / extensions / extensions-reload.html
blobf7d2654e67d396af33952e2a2359abb93631d5c9
1 <html>
2 <head>
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/extensions-test.js"></script>
6 <script src="../../http/tests/inspector/console-test.js"></script>
7 <script type="text/javascript">
9 window.bar = "foo = " + window.foo;
11 function extension_testReloadInjectsCode(nextTest)
13 var valueWithInjectedCode;
15 function onPageWithInjectedCodeLoaded()
17 webInspector.inspectedWindow.eval("window.bar", function(value) {
18 valueWithInjectedCode = value;
19 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageWithoutInjectedCodeLoaded);
20 webInspector.inspectedWindow.reload();
21 });
23 function onPageWithoutInjectedCodeLoaded()
25 webInspector.inspectedWindow.eval("window.bar", function(value) {
26 output("With injected code: " + valueWithInjectedCode);
27 output("Without injected code: " + value);
28 nextTest();
29 });
31 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageWithInjectedCodeLoaded);
32 webInspector.inspectedWindow.reload({
33 injectedScript: "window.foo = 42;"
34 });
37 function initialize_testReloadInjectsCodeWithMessage()
39 InspectorTest.lastMessageScriptId = function(callback)
41 var consoleView = WebInspector.ConsolePanel._view();
42 if (consoleView._needsFullUpdate)
43 consoleView._updateMessageList();
44 var viewMessages = consoleView._visibleViewMessages;
45 if (viewMessages.length !== 1)
46 callback(null);
47 var uiMessage = viewMessages[viewMessages.length - 1];
48 var message = uiMessage.consoleMessage();
49 if (message.stackTrace.length < 1)
50 callback(null);
51 callback(message.stackTrace[0].scriptId);
53 InspectorTest.getScriptSource = function(scriptId, callback)
55 InspectorTest.DebuggerAgent.getScriptSource(scriptId, didGetScriptSource);
56 function didGetScriptSource(error, source)
58 callback(error ? "" : source);
63 function extension_testReloadInjectsCodeWithMessage(nextTest)
65 var valueWithInjectedCode;
67 function onPageWithInjectedCodeLoaded()
69 evaluateOnFrontend("InspectorTest.lastMessageScriptId(reply);", onScriptIdReceived);
72 function onScriptIdReceived(scriptId)
74 if (!scriptId) {
75 output("Script ID unavailable");
76 nextTest();
77 } else {
78 evaluateOnFrontend("InspectorTest.getScriptSource(\"" + scriptId + "\", reply);", function(source) {
79 output("Source received:");
80 output(source);
81 nextTest();
82 });
86 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageWithInjectedCodeLoaded);
87 webInspector.inspectedWindow.reload({
88 injectedScript: "console.log(42)"
89 });
92 </script>
93 </head>
94 <body onload="runTest()">
95 <p>Tests that webInspector.inspectedWindow.reload() successfully injects and preprocesses user's code upon reload</p>
96 </body>
97 </html>