Chromium Code Reviews| 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="breakpoint-manager.js"></script> | 4 <script src="breakpoint-manager.js"></script> |
| 5 <script> | 5 <script> |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 var mockTarget; | 8 var mockTarget; |
| 9 var lastTargetId = 0; | 9 var lastTargetId = 0; |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 InspectorTest.addResult("\n Navigating back to A."); | 166 InspectorTest.addResult("\n Navigating back to A."); |
| 167 resetWorkspace(breakpointManager); | 167 resetWorkspace(breakpointManager); |
| 168 InspectorTest.addResult(" Resolving provisional breakpoint."); | 168 InspectorTest.addResult(" Resolving provisional breakpoint."); |
| 169 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | 169 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); |
| 170 mockTarget.debuggerModel._breakpointResolved("a.js:10", new SDK. DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); | 170 mockTarget.debuggerModel._breakpointResolved("a.js:10", new SDK. DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); |
| 171 addUISourceCode(breakpointManager, "a.js", false, true); | 171 addUISourceCode(breakpointManager, "a.js", false, true); |
| 172 InspectorTest.finishBreakpointTest(breakpointManager, next); | 172 InspectorTest.finishBreakpointTest(breakpointManager, next); |
| 173 } | 173 } |
| 174 }, | 174 }, |
| 175 | 175 |
| 176 function testSourceMapping(next) | |
|
dgozman
2017/06/08 19:12:00
Please ensure we have a test for breakpoints+sourc
lushnikov
2017/06/08 21:14:34
There's a test which covers both reload and source
| |
| 177 { | |
| 178 var shiftingMapping = { | |
| 179 rawLocationToUILocation: function(rawLocation) | |
| 180 { | |
| 181 if (this._disabled) | |
| 182 return null; | |
| 183 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiL ocation(rawLocation.lineNumber + 10, 0); | |
| 184 }, | |
| 185 | |
| 186 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | |
| 187 { | |
| 188 return new SDK.DebuggerModel.Location(mockTarget.debuggerMod el, uiSourceCode.url(), lineNumber - 10, 0); | |
| 189 }, | |
| 190 | |
| 191 isIdentity: function() | |
| 192 { | |
| 193 return false; | |
| 194 } | |
| 195 }; | |
| 196 | |
| 197 // Source mapping will shift everything 10 lines ahead so that break point 1 clashes with breakpoint 2. | |
| 198 var serializedBreakpoints = []; | |
| 199 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar" , true)); | |
| 200 serializedBreakpoints.push(createBreakpoint("a.js", 20, "", true)); | |
| 201 | |
| 202 var breakpointManager = createBreakpointManager(serializedBreakpoint s); | |
| 203 var uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | |
| 204 window.setBreakpointCallback = step2.bind(this); | |
| 205 | |
| 206 function step2() | |
| 207 { | |
| 208 window.setBreakpointCallback = step3.bind(this); | |
| 209 } | |
| 210 | |
| 211 function step3() | |
| 212 { | |
| 213 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 214 InspectorTest.addResult("\n Toggling source mapping."); | |
| 215 mockTarget.debuggerModel.pushSourceMapping(shiftingMapping); | |
| 216 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 217 InspectorTest.addResult("\n Toggling source mapping back."); | |
| 218 mockTarget.debuggerModel.disableSourceMapping(shiftingMapping); | |
| 219 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 220 } | |
| 221 | |
| 222 }, | |
| 223 | |
| 224 function testProvisionalBreakpointsResolve(next) | 176 function testProvisionalBreakpointsResolve(next) |
| 225 { | 177 { |
| 226 var serializedBreakpoints = []; | 178 var serializedBreakpoints = []; |
| 227 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar" , true)); | 179 serializedBreakpoints.push(createBreakpoint("a.js", 10, "foo == bar" , true)); |
| 228 | 180 |
| 229 var breakpointManager = createBreakpointManager(serializedBreakpoint s); | 181 var breakpointManager = createBreakpointManager(serializedBreakpoint s); |
| 230 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); | 182 var uiSourceCode = addUISourceCode(breakpointManager, "a.js"); |
| 231 window.setBreakpointCallback = step2.bind(this); | 183 window.setBreakpointCallback = step2.bind(this); |
| 232 | 184 |
| 233 function step2() | 185 function step2() |
| 234 { | 186 { |
| 235 InspectorTest.dumpBreakpointLocations(breakpointManager); | 187 InspectorTest.dumpBreakpointLocations(breakpointManager); |
| 236 resetWorkspace(breakpointManager); | 188 resetWorkspace(breakpointManager); |
| 237 InspectorTest.addResult(" Resolving provisional breakpoint."); | 189 InspectorTest.addResult(" Resolving provisional breakpoint."); |
| 238 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | 190 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); |
| 239 mockTarget.debuggerModel._breakpointResolved("a.js:10", new SDK. DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 11, 0)); | 191 mockTarget.debuggerModel._breakpointResolved("a.js:10", new SDK. DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 11, 0)); |
| 240 var breakpoints = breakpointManager._allBreakpoints(); | 192 var breakpoints = breakpointManager._allBreakpoints(); |
| 241 InspectorTest.assertEquals(1, breakpoints.length, "Exactly one p rovisional breakpoint should be registered in breakpoint manager."); | 193 InspectorTest.assertEquals(1, breakpoints.length, "Exactly one p rovisional breakpoint should be registered in breakpoint manager."); |
| 242 InspectorTest.finishBreakpointTest(breakpointManager, next); | 194 InspectorTest.finishBreakpointTest(breakpointManager, next); |
| 243 } | 195 } |
| 244 }, | 196 }, |
| 245 | 197 |
| 246 function testSourceMappingReload(next) | |
|
dgozman
2017/06/08 19:12:00
Please ensure we have a test that breakpoints in h
lushnikov
2017/06/08 21:14:34
There's a test which covers both reload and source
| |
| 247 { | |
| 248 function createSourceMapping(uiSourceCodeA, uiSourceCodeB) | |
| 249 { | |
| 250 var mapping = { | |
| 251 rawLocationToUILocation: function(rawLocation) | |
| 252 { | |
| 253 if (this._disabled) | |
| 254 return null; | |
| 255 return uiSourceCodeB.uiLocation(rawLocation.lineNumber + 10, 0); | |
| 256 }, | |
| 257 | |
| 258 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | |
| 259 { | |
| 260 return new SDK.DebuggerModel.Location(mockTarget.debugge rModel, uiSourceCodeA.url(), lineNumber - 10, 0); | |
| 261 }, | |
| 262 | |
| 263 isIdentity: function() | |
| 264 { | |
| 265 return false; | |
| 266 } | |
| 267 }; | |
| 268 | |
| 269 return mapping; | |
| 270 } | |
| 271 // Source mapping will shift everything 10 lines ahead. | |
| 272 var serializedBreakpoints = [createBreakpoint("b.js", 20, "foo == ba r", true)]; | |
| 273 var breakpointManager = createBreakpointManager(serializedBreakpoint s); | |
| 274 InspectorTest.addResult("\n Adding files:"); | |
| 275 var uiSourceCodeA = addUISourceCode(breakpointManager, "a.js"); | |
| 276 var uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true); | |
| 277 | |
| 278 InspectorTest.addResult("\n Toggling source mapping."); | |
| 279 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceCodeB ); | |
| 280 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); | |
| 281 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(mockTar get.debuggerModel, uiSourceCodeB, sourceMapping); | |
| 282 InspectorTest.runAfterPendingBreakpointUpdates(breakpointManager, br eakpointActionsPerformedBeforeReload.bind(this)); | |
| 283 | |
| 284 function breakpointActionsPerformedBeforeReload() | |
| 285 { | |
| 286 InspectorTest.dumpBreakpointLocations(breakpointManager); | |
| 287 InspectorTest.addResult("\n Reloading:"); | |
| 288 resetWorkspace(breakpointManager); | |
| 289 | |
| 290 InspectorTest.addResult("\n Adding files:"); | |
| 291 InspectorTest.addScript(mockTarget, breakpointManager, "a.js"); | |
| 292 mockTarget.debuggerModel._breakpointResolved("a.js:10", new SDK. DebuggerModel.Location(mockTarget.debuggerModel, "a.js", 10, 0)); | |
| 293 uiSourceCodeA = addUISourceCode(breakpointManager, "a.js", false , true); | |
| 294 uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true); | |
| 295 | |
| 296 InspectorTest.addResult("\n Toggling source mapping."); | |
| 297 var sourceMapping = createSourceMapping(uiSourceCodeA, uiSourceC odeB); | |
| 298 mockTarget.debuggerModel.pushSourceMapping(sourceMapping); | |
| 299 breakpointManager._debuggerWorkspaceBinding.setSourceMapping(moc kTarget.debuggerModel, uiSourceCodeB, sourceMapping); | |
| 300 InspectorTest.runAfterPendingBreakpointUpdates(breakpointManager , breakpointActionsPerformed.bind(this)); | |
| 301 } | |
| 302 | |
| 303 function breakpointActionsPerformed() | |
| 304 { | |
| 305 InspectorTest.finishBreakpointTest(breakpointManager, next); | |
| 306 } | |
| 307 }, | |
| 308 | |
| 309 function testBreakpointInCollectedReload(next) | 198 function testBreakpointInCollectedReload(next) |
| 310 { | 199 { |
| 311 var breakpointManager = createBreakpointManager(); | 200 var breakpointManager = createBreakpointManager(); |
| 312 InspectorTest.addResult("\n Adding file without script:"); | 201 InspectorTest.addResult("\n Adding file without script:"); |
| 313 var uiSourceCode = addUISourceCode(breakpointManager, "a.js", true, true); | 202 var uiSourceCode = addUISourceCode(breakpointManager, "a.js", true, true); |
| 314 | 203 |
| 315 InspectorTest.addResult("\n Setting breakpoint:"); | 204 InspectorTest.addResult("\n Setting breakpoint:"); |
| 316 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 10, 0, "", true, step2); | 205 InspectorTest.setBreakpoint(breakpointManager, uiSourceCode, 10, 0, "", true, step2); |
| 317 | 206 |
| 318 function step2() | 207 function step2() |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 340 }; | 229 }; |
| 341 </script> | 230 </script> |
| 342 | 231 |
| 343 </head> | 232 </head> |
| 344 | 233 |
| 345 <body onload="runTest()"> | 234 <body onload="runTest()"> |
| 346 <p>Tests BreakpointManager class.</p> | 235 <p>Tests BreakpointManager class.</p> |
| 347 | 236 |
| 348 </body> | 237 </body> |
| 349 </html> | 238 </html> |
| OLD | NEW |