3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script src="resources/unformatted.js"></script>
11 var a=0;var b=1;var c=3;var d=4;var e=5;
18 WebInspector.breakpointManager._storage._breakpoints = {};
19 var panel = WebInspector.panels.sources;
22 InspectorTest.runDebuggerTestSuite([
23 function testBreakpointsInOriginalAndFormattedSource(next)
25 InspectorTest.showScriptSource("script-formatter-breakpoints.html", didShowScriptSource);
27 function didShowScriptSource(frame)
30 InspectorTest.setBreakpoint(sourceFrame, 11, "", true);
31 InspectorTest.waitUntilPaused(pausedInF1);
32 InspectorTest.evaluateInPageWithTimeout("f1()");
35 function pausedInF1(callFrames)
37 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
38 InspectorTest.resumeExecution(resumed);
43 sourceFrame._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
44 sourceFrame._uiSourceCode.setFormatted(true);
47 function didFormatPage()
49 sourceFrame._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
50 // There should be a breakpoint in f1 although script is pretty-printed.
51 InspectorTest.waitUntilPaused(pausedInF1Again);
52 InspectorTest.evaluateInPageWithTimeout("f1()");
55 function pausedInF1Again(callFrames)
57 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty printed");
58 sourceFrame._uiSourceCode.setFormatted(false);
59 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
60 InspectorTest.removeBreakpoint(sourceFrame, 11);
61 InspectorTest.resumeExecution(next);
65 function testBreakpointSetInOriginalAndRemovedInFormatted(next)
67 InspectorTest.showScriptSource("script-formatter-breakpoints.html", didShowScriptSource);
69 function didShowScriptSource(frame)
72 InspectorTest.addResult("Adding breakpoint.");
73 InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved);
74 InspectorTest.setBreakpoint(sourceFrame, 11, "", true);
77 function breakpointResolved()
79 InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "updateLiveLocations", didFormatPage);
80 InspectorTest.addResult("Formatting.");
81 sourceFrame._uiSourceCode.setFormatted(true);
84 function didFormatPage()
86 InspectorTest.addResult("Removing breakpoint.");
87 InspectorTest.removeBreakpoint(sourceFrame, 16);
88 InspectorTest.addResult("Unformatting.");
89 sourceFrame._uiSourceCode.setFormatted(false);
90 var breakpoints = WebInspector.breakpointManager._storage._setting.get();
91 InspectorTest.assertEquals(breakpoints.length, 0, "There should not be any breakpoints in the storage.");
96 function testBreakpointsSetAndRemoveInFormattedSource(next)
98 InspectorTest.showScriptSource("unformatted.js", didShowScriptSource);
100 function didShowScriptSource(frame)
103 sourceFrame._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
104 sourceFrame._uiSourceCode.setFormatted(true);
107 function didFormatPage()
109 sourceFrame._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
110 InspectorTest.setBreakpoint(sourceFrame, 3, "", true);
111 InspectorTest.waitUntilPaused(pausedInF2);
112 InspectorTest.evaluateInPageWithTimeout("f2()");
115 function pausedInF2(callFrames)
117 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty printed");
118 InspectorTest.removeBreakpoint(sourceFrame, 3);
119 sourceFrame._uiSourceCode.setFormatted(false);
120 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
121 InspectorTest.resumeExecution(next);
125 function testBreakpointsSetInFormattedAndRemoveInOriginalSource(next)
127 InspectorTest.showScriptSource("unformatted.js", didShowScriptSource);
129 function didShowScriptSource(frame)
132 sourceFrame._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
133 sourceFrame._uiSourceCode.setFormatted(true);
136 function didFormatPage()
138 sourceFrame._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this);
139 InspectorTest.setBreakpoint(sourceFrame, 3, "", true);
140 InspectorTest.waitUntilPaused(pausedInF2);
141 InspectorTest.evaluateInPageWithTimeout("f2()");
144 function pausedInF2(callFrames)
146 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty printed");
147 sourceFrame._uiSourceCode.setFormatted(false);
148 InspectorTest.dumpBreakpointSidebarPane("while paused in raw");
149 InspectorTest.removeBreakpoint(sourceFrame, 2);
150 InspectorTest.dumpBreakpointSidebarPane("after removed");
151 InspectorTest.resumeExecution(next);
161 <body onload="runTest()">
162 <p>Tests the script formatting is working fine with breakpoints.