Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/compiler-script-mapping.html

Issue 2536733004: [DevTools] Remove workspace-test.js part4. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="inspector-test.js"></script> 3 <script src="inspector-test.js"></script>
4 <script src="debugger-test.js"></script> 4 <script src="debugger-test.js"></script>
5 <script src="workspace-test.js"></script>
6 <script src="breakpoint-manager-test.js"></script>
7 5
8 <script> 6 <script>
9 7
8 function addScript(url)
9 {
10 var script = document.createElement("script");
11 script.setAttribute("src", url);
12 document.head.appendChild(script);
13 }
14
10 function test() 15 function test()
11 { 16 {
12 function createWorkspaceWithTarget(userCallback)
13 {
14 InspectorTest.createWorkspace();
15 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId+ +);
16 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events. UISourceCodeAdded, uiSourceCodeAdded);
17 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events. UISourceCodeRemoved, uiSourceCodeRemoved);
18 userCallback(target);
19 }
20
21 function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, s ourceLineNumber, sourceColumnNumber, mapping) 17 function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, s ourceLineNumber, sourceColumnNumber, mapping)
22 { 18 {
23 var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber); 19 var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber);
24 InspectorTest.addResult(sourceURL + " === " + entry.sourceURL); 20 InspectorTest.addResult(sourceURL + " === " + entry.sourceURL);
25 InspectorTest.addResult(sourceLineNumber + " === " + entry.sourceLineNum ber); 21 InspectorTest.addResult(sourceLineNumber + " === " + entry.sourceLineNum ber);
26 InspectorTest.addResult(sourceColumnNumber + " === " + entry.sourceColum nNumber); 22 InspectorTest.addResult(sourceColumnNumber + " === " + entry.sourceColum nNumber);
27 } 23 }
28 24
29 function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourc eURL, sourceLineNumber, mapping) 25 function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourc eURL, sourceLineNumber, mapping)
30 { 26 {
31 var entry = mapping.firstSourceLineMapping(sourceURL, sourceLineNumber); 27 var entry = mapping.firstSourceLineMapping(sourceURL, sourceLineNumber);
32 if (!entry) { 28 if (!entry) {
33 InspectorTest.addResult("source line " + sourceLineNumber + " has no mappings."); 29 InspectorTest.addResult("source line " + sourceLineNumber + " has no mappings.");
34 return; 30 return;
35 } 31 }
36 InspectorTest.addResult(compiledLineNumber + " === " + entry.lineNumber) ; 32 InspectorTest.addResult(compiledLineNumber + " === " + entry.lineNumber) ;
37 InspectorTest.addResult(compiledColumnNumber + " === " + entry.columnNum ber); 33 InspectorTest.addResult(compiledColumnNumber + " === " + entry.columnNum ber);
38 } 34 }
39 35
40 function uiLocation(script, line, column) 36 function uiLocation(script, line, column)
41 { 37 {
42 var location = script.target().debuggerModel.createRawLocation(script, l ine, column); 38 var location = SDK.DebuggerModel.fromTarget(script.target()).createRawLo cation(script, line, column);
43 return InspectorTest.testDebuggerWorkspaceBinding.rawLocationToUILocatio n(location); 39 return Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(locatio n);
44 }
45
46 function resetModels()
47 {
48 target.debuggerModel._reset();
49 InspectorTest.testDebuggerWorkspaceBinding._reset(target);
50 }
51
52 function uiSourceCodeAdded(event)
53 {
54 var uiSourceCode = event.data;
55 InspectorTest.addResult("UISourceCodeAdded: [" + uiSourceCode.project(). type() + "] " + uiSourceCode.url());
56 }
57
58 function uiSourceCodeRemoved(event)
59 {
60 var uiSourceCode = event.data;
61 InspectorTest.addResult("UISourceCodeRemoved: [" + uiSourceCode.project( ).type() + "] " + uiSourceCode.url());
62 } 40 }
63 41
64 InspectorTest.runTestSuite([ 42 InspectorTest.runTestSuite([
65 function testSimpleMap(next) 43 function testSimpleMap(next)
66 { 44 {
67 /* 45 /*
68 example.js: 46 example.js:
69 0 1 2 3 47 0 1 2 3
70 012345678901234567890123456789012345 48 012345678901234567890123456789012345
71 function add(variable_x, variable_y) 49 function add(variable_x, variable_y)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 testCompleteURL("http://a/b/c/d;p?q", "//secure.com/moo", "http://se cure.com/moo"); 195 testCompleteURL("http://a/b/c/d;p?q", "//secure.com/moo", "http://se cure.com/moo");
218 testCompleteURL("http://a/b/c/d;p?q", "cat.jpeg", "http://a/b/c/cat. jpeg"); 196 testCompleteURL("http://a/b/c/d;p?q", "cat.jpeg", "http://a/b/c/cat. jpeg");
219 testCompleteURL("http://example.com/path.css?query#fragment","", "ht tp://example.com/path.css?query"); 197 testCompleteURL("http://example.com/path.css?query#fragment","", "ht tp://example.com/path.css?query");
220 next(); 198 next();
221 }, 199 },
222 200
223 function testCompilerScriptMapping(next) 201 function testCompilerScriptMapping(next)
224 { 202 {
225 var script; 203 var script;
226 var originalUISourceCode; 204 var originalUISourceCode;
227 var target; 205 var target = InspectorTest.mainTarget;
228 createWorkspaceWithTarget(step1);
229 206
230 function step1(newTarget) 207 InspectorTest.addResult("Adding compiled.js");
231 { 208 InspectorTest.waitForUISourceCode(originalUISourceCodeAdded, "resour ces/compiled.js");
232 target = newTarget; 209 InspectorTest.evaluateInPage("addScript('resources/compiled.js')");
233 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUIS ourceCodeAdded);
234 script = InspectorTest.createScriptMock("compiled.js", 0, 0, tru e, "", target, function(script) {
235 script.sourceMapURL = "http://localhost:8000/inspector/resou rces/source-map.json";
236 });
237 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
238 }
239 210
240 function originalUISourceCodeAdded(uiSourceCode) 211 function originalUISourceCodeAdded(uiSourceCode)
241 { 212 {
242 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded); 213 InspectorTest.addResult("compiled.js UISourceCode arrived");
243 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", Comm on.resourceTypes.Script, "");
244 }
245
246 function originalResourceUISourceCodeAdded(uiSourceCode)
247 {
248 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(stubUISourc eCodeAdded, 1, Workspace.projectTypes.Service);
249 originalUISourceCode = uiSourceCode; 214 originalUISourceCode = uiSourceCode;
250 } 215 for (var s of Object.values(InspectorTest.debuggerModel.scripts) ) {
251 216 if (s.sourceURL.endsWith("compiled.js")) {
252 function stubUISourceCodeAdded(uiSourceCode) 217 InspectorTest.addResult("compiled.js script found");
253 { 218 script = s;
254 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded); 219 }
220 }
221 InspectorTest.waitForUISourceCode(firstUISourceCodeAdded, "sourc e1.js");
255 } 222 }
256 223
257 function firstUISourceCodeAdded(uiSourceCode) 224 function firstUISourceCodeAdded(uiSourceCode)
258 { 225 {
259 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(secondUISou rceCodeAdded); 226 InspectorTest.addResult("source1.js UISourceCode arrived");
227 InspectorTest.waitForUISourceCode(secondUISourceCodeAdded, "sour ce2.js");
260 } 228 }
261 229
262 function secondUISourceCodeAdded(uiSourceCode) 230 function secondUISourceCodeAdded(uiSourceCode)
263 { 231 {
264 afterScriptAdded(); 232 InspectorTest.addResult("source2.js UISourceCode arrived");
265 } 233 var uiSourceCode1 = Workspace.workspace.uiSourceCodeForURL("http ://127.0.0.1:8000/inspector/resources/source1.js");
266 234 var uiSourceCode2 = Workspace.workspace.uiSourceCodeForURL("http ://127.0.0.1:8000/inspector/resources/source2.js");
267 function afterScriptAdded()
268 {
269 InspectorTest.addResult("afterScriptAdded");
270 var uiSourceCode1 = InspectorTest.testWorkspace.uiSourceCodeForU RL("http://localhost:8000/inspector/resources/source1.js");
271 var uiSourceCode2 = InspectorTest.testWorkspace.uiSourceCodeForU RL("http://localhost:8000/inspector/resources/source2.js");
272 235
273 InspectorTest.checkUILocation(uiSourceCode1, 4, 4, uiLocation(sc ript, 0, 81)); 236 InspectorTest.checkUILocation(uiSourceCode1, 4, 4, uiLocation(sc ript, 0, 81));
274 InspectorTest.checkUILocation(uiSourceCode1, 5, 4, uiLocation(sc ript, 0, 93)); 237 InspectorTest.checkUILocation(uiSourceCode1, 5, 4, uiLocation(sc ript, 0, 93));
275 InspectorTest.checkUILocation(uiSourceCode2, 7, 4, uiLocation(sc ript, 1, 151)); 238 InspectorTest.checkUILocation(uiSourceCode2, 7, 4, uiLocation(sc ript, 1, 151));
276 InspectorTest.checkUILocation(originalUISourceCode, 1, 200, uiLo cation(script, 1, 200)); 239 InspectorTest.checkUILocation(originalUISourceCode, 1, 200, uiLo cation(script, 1, 200));
277 240
278 InspectorTest.checkRawLocation(script, 0, 42, InspectorTest.test DebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode1, 3, 10)); 241 InspectorTest.checkRawLocation(script, 0, 42, Bindings.debuggerW orkspaceBinding.uiLocationToRawLocation(target, uiSourceCode1, 3, 10));
279 InspectorTest.checkRawLocation(script, 1, 85, InspectorTest.test DebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 1, 0)); 242 InspectorTest.checkRawLocation(script, 1, 85, Bindings.debuggerW orkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 1, 0));
280 InspectorTest.checkRawLocation(script, 1, 110, InspectorTest.tes tDebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 5, 2)); 243 InspectorTest.checkRawLocation(script, 1, 110, Bindings.debugger WorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 5, 2));
281 244
245 InspectorTest.addResult("Location checks passed. Requesting cont ent");
282 uiSourceCode1.requestContent().then(didRequestContent1); 246 uiSourceCode1.requestContent().then(didRequestContent1);
283 247
284 function didRequestContent1(content, contentEncoded, mimeType) 248 function didRequestContent1(content, contentEncoded, mimeType)
285 { 249 {
250 InspectorTest.addResult("Content1 arrived.");
286 InspectorTest.assertEquals(0, content.indexOf("window.addEve ntListener")); 251 InspectorTest.assertEquals(0, content.indexOf("window.addEve ntListener"));
287 uiSourceCode2.requestContent().then(didRequestContent2); 252 uiSourceCode2.requestContent().then(didRequestContent2);
288 } 253 }
289 254
290 function didRequestContent2(content, contentEncoded, mimeType) 255 function didRequestContent2(content, contentEncoded, mimeType)
291 { 256 {
292 InspectorTest.assertEquals(0, content.indexOf("function Clic kHandler()")); 257 InspectorTest.addResult("Content2 arrived.");
293 next();
294 }
295 }
296 },
297
298 function testCompilerScriptMappingWhenResourceWasLoadedAfterSource(next)
299 {
300 var script;
301 var originalUISourceCode;
302 var target;
303 createWorkspaceWithTarget(workspaceCreated);
304
305 function workspaceCreated(newTarget)
306 {
307 target = newTarget;
308 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { });
309 script = InspectorTest.createScriptMock("compiled.js", 0, 0, tru e, "", target, function(script) {
310 script.sourceMapURL = "http://localhost:8000/inspector/resou rces/source-map.json";
311 });
312 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
313 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded);
314 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", Comm on.resourceTypes.Script, "");
315 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded);
316 }
317
318 function originalResourceUISourceCodeAdded(uiSourceCode)
319 {
320 originalUISourceCode = uiSourceCode;
321 }
322
323 function firstUISourceCodeAdded(uiSourceCode)
324 {
325 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(afterScript Added);
326 }
327
328 function afterScriptAdded(uiSourceCode)
329 {
330 var uiSourceCode1 = InspectorTest.testWorkspace.uiSourceCodeForU RL("http://localhost:8000/inspector/resources/source1.js");
331 var uiSourceCode2 = InspectorTest.testWorkspace.uiSourceCodeForU RL("http://localhost:8000/inspector/resources/source2.js");
332
333 InspectorTest.checkUILocation(uiSourceCode1, 4, 4, uiLocation(sc ript, 0, 81));
334 InspectorTest.checkUILocation(uiSourceCode1, 5, 4, uiLocation(sc ript, 0, 93));
335 InspectorTest.checkUILocation(uiSourceCode2, 7, 4, uiLocation(sc ript, 1, 151));
336 InspectorTest.checkUILocation(originalUISourceCode, 1, 200, uiLo cation(script, 1, 200));
337
338 InspectorTest.checkRawLocation(script, 0, 42, InspectorTest.test DebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode1, 3, 10));
339 InspectorTest.checkRawLocation(script, 1, 85, InspectorTest.test DebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 1, 0));
340 InspectorTest.checkRawLocation(script, 1, 110, InspectorTest.tes tDebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode2, 5, 2));
341
342 uiSourceCode1.requestContent().then(didRequestContent1);
343
344 function didRequestContent1(content, contentEncoded, mimeType)
345 {
346 InspectorTest.assertEquals(0, content.indexOf("window.addEve ntListener"));
347 uiSourceCode2.requestContent().then(didRequestContent2);
348 }
349
350 function didRequestContent2(content, contentEncoded, mimeType)
351 {
352 InspectorTest.assertEquals(0, content.indexOf("function Clic kHandler()")); 258 InspectorTest.assertEquals(0, content.indexOf("function Clic kHandler()"));
353 next(); 259 next();
354 } 260 }
355 } 261 }
356 }, 262 },
357 263
358 function testInlinedSourceMap(next) 264 function testInlinedSourceMap(next)
359 { 265 {
360 var target; 266 var sourceMap = {
267 "file":"compiled.js",
268 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
269 "sources":["source3.js"],
270 "sourcesContent":["<source content>"]
271 };
272 var sourceMapURL = "data:application/json;base64," + btoa(JSON.strin gify(sourceMap));
273 var scriptSource = "\n//# sourceMappingURL=" + sourceMapURL + "\n";
274
275 InspectorTest.addResult("Adding compiled.js");
276 InspectorTest.waitForUISourceCode(compiledUISourceCodeAdded);
277 InspectorTest.evaluateInPage(scriptSource);
278
279 var target = InspectorTest.mainTarget;
361 var script; 280 var script;
362 createWorkspaceWithTarget(workspaceCreated);
363
364 function workspaceCreated(newTarget) {
365 target = newTarget;
366 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(compiledUIS ourceCodeAdded);
367 script = InspectorTest.createScriptMock("http://example.com/com piled.js", 0, 0, true, "", target, function(script) {
368 var sourceMap = {
369 "file":"compiled.js",
370 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ, CACI,MAAOD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
371 "sources":["source.js"],
372 "sourcesContent":["<source content>"]
373 };
374 script.sourceMapURL = "data:application/json;base64," + btoa (JSON.stringify(sourceMap));
375 });
376 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
377 }
378 281
379 function compiledUISourceCodeAdded(uiSourceCode) 282 function compiledUISourceCodeAdded(uiSourceCode)
380 { 283 {
381 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUIS ourceCodeAdded); 284 InspectorTest.addResult("compiled.js UISourceCode arrived");
285 for (var s of Object.values(InspectorTest.debuggerModel.scripts) ) {
286 if (s.sourceMapURL && s.sourceMapURL.startsWith("data:applic ation")) {
287 InspectorTest.addResult("compiled.js script found");
288 script = s;
289 }
290 }
291 InspectorTest.waitForUISourceCode(originalUISourceCodeAdded, "so urce3.js");
382 } 292 }
383 293
384 function originalUISourceCodeAdded(uiSourceCode) 294 function originalUISourceCodeAdded(uiSourceCode)
385 { 295 {
386 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCodeForUR L("http://example.com/source.js"); 296 InspectorTest.addResult("source3.js UISourceCode arrived");
297 InspectorTest.checkUILocation(uiSourceCode, 2, 4, uiLocation(scr ipt, 0, 18));
298 InspectorTest.checkRawLocation(script, 0, 18, Bindings.debuggerW orkspaceBinding.uiLocationToRawLocation(target, uiSourceCode, 2, 4));
387 299
388 InspectorTest.checkUILocation(uiSourceCode, 2, 4, uiLocation(scr ipt, 0, 18)); 300 InspectorTest.addResult("Location checks passed. Requesting cont ent");
389 InspectorTest.checkRawLocation(script, 0, 18, InspectorTest.test DebuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode, 2, 4));
390
391 uiSourceCode.requestContent().then(didRequestContent); 301 uiSourceCode.requestContent().then(didRequestContent);
392 302
393 function didRequestContent(content, contentEncoded, mimeType) 303 function didRequestContent(content, contentEncoded, mimeType)
394 { 304 {
395 InspectorTest.addResult("<source content> === " + content); 305 InspectorTest.addResult("<source content> === " + content);
396 next(); 306 next();
397 } 307 }
398 } 308 }
399 }, 309 },
400 310
401 function testSourceMapCouldNotBeLoaded(next) 311 function testSourceMapCouldNotBeLoaded(next)
402 { 312 {
403 createWorkspaceWithTarget(workspaceCreated); 313 InspectorTest.addResult("Adding compiled.js");
404 function workspaceCreated(target) 314 InspectorTest.waitForUISourceCode(compiledUISourceCodeAdded);
315 InspectorTest.evaluateInPage("\n//# sourceMappingURL=http://127.0.0. 1:8000/inspector/resources/source-map.json_\n");
316
317 var script;
318 var consoleError = console.error;
319 console.error = function() {}; // Error message is platform dependen t.
320
321 function compiledUISourceCodeAdded(uiSourceCode)
405 { 322 {
406 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(compiledUIS ourceCodeAdded); 323 InspectorTest.addResult("compiled.js UISourceCode arrived");
407 var script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "", target); 324 for (var s of Object.values(InspectorTest.debuggerModel.scripts) ) {
325 if (s.sourceMapURL === "http://127.0.0.1:8000/inspector/reso urces/source-map.json_") {
326 InspectorTest.addResult("compiled.js script found");
327 script = s;
328 }
329 }
330 InspectorTest.waitForUISourceCode(sourceMapUISourceCodeAdded, un defined, Workspace.projectTypes.Service);
331 }
408 332
409 function compiledUISourceCodeAdded(uiSourceCode) 333 function sourceMapUISourceCodeAdded()
410 { 334 {
411 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(origina lUISourceCodeAdded); 335 InspectorTest.addResult("source-map.json_ UISourceCode arrived") ;
412 }
413
414 function originalUISourceCodeAdded(uiSourceCode) { }
415
416 script.sourceMapURL = "http://localhost:8000/inspector/resources /source-map.json_";
417 console.error = function() {}; // Error message is platform depe ndent.
418 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
419 var location = uiLocation(script, 0, 0); 336 var location = uiLocation(script, 0, 0);
420 InspectorTest.addResult(location.uiSourceCode.url()); 337 InspectorTest.addResult(location.uiSourceCode.url().replace(/VM\ d+/g, "VM"));
338 console.error = consoleError;
421 next(); 339 next();
422 } 340 }
423 }, 341 },
424 342
425 function testSourceRoot(next) 343 function testSourceRoot(next)
426 { 344 {
427 /* 345 /*
428 example.js: 346 example.js:
429 0 1 2 3 347 0 1 2 3
430 012345678901234567890123456789012345 348 012345678901234567890123456789012345
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 }; 429 };
512 430
513 </script> 431 </script>
514 432
515 </head> 433 </head>
516 434
517 <body onload="runTest()"> 435 <body onload="runTest()">
518 <p>Tests SourceMap and CompilerScriptMapping.</p> 436 <p>Tests SourceMap and CompilerScriptMapping.</p>
519 </body> 437 </body>
520 </html> 438 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698