| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script src="resources/unformatted.js"></script> | 5 <script src="resources/unformatted.js"></script> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 function f1() | 9 function f1() |
| 10 { | 10 { |
| 11 var a=0;var b=1;var c=3;var d=4;var e=5; | 11 var a=0;var b=1;var c=3;var d=4;var e=5; |
| 12 var f=0; | 12 var f=0; |
| 13 return 0; | 13 return 0; |
| 14 } | 14 } |
| 15 | 15 |
| 16 var test = function() | 16 var test = function() |
| 17 { | 17 { |
| 18 WebInspector.breakpointManager._storage._breakpoints = {}; | 18 WebInspector.breakpointManager._storage._breakpoints = {}; |
| 19 var panel = WebInspector.showPanel("sources"); | 19 var panel = WebInspector.showPanel("sources"); |
| 20 var scriptFormatter = InspectorTest.scriptFormatter(); | 20 var scriptFormatter = InspectorTest.scriptFormatter(); |
| 21 var sourceFrame; | 21 var sourceFrame; |
| 22 var formattedSourceFrame; | 22 var formattedSourceFrame; |
| 23 | 23 |
| 24 InspectorTest.runDebuggerTestSuite([ | 24 InspectorTest.runDebuggerTestSuite([ |
| 25 function testBreakpointsInOriginalAndFormattedSource(next) | 25 function testBreakpointsSetAndRemoveInFormattedSource(next) |
| 26 { | 26 { |
| 27 InspectorTest.showScriptSource("script-formatter-breakpoints.html",
didShowScriptSource); | 27 InspectorTest.showScriptSource("unformatted.js", didShowScriptSource
); |
| 28 | 28 |
| 29 function didShowScriptSource(frame) | 29 function didShowScriptSource(frame) |
| 30 { | 30 { |
| 31 sourceFrame = frame; | 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); | 32 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); |
| 46 scriptFormatter._toggleFormatScriptSource(); | 33 scriptFormatter._toggleFormatScriptSource(); |
| 47 } | 34 } |
| 48 | 35 |
| 49 function uiSourceCodeScriptFormatted() | 36 function uiSourceCodeScriptFormatted() |
| 50 { | 37 { |
| 51 // There should be a breakpoint in f1 although script is pretty-
printed. | 38 formattedSourceFrame = panel.visibleView; |
| 52 InspectorTest.waitUntilPaused(pausedInF1Again); | 39 InspectorTest.setBreakpoint(formattedSourceFrame, 3, "", true); |
| 53 InspectorTest.evaluateInPageWithTimeout("f1()"); | 40 InspectorTest.waitUntilPaused(pausedInF2); |
| 41 InspectorTest.evaluateInPageWithTimeout("f2()"); |
| 54 } | 42 } |
| 55 | 43 |
| 56 function pausedInF1Again(callFrames) | 44 function pausedInF2(callFrames) |
| 57 { | 45 { |
| 58 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty
printed"); | 46 InspectorTest.dumpBreakpointSidebarPane("while paused in pretty
printed"); |
| 47 InspectorTest.removeBreakpoint(formattedSourceFrame, 3); |
| 59 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | 48 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); |
| 60 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); | 49 InspectorTest.dumpBreakpointSidebarPane("while paused in raw"); |
| 61 InspectorTest.removeBreakpoint(sourceFrame, 11); | |
| 62 InspectorTest.resumeExecution(next); | 50 InspectorTest.resumeExecution(next); |
| 63 } | 51 } |
| 64 }, | 52 }, |
| 65 | 53 |
| 66 function testBreakpointSetInOriginalAndRemovedInFormatted(next) | 54 function testBreakpointSetInOriginalAndRemovedInFormatted(next) |
| 67 { | 55 { |
| 68 InspectorTest.showScriptSource("script-formatter-breakpoints.html",
didShowScriptSource); | 56 InspectorTest.showScriptSource("script-formatter-breakpoints-2.html"
, didShowScriptSource); |
| 69 | 57 |
| 70 function didShowScriptSource(frame) | 58 function didShowScriptSource(frame) |
| 71 { | 59 { |
| 72 sourceFrame = frame; | 60 sourceFrame = frame; |
| 73 InspectorTest.addResult("Adding breakpoint."); | 61 InspectorTest.addResult("Adding breakpoint."); |
| 74 InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoi
nt.prototype, "_addResolvedLocation", breakpointResolved); | 62 InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoi
nt.prototype, "_addResolvedLocation", breakpointResolved); |
| 75 InspectorTest.setBreakpoint(sourceFrame, 11, "", true); | 63 InspectorTest.setBreakpoint(sourceFrame, 11, "", true); |
| 76 } | 64 } |
| 77 | 65 |
| 78 function breakpointResolved() | 66 function breakpointResolved() |
| 79 { | 67 { |
| 80 InspectorTest.addResult("Formatting."); | 68 InspectorTest.addResult("Formatting."); |
| 81 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); | 69 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorActio
n.prototype, "_updateButton", uiSourceCodeScriptFormatted); |
| 82 scriptFormatter._toggleFormatScriptSource(); | 70 scriptFormatter._toggleFormatScriptSource(); |
| 83 } | 71 } |
| 84 | 72 |
| 85 function uiSourceCodeScriptFormatted() | 73 function uiSourceCodeScriptFormatted() |
| 86 { | 74 { |
| 87 InspectorTest.addResult("Removing breakpoint."); | 75 InspectorTest.addResult("Removing breakpoint."); |
| 88 formattedSourceFrame = panel.visibleView; | 76 formattedSourceFrame = panel.visibleView; |
| 89 InspectorTest.removeBreakpoint(formattedSourceFrame, 16); | 77 InspectorTest.removeBreakpoint(formattedSourceFrame, 16); |
| 90 InspectorTest.addResult("Unformatting."); | 78 InspectorTest.addResult("Unformatting."); |
| 91 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); | 79 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibl
eView.uiSourceCode()); |
| 92 var breakpoints = WebInspector.breakpointManager._storage._setti
ng.get(); | 80 var breakpoints = WebInspector.breakpointManager._storage._setti
ng.get(); |
| 93 InspectorTest.assertEquals(breakpoints.length, 0, "There should
not be any breakpoints in the storage."); | 81 InspectorTest.assertEquals(breakpoints.length, 0, "There should
not be any breakpoints in the storage."); |
| 94 next(); | 82 next(); |
| 95 } | 83 } |
| 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 } | 84 } |
| 155 ]); | 85 ]); |
| 156 | 86 |
| 157 } | 87 } |
| 158 | 88 |
| 159 </script> | 89 </script> |
| 160 | 90 |
| 161 </head> | 91 </head> |
| 162 | 92 |
| 163 <body onload="runTest()"> | 93 <body onload="runTest()"> |
| 164 <p>Tests the script formatting is working fine with breakpoints. | 94 <p>Tests the script formatting is working fine with breakpoints. |
| 165 </p> | 95 </p> |
| 166 | 96 |
| 167 </body> | 97 </body> |
| 168 </html> | 98 </html> |
| OLD | NEW |