| OLD | NEW |
| (Empty) |
| 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="resources/unformatted.js"></script> | |
| 6 | |
| 7 <script> | |
| 8 | |
| 9 function f1() | |
| 10 { | |
| 11 var a=0;var b=1;var c=3;var d=4;var e=5; | |
| 12 var f=0; | |
| 13 return 0; | |
| 14 } | |
| 15 | |
| 16 var test = function() | |
| 17 { | |
| 18 WebInspector.breakpointManager._storage._breakpoints = {}; | |
| 19 var panel = WebInspector.showPanel("sources"); | |
| 20 var scriptFormatter = InspectorTest.scriptFormatter(); | |
| 21 var sourceFrame; | |
| 22 var formattedSourceFrame; | |
| 23 | |
| 24 InspectorTest.runDebuggerTestSuite([ | |
| 25 function testBreakpointsInOriginalAndFormattedSource(next) | |
| 26 { | |
| 27 InspectorTest.showScriptSource("script-formatter-breakpoints.html",
didShowScriptSource); | |
| 28 | |
| 29 function didShowScriptSource(frame) | |
| 30 { | |
| 31 sourceFrame = frame; | |
| 32 InspectorTest.setBreakpoint(sourceFrame, 11, "", true); | |
| 33 InspectorTest.waitUntilPaused(pausedInF1); | |
| 34 InspectorTest.evaluateInPageWithTimeout("f1()"); | |
| 35 } | |
| 36 | |
| 37 function pausedInF1(callFrames) | |
| 38 { | |
| 39 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); | |
| 40 InspectorTest.resumeExecution(resumed); | |
| 41 } | |
| 42 | |
| 43 function resumed() | |
| 44 { | |
| 45 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); | |
| 46 scriptFormatter._toggleFormatScriptSource(); | |
| 47 } | |
| 48 | |
| 49 function uiSourceCodeScriptFormatted() | |
| 50 { | |
| 51 // There should be a breakpoint in f1 although script is pretty-
printed. | |
| 52 InspectorTest.waitUntilPaused(pausedInF1Again); | |
| 53 InspectorTest.evaluateInPageWithTimeout("f1()"); | |
| 54 } | |
| 55 | |
| 56 function pausedInF1Again(callFrames) | |
| 57 { | |
| 58 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty
printed"); | |
| 59 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | |
| 60 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); | |
| 61 InspectorTest.removeBreakpoint(sourceFrame, 11); | |
| 62 InspectorTest.resumeExecution(next); | |
| 63 } | |
| 64 }, | |
| 65 | |
| 66 function testBreakpointSetInOriginalAndRemovedInFormatted(next) | |
| 67 { | |
| 68 InspectorTest.showScriptSource("script-formatter-breakpoints.html",
didShowScriptSource); | |
| 69 | |
| 70 function didShowScriptSource(frame) | |
| 71 { | |
| 72 sourceFrame = frame; | |
| 73 InspectorTest.addResult("Adding breakpoint."); | |
| 74 InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoi
nt.prototype, "_addResolvedLocation", breakpointResolved); | |
| 75 InspectorTest.setBreakpoint(sourceFrame, 11, "", true); | |
| 76 } | |
| 77 | |
| 78 function breakpointResolved() | |
| 79 { | |
| 80 InspectorTest.addResult("Formatting."); | |
| 81 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); | |
| 82 scriptFormatter._toggleFormatScriptSource(); | |
| 83 } | |
| 84 | |
| 85 function uiSourceCodeScriptFormatted() | |
| 86 { | |
| 87 InspectorTest.addResult("Removing breakpoint."); | |
| 88 formattedSourceFrame = panel.visibleView; | |
| 89 InspectorTest.removeBreakpoint(formattedSourceFrame, 16); | |
| 90 InspectorTest.addResult("Unformatting."); | |
| 91 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | |
| 92 var breakpoints = WebInspector.breakpointManager._storage._setti
ng.get(); | |
| 93 InspectorTest.assertEquals(breakpoints.length, 0, "There should
not be any breakpoints in the storage."); | |
| 94 next(); | |
| 95 } | |
| 96 }, | |
| 97 | |
| 98 function testBreakpointsSetAndRemoveInFormattedSource(next) | |
| 99 { | |
| 100 InspectorTest.showScriptSource("unformatted.js", didShowScriptSource
); | |
| 101 | |
| 102 function didShowScriptSource(frame) | |
| 103 { | |
| 104 sourceFrame = frame; | |
| 105 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); | |
| 106 scriptFormatter._toggleFormatScriptSource(); | |
| 107 } | |
| 108 | |
| 109 function uiSourceCodeScriptFormatted() | |
| 110 { | |
| 111 formattedSourceFrame = panel.visibleView; | |
| 112 InspectorTest.setBreakpoint(formattedSourceFrame, 3, "", true); | |
| 113 InspectorTest.waitUntilPaused(pausedInF2); | |
| 114 InspectorTest.evaluateInPageWithTimeout("f2()"); | |
| 115 } | |
| 116 | |
| 117 function pausedInF2(callFrames) | |
| 118 { | |
| 119 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty
printed"); | |
| 120 InspectorTest.removeBreakpoint(formattedSourceFrame, 3); | |
| 121 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | |
| 122 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); | |
| 123 InspectorTest.resumeExecution(next); | |
| 124 } | |
| 125 }, | |
| 126 | |
| 127 function testBreakpointsSetInFormattedAndRemoveInOriginalSource(next) | |
| 128 { | |
| 129 InspectorTest.showScriptSource("unformatted.js", didShowScriptSource
); | |
| 130 | |
| 131 function didShowScriptSource(frame) | |
| 132 { | |
| 133 sourceFrame = frame; | |
| 134 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); | |
| 135 scriptFormatter._toggleFormatScriptSource(); | |
| 136 } | |
| 137 | |
| 138 function uiSourceCodeScriptFormatted() | |
| 139 { | |
| 140 formattedSourceFrame = panel.visibleView; | |
| 141 InspectorTest.setBreakpoint(formattedSourceFrame, 3, "", true); | |
| 142 InspectorTest.waitUntilPaused(pausedInF2); | |
| 143 InspectorTest.evaluateInPageWithTimeout("f2()"); | |
| 144 } | |
| 145 | |
| 146 function pausedInF2(callFrames) | |
| 147 { | |
| 148 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty
printed"); | |
| 149 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | |
| 150 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); | |
| 151 // No need to remove breakpoint since formattedUISourceCode was
removed. | |
| 152 InspectorTest.resumeExecution(next); | |
| 153 } | |
| 154 } | |
| 155 ]); | |
| 156 | |
| 157 } | |
| 158 | |
| 159 </script> | |
| 160 | |
| 161 </head> | |
| 162 | |
| 163 <body onload="runTest()"> | |
| 164 <p>Tests the script formatting is working fine with breakpoints. | |
| 165 </p> | |
| 166 | |
| 167 </body> | |
| 168 </html> | |
| OLD | NEW |