Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger / live-edit.html
blobe24e4a15cb7c7430716b8d70bb6f7ecf599836a6
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/live-edit-test.js"></script>
6 <script src="resources/edit-me.js"></script>
7 <script src="resources/edit-me-syntax-error.js"></script>
8 <script src="resources/edit-me-when-paused.js"></script>
10 <script>
12 function test()
14 var panel = WebInspector.panels.sources;
16 InspectorTest.runDebuggerTestSuite([
17 function testLiveEdit(next)
19 InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
21 function didShowScriptSource(sourceFrame)
23 replaceInSource(sourceFrame, "return 0;", "return \"live-edited string\";", didEditScriptSource);
26 function didEditScriptSource()
28 InspectorTest.evaluateInPage("f()", didEvaluateInPage)
31 function didEvaluateInPage(result)
33 InspectorTest.assertEquals("live-edited string", result.description, "edited function returns wrong result");
34 InspectorTest.dumpSourceFrameContents(panel.visibleView);
35 next();
39 function testLiveEditSyntaxError(next)
41 InspectorTest.showScriptSource("edit-me-syntax-error.js", didShowScriptSource);
43 function didShowScriptSource(sourceFrame)
45 InspectorTest.replaceInSource(sourceFrame, ",\"I'm good\"", "\"I'm good\"");
46 InspectorTest.dumpSourceFrameContents(panel.visibleView);
47 next();
51 function testLiveEditWhenPaused(next)
53 InspectorTest.showScriptSource("edit-me-when-paused.js", didShowScriptSource);
55 function didShowScriptSource(sourceFrame)
57 InspectorTest.waitUntilPaused(paused);
58 InspectorTest.evaluateInPage("f1()", didEvaluateInPage);
61 function paused(callFrames)
63 replaceInSource(panel.visibleView, "return 1;", "return 2;\n\n\n\n", didEditScriptSource);
66 function didEditScriptSource()
68 InspectorTest.resumeExecution();
71 function didEvaluateInPage(result)
73 InspectorTest.assertEquals("3", result.description, "edited function returns wrong result");
74 next();
78 function testNoCrashWhenOnlyOneFunctionOnStack(next)
80 InspectorTest.showScriptSource("edit-me-when-paused.js", didShowScriptSource);
82 function didShowScriptSource(sourceFrame)
84 InspectorTest.waitUntilPaused(paused);
85 InspectorTest.evaluateInPage("setTimeout(f1, 0)");
88 function paused(callFrames)
90 InspectorTest.captureStackTrace(callFrames);
91 replaceInSource(panel.visibleView, "debugger;", "debugger;\n", didEditScriptSource);
94 function didEditScriptSource()
96 InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, InspectorTest.resumeExecution.bind(InspectorTest, next)));
100 function testBreakpointsUpdated(next)
102 InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
104 function didShowScriptSource(sourceFrame)
106 InspectorTest.addSniffer(sourceFrame, "_addBreakpointDecoration", breakpointAdded);
107 InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
110 function breakpointAdded()
112 replaceInSource(panel.visibleView, "function f()", "function newFunctionCreatedWithLiveEdit()\n{\n}\nfunction f()", didEditScriptSource);
115 function didEditScriptSource()
117 var breakpoints = panel.visibleView._breakpoints;
118 for (var lineNumber in breakpoints)
119 InspectorTest.assertEquals("5", lineNumber);
120 next();
124 function testNoCrashWhenLiveEditOnBreakpoint(next)
126 InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
128 var testSourceFrame;
130 function didShowScriptSource(sourceFrame)
132 testSourceFrame = sourceFrame;
133 InspectorTest.addSniffer(sourceFrame, "_addBreakpointDecoration", uiBreakpointAdded);
134 InspectorTest.setBreakpoint(sourceFrame, 3, "", true);
137 function uiBreakpointAdded() {
138 InspectorTest.addSniffer(testSourceFrame, "_addBreakpointDecoration", breakpointAdded);
141 function breakpointAdded()
143 InspectorTest.waitUntilPaused(pausedInF);
144 InspectorTest.evaluateInPage("setTimeout(f, 0)");
147 function pausedInF(callFrames)
149 replaceInSource(panel.visibleView, "function f()", "function f()\n", didEditScriptSource);
152 function didEditScriptSource()
154 InspectorTest.resumeExecution(resumed);
157 function resumed()
159 next();
164 function replaceInSource(sourceFrame, string, replacement, callback)
166 InspectorTest.addSniffer(InspectorTest.debuggerModel, "_didEditScriptSource", callback);
167 InspectorTest.replaceInSource(sourceFrame, string, replacement);
168 InspectorTest.commitSource(sourceFrame);
172 </script>
174 </head>
176 <body onload="runTest()">
177 <p>Tests live edit feature.</p>
179 </body>
180 </html>