| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/debugger-test.js"></script> |
| |
| <script> |
| |
| function f1() |
| { |
| var a=0;var b=1;var c=3;var d=4;var e=5; |
| var f=0; |
| return 0; |
| } |
| |
| var test = function() |
| { |
| WebInspector.breakpointManager._storage._breakpoints = {}; |
| var panel = WebInspector.panels.scripts; |
| var sourceFrame; |
| |
| InspectorTest.runDebuggerTestSuite([ |
| function testBreakpointsInOriginalAndFormattedSource(next) |
| { |
| InspectorTest.showScriptSource("script-formatter-breakpoints.html", didShowScriptSource); |
| |
| function didShowScriptSource(frame) |
| { |
| sourceFrame = frame; |
| InspectorTest.setBreakpoint(sourceFrame, 10, "", true); |
| InspectorTest.waitUntilPaused(pausedInF1); |
| InspectorTest.evaluateInPageWithTimeout("f1()"); |
| } |
| |
| function pausedInF1(callFrames) |
| { |
| dumpBreakpointSidebarPane("while paused in raw"); |
| InspectorTest.resumeExecution(resumed); |
| } |
| |
| function resumed() |
| { |
| sourceFrame._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this); |
| sourceFrame._uiSourceCode.setFormatted(true); |
| } |
| |
| function didFormatPage() |
| { |
| sourceFrame._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormatPage, this); |
| // There should be a breakpoint in f1 although script is pretty-printed. |
| InspectorTest.waitUntilPaused(pausedInF1Again); |
| InspectorTest.evaluateInPageWithTimeout("f1()"); |
| } |
| |
| function pausedInF1Again(callFrames) |
| { |
| dumpBreakpointSidebarPane("while paused in pretty printed"); |
| sourceFrame._uiSourceCode.setFormatted(false); |
| dumpBreakpointSidebarPane("while paused in raw"); |
| InspectorTest.removeBreakpoint(sourceFrame, 10); |
| InspectorTest.resumeExecution(next); |
| } |
| }, |
| |
| function testBreakpointSetInOriginalAndRemovedInFormatted(next) |
| { |
| InspectorTest.showScriptSource("script-formatter-breakpoints.html", didShowScriptSource); |
| |
| function didShowScriptSource(frame) |
| { |
| sourceFrame = frame; |
| InspectorTest.addResult("Adding breakpoint."); |
| InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved); |
| InspectorTest.setBreakpoint(sourceFrame, 10, "", true); |
| } |
| |
| function breakpointResolved() |
| { |
| InspectorTest.addSniffer(WebInspector.UISourceCode.prototype, "updateLiveLocations", didFormatPage); |
| InspectorTest.addResult("Formatting."); |
| sourceFrame._uiSourceCode.setFormatted(true); |
| } |
| |
| function didFormatPage() |
| { |
| InspectorTest.addResult("Removing breakpoint."); |
| InspectorTest.removeBreakpoint(sourceFrame, 17); |
| InspectorTest.addResult("Unformatting."); |
| sourceFrame._uiSourceCode.setFormatted(false); |
| var breakpoints = WebInspector.breakpointManager._storage._setting.get(); |
| InspectorTest.assertEquals(breakpoints.length, 0, "There should not be any breakpoints in the storage."); |
| next(); |
| } |
| } |
| ]); |
| |
| function dumpBreakpointSidebarPane(title) |
| { |
| var paneElement = WebInspector.panels.scripts.sidebarPanes.jsBreakpoints.listElement |
| InspectorTest.addResult("Breakpoint sidebar pane " + title); |
| InspectorTest.addResult(InspectorTest.textContentWithLineBreaks(paneElement)); |
| } |
| } |
| |
| </script> |
| |
| </head> |
| |
| <body onload="runTest()"> |
| <p>Tests the script formatting is working fine with breakpoints. |
| </p> |
| |
| </body> |
| </html> |