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-when-paused-no-reveal.js"></script>
12 var panel
= WebInspector
.panels
.sources
;
15 function didStepInto()
17 InspectorTest
.addResult("Did step into");
20 InspectorTest
.addSniffer(InspectorTest
.debuggerModel
, "stepInto", didStepInto
, true);
22 function testLiveEditWhenPausedDoesNotCauseCursorMove(oldText
, newText
, next
)
24 InspectorTest
.showScriptSource("edit-me-when-paused-no-reveal.js", didShowScriptSource
);
26 function didShowScriptSource(sourceFrame
)
28 InspectorTest
.waitUntilPaused(paused
);
29 InspectorTest
.setBreakpoint(sourceFrame
, 8, "", true);
30 InspectorTest
.evaluateInPage("f1()", didEvaluateInPage
);
33 function paused(callFrames
)
35 sourceFrame
= panel
.visibleView
;
36 InspectorTest
.removeBreakpoint(sourceFrame
, 8);
37 InspectorTest
.addSniffer(InspectorTest
.debuggerModel
, "_didEditScriptSource", didEditScriptSource
);
38 InspectorTest
.replaceInSource(sourceFrame
, oldText
, newText
);
39 InspectorTest
.addResult("Moving cursor to (0, 0).");
40 sourceFrame
.setSelection(WebInspector
.TextRange
.createFromLocation(0, 0));
41 InspectorTest
.addResult("Committing live edit.");
42 InspectorTest
.commitSource(sourceFrame
);
45 function didEditScriptSource()
47 InspectorTest
.resumeExecution();
50 function didEvaluateInPage(result
)
52 var selection
= sourceFrame
.textEditor
.selection();
53 InspectorTest
.addResult("Cursor position is: (" + selection
.startLine
+ ", " +selection
.startColumn
+ ").");
54 InspectorTest
.assertEquals(sourceFrame
, panel
.visibleView
, "Another file editor is open.");
59 function testLiveEditWhenPausedThenStepIntoCausesCursorMove(oldText
, newText
, next
)
61 InspectorTest
.showScriptSource("edit-me-when-paused-no-reveal.js", didShowScriptSource
);
63 function didShowScriptSource(sourceFrame
)
65 InspectorTest
.waitUntilPaused(paused
);
66 InspectorTest
.setBreakpoint(sourceFrame
, 8, "", true);
67 InspectorTest
.evaluateInPage("f1()", didEvaluateInPage
);
70 function paused(callFrames
)
72 sourceFrame
= panel
.visibleView
;
73 InspectorTest
.removeBreakpoint(sourceFrame
, 8);
74 InspectorTest
.addSniffer(InspectorTest
.debuggerModel
, "_didEditScriptSource", didEditScriptSource
);
75 InspectorTest
.replaceInSource(sourceFrame
, oldText
, newText
);
76 InspectorTest
.addResult("Moving cursor to (0, 0).");
77 sourceFrame
.setSelection(WebInspector
.TextRange
.createFromLocation(0, 0));
78 InspectorTest
.addResult("Committing live edit.");
79 InspectorTest
.commitSource(sourceFrame
);
82 function didEditScriptSource()
84 InspectorTest
.addResult("Stepping into...");
85 InspectorTest
.addSniffer(WebInspector
.SourcesView
.prototype, "showSourceLocation", didRevealAfterStepInto
);
86 WebInspector
.panels
.sources
._stepIntoButton
.element
.click();
89 function didRevealAfterStepInto()
91 InspectorTest
.resumeExecution();
94 function didEvaluateInPage(result
)
96 var selection
= sourceFrame
.textEditor
.selection();
97 InspectorTest
.addResult("Cursor position is: (" + selection
.startLine
+ ", " +selection
.startColumn
+ ").");
98 InspectorTest
.assertEquals(sourceFrame
, panel
.visibleView
, "Another file editor is open.");
103 InspectorTest
.runDebuggerTestSuite([
104 function testLiveEditWithoutStepInWhenPausedDoesNotCauseCursorMove(next
)
106 testLiveEditWhenPausedDoesNotCauseCursorMove("function f2()", " function f2()", next
);
109 function testLiveEditWithStepInWhenPausedDoesNotCauseCursorMove(next
)
111 testLiveEditWhenPausedDoesNotCauseCursorMove("return x + f2();", "return x + f2(); ", next
);
114 function testLiveEditWithoutStepInWhenPausedThenStepIntoCausesCursorMove(next
)
116 testLiveEditWhenPausedThenStepIntoCausesCursorMove("function f2()", " function f2()", next
);
119 function testLiveEditWithStepInWhenPausedThenStepIntoCausesCursorMove(next
)
121 testLiveEditWhenPausedThenStepIntoCausesCursorMove("return x + f2();", "return x + f2(); ", next
);
130 <body onload=
"runTest()">
131 <p>Tests live edit feature.
</p>