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();
23 function onPageWithoutInjectedCodeLoaded()
25 webInspector
.inspectedWindow
.eval("window.bar", function(value
) {
26 output("With injected code: " + valueWithInjectedCode
);
27 output("Without injected code: " + value
);
31 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageWithInjectedCodeLoaded
);
32 webInspector
.inspectedWindow
.reload({
33 injectedScript
: "window.foo = 42;"
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)
47 var uiMessage
= viewMessages
[viewMessages
.length
- 1];
48 var message
= uiMessage
.consoleMessage();
49 if (message
.stackTrace
.length
< 1)
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
)
75 output("Script ID unavailable");
78 evaluateOnFrontend("InspectorTest.getScriptSource(\"" + scriptId
+ "\", reply);", function(source
) {
79 output("Source received:");
86 evaluateOnFrontend("InspectorTest.runWhenPageLoads(reply)", onPageWithInjectedCodeLoaded
);
87 webInspector
.inspectedWindow
.reload({
88 injectedScript
: "console.log(42)"
94 <body onload=
"runTest()">
95 <p>Tests that webInspector.inspectedWindow.reload() successfully injects and preprocesses user's code upon reload
</p>