| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
| 4 <script src="../../../http/tests/inspector/workspace-test.js"></script> | |
| 5 <script src="breakpoint-manager.js"></script> | |
| 6 | |
| 7 <script> | |
| 8 | |
| 9 function test() | |
| 10 { | |
| 11 var mockTarget; | |
| 12 | |
| 13 function createWorkspace() | |
| 14 { | |
| 15 InspectorTest.createWorkspace(true); | |
| 16 mockTarget = InspectorTest.createMockTarget(1, InspectorTest.DebuggerMod
elMock); | |
| 17 } | |
| 18 | |
| 19 function resetWorkspace(breakpointManager) | |
| 20 { | |
| 21 mockTarget.debuggerModel.reset(); | |
| 22 InspectorTest.addResult(" Resetting workspace."); | |
| 23 breakpointManager._debuggerWorkspaceBinding._reset(mockTarget); | |
| 24 InspectorTest.testNetworkProject._reset(); | |
| 25 } | |
| 26 | |
| 27 function createBreakpoint(uiSourceCodeId, lineNumber, condition, enabled) | |
| 28 { | |
| 29 return { sourceFileId: uiSourceCodeId, lineNumber: lineNumber, condition
: condition, enabled: enabled }; | |
| 30 } | |
| 31 | |
| 32 var serializedBreakpoints = []; | |
| 33 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar", true))
; | |
| 34 serializedBreakpoints.push(createBreakpoint("a.js", 20, "", false)); | |
| 35 serializedBreakpoints.push(createBreakpoint("b.js", 3, "", true)); | |
| 36 | |
| 37 createWorkspace(); | |
| 38 InspectorTest.setupLiveLocationSniffers(); | |
| 39 | |
| 40 var addUISourceCode = function() { | |
| 41 var args = [mockTarget].concat(Array.prototype.slice.call(arguments)); | |
| 42 return InspectorTest.addUISourceCode.apply(null, args); | |
| 43 } | |
| 44 var createBreakpointManager = function(serializedBreakpoints) { | |
| 45 return InspectorTest.createBreakpointManager(InspectorTest.testTargetMan
ager, InspectorTest.testDebuggerWorkspaceBinding, serializedBreakpoints); | |
| 46 } | |
| 47 | |
| 48 InspectorTest.runTestSuite([ | |
| 49 function testSetBreakpoint(next) | |
| 50 { | |
| 51 var breakpointManager = createBreakpointManager(); | |
| 52 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 53 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 30, 0,
"", true); | |
| 54 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 55 }, | |
| 56 | |
| 57 function testSetDisabledBreakpoint(next) | |
| 58 { | |
| 59 var breakpointManager = createBreakpointManager(); | |
| 60 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 61 var breakpoint = InspectorTest.setBreakpoint(breakpointManager, uiSo
urceCode, 30, 0, "", false); | |
| 62 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 63 InspectorTest.dumpBreakpointStorage(breakpointManager); | |
| 64 InspectorTest.addResult(" Enabling breakpoint"); | |
| 65 breakpoint.setEnabled(true); | |
| 66 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 67 }, | |
| 68 | |
| 69 function testSetConditionalBreakpoint(next) | |
| 70 { | |
| 71 var breakpointManager = createBreakpointManager(); | |
| 72 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 73 var breakpoint = InspectorTest.setBreakpoint(breakpointManager, uiSo
urceCode, 30, 0, "condition", true, step2); | |
| 74 | |
| 75 function step2() | |
| 76 { | |
| 77 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 78 InspectorTest.dumpBreakpointStorage(breakpointManager); | |
| 79 InspectorTest.addResult(" Updating condition"); | |
| 80 breakpoint.setCondition(""); | |
| 81 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 82 } | |
| 83 }, | |
| 84 | |
| 85 function testRestoreBreakpoints(next) | |
| 86 { | |
| 87 createWorkspace(); | |
| 88 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 89 addUISourceCode(breakpointManager, "a.js"); | |
| 90 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 91 }, | |
| 92 | |
| 93 function testRestoreBreakpointsTwice(next) | |
| 94 { | |
| 95 createWorkspace(); | |
| 96 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 97 addUISourceCode(breakpointManager, "a.js"); | |
| 98 addUISourceCode(breakpointManager, "a.js"); | |
| 99 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 100 }, | |
| 101 | |
| 102 function testRemoveBreakpoints(next) | |
| 103 { | |
| 104 createWorkspace(); | |
| 105 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 106 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 107 window.setBreakpointCallback = step2.bind(this); | |
| 108 | |
| 109 function step2() | |
| 110 { | |
| 111 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 112 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 30,
0, "", true, step3); | |
| 113 } | |
| 114 | |
| 115 function step3() | |
| 116 { | |
| 117 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 118 InspectorTest.removeBreakpoint(breakpointManager, uiSourceCode,
30, 0); | |
| 119 InspectorTest.removeBreakpoint(breakpointManager, uiSourceCode,
10, 0); | |
| 120 InspectorTest.removeBreakpoint(breakpointManager, uiSourceCode,
20, 0); | |
| 121 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 122 } | |
| 123 }, | |
| 124 | |
| 125 function testSetBreakpointThatShifts(next) | |
| 126 { | |
| 127 createWorkspace(); | |
| 128 var breakpointManager = createBreakpointManager(); | |
| 129 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 130 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 1015, 0
, "", true); | |
| 131 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 132 }, | |
| 133 | |
| 134 function testSetBreakpointThatShiftsTwice(next) | |
| 135 { | |
| 136 createWorkspace(); | |
| 137 var breakpointManager = createBreakpointManager(); | |
| 138 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 139 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 1015, 0
, "", true, step2); | |
| 140 | |
| 141 function step2() | |
| 142 { | |
| 143 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 144 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 101
5, 0, "", true); | |
| 145 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 146 } | |
| 147 }, | |
| 148 | |
| 149 function testSetBreakpointOutsideScript(next) | |
| 150 { | |
| 151 createWorkspace(); | |
| 152 var breakpointManager = createBreakpointManager(); | |
| 153 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 154 breakpointManager.setBreakpoint(uiSourceCode, 2500, 0, "", true); | |
| 155 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 156 }, | |
| 157 | |
| 158 function testNavigation(next) | |
| 159 { | |
| 160 createWorkspace(); | |
| 161 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 162 var uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | |
| 163 window.setBreakpointCallback = step2.bind(this); | |
| 164 | |
| 165 function step2() | |
| 166 { | |
| 167 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 168 InspectorTest.addResult("\n Navigating to B."); | |
| 169 resetWorkspace(breakpointManager); | |
| 170 var uiSourceCodeB = addUISourceCode(breakpointManager, "b.js"); | |
| 171 window.setBreakpointCallback = step3.bind(this); | |
| 172 } | |
| 173 | |
| 174 function step3() | |
| 175 { | |
| 176 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 177 InspectorTest.addResult("\n Navigating back to A."); | |
| 178 resetWorkspace(breakpointManager); | |
| 179 InspectorTest.addResult(" Resolving provisional breakpoint."); | |
| 180 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | |
| 181 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); | |
| 182 addUISourceCode(breakpointManager, "a.js", false, true); | |
| 183 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 184 } | |
| 185 }, | |
| 186 | |
| 187 function testSourceMapping(next) | |
| 188 { | |
| 189 var shiftingMapping = { | |
| 190 rawLocationToUILocation: function(rawLocation) | |
| 191 { | |
| 192 if (this._disabled) | |
| 193 return null; | |
| 194 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiL
ocation(rawLocation.lineNumber + 10, 0); | |
| 195 }, | |
| 196 | |
| 197 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | |
| 198 { | |
| 199 var networkURL = InspectorTest.testNetworkMapping.networkURL
(uiSourceCode); | |
| 200 return new WebInspector.DebuggerModel.Location(mockTarget.de
buggerModel, networkURL, lineNumber - 10, 0); | |
| 201 }, | |
| 202 | |
| 203 isIdentity: function() | |
| 204 { | |
| 205 return false; | |
| 206 } | |
| 207 }; | |
| 208 | |
| 209 // Source mapping will shift everything 10 lines ahead so that break
point 1 clashes with breakpoint 2. | |
| 210 var serializedBreakpoints = []; | |
| 211 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar"
, true)); | |
| 212 serializedBreakpoints.push(createBreakpoint("a.js", 20, "", true)); | |
| 213 | |
| 214 createWorkspace(); | |
| 215 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 216 var uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | |
| 217 window.setBreakpointCallback = step2.bind(this); | |
| 218 | |
| 219 function step2() | |
| 220 { | |
| 221 window.setBreakpointCallback = step3.bind(this); | |
| 222 } | |
| 223 | |
| 224 function step3() | |
| 225 { | |
| 226 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 227 InspectorTest.addResult("\n Toggling source mapping."); | |
| 228 mockTarget.debuggerModel.pushSourceMapping(shiftingMapping); | |
| 229 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 230 InspectorTest.addResult("\n Toggling source mapping back."); | |
| 231 mockTarget.debuggerModel.disableSourceMapping(shiftingMapping); | |
| 232 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 233 } | |
| 234 | |
| 235 }, | |
| 236 | |
| 237 function testProvisionalBreakpointsResolve(next) | |
| 238 { | |
| 239 var serializedBreakpoints = []; | |
| 240 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar"
, true)); | |
| 241 | |
| 242 createWorkspace(); | |
| 243 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 244 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 245 window.setBreakpointCallback = step2.bind(this); | |
| 246 | |
| 247 function step2() | |
| 248 { | |
| 249 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 250 resetWorkspace(breakpointManager); | |
| 251 InspectorTest.addResult(" Resolving provisional breakpoint."); | |
| 252 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | |
| 253 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 11, 0)); | |
| 254 var breakpoints = breakpointManager.allBreakpoints(); | |
| 255 InspectorTest.assertEquals(1, breakpoints.length, "Exactly one p
rovisional breakpoint should be registered in breakpoint manager."); | |
| 256 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 257 } | |
| 258 }, | |
| 259 | |
| 260 function testSourceMappingReload(next) | |
| 261 { | |
| 262 function createSourceMapping(uiSourceCodeA, uiSourceCodeB) | |
| 263 { | |
| 264 var mapping = { | |
| 265 rawLocationToUILocation: function(rawLocation) | |
| 266 { | |
| 267 if (this._disabled) | |
| 268 return null; | |
| 269 return uiSourceCodeB.uiLocation(rawLocation.lineNumber +
10, 0); | |
| 270 }, | |
| 271 | |
| 272 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | |
| 273 { | |
| 274 var networkURL = InspectorTest.testNetworkMapping.networ
kURL(uiSourceCodeA); | |
| 275 return new WebInspector.DebuggerModel.Location(mockTarge
t.debuggerModel, networkURL, lineNumber - 10, 0); | |
| 276 }, | |
| 277 | |
| 278 isIdentity: function() | |
| 279 { | |
| 280 return false; | |
| 281 } | |
| 282 }; | |
| 283 | |
| 284 return mapping; | |
| 285 } | |
| 286 // Source mapping will shift everything 10 lines ahead. | |
| 287 var serializedBreakpoints = [createBreakpoint("b.js", 20, "foo == ba
r", true)]; | |
| 288 createWorkspace(); | |
| 289 var breakpointManager = createBreakpointManager(serializedBreakpoint
s); | |
| 290 InspectorTest.addResult("\n Adding files:"); | |
| 291 var uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | |
| 292 var uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); | |
| 293 | |
| 294 InspectorTest.addResult("\n Toggling source mapping."); | |
| 295 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceCodeB
); | |
| 296 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); | |
| 297 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(mockTar
get, uiSourceCodeB, sourceMapping); | |
| 298 InspectorTest.runAfterPendingBreakpointUpdates(breakpointManager, br
eakpointActionsPerformedBeforeReload.bind(this)); | |
| 299 | |
| 300 function breakpointActionsPerformedBeforeReload() | |
| 301 { | |
| 302 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 303 InspectorTest.addResult("\n Reloading:"); | |
| 304 resetWorkspace(breakpointManager); | |
| 305 | |
| 306 InspectorTest.addResult("\n Adding files:"); | |
| 307 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | |
| 308 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); | |
| 309 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js", false
, true); | |
| 310 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true,
true); | |
| 311 | |
| 312 InspectorTest.addResult("\n Toggling source mapping."); | |
| 313 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC
odeB); | |
| 314 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); | |
| 315 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(moc
kTarget, uiSourceCodeB, sourceMapping); | |
| 316 InspectorTest.runAfterPendingBreakpointUpdates(breakpointManager
, breakpointActionsPerformed.bind(this)); | |
| 317 } | |
| 318 | |
| 319 function breakpointActionsPerformed() | |
| 320 { | |
| 321 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 322 } | |
| 323 }, | |
| 324 | |
| 325 function testBreakpointInCollectedReload(next) | |
| 326 { | |
| 327 createWorkspace(); | |
| 328 var breakpointManager = createBreakpointManager(); | |
| 329 InspectorTest.addResult("\n Adding file without script:"); | |
| 330 var uiSourceCode = addUISourceCode(breakpointManager, "a.js", true,
true); | |
| 331 | |
| 332 InspectorTest.addResult("\n Setting breakpoint:"); | |
| 333 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 10, 0,
"", true, step2); | |
| 334 | |
| 335 function step2() | |
| 336 { | |
| 337 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 338 InspectorTest.addResult("\n Reloading:"); | |
| 339 resetWorkspace(breakpointManager); | |
| 340 | |
| 341 InspectorTest.addResult("\n Adding file with script:"); | |
| 342 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | |
| 343 | |
| 344 InspectorTest.addResult("\n Emulating breakpoint resolved event
:"); | |
| 345 mockTarget.debuggerModel._breakpointResolved("a.js:10", new WebI
nspector.DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); | |
| 346 | |
| 347 InspectorTest.addResult("\n Make sure we don't do any unnecessa
ry breakpoint actions:"); | |
| 348 InspectorTest.runAfterPendingBreakpointUpdates(breakpointManager
, breakpointActionsPerformed.bind(this)); | |
| 349 | |
| 350 function breakpointActionsPerformed() | |
| 351 { | |
| 352 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 353 } | |
| 354 } | |
| 355 }, | |
| 356 ]); | |
| 357 }; | |
| 358 </script> | |
| 359 | |
| 360 </head> | |
| 361 | |
| 362 <body onload="runTest()"> | |
| 363 <p>Tests BreakpointManager class.</p> | |
| 364 | |
| 365 </body> | |
| 366 </html> | |
| OLD | NEW |