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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
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> 5 <script src="workspace-test.js"></script>
6 <script src="breakpoint-manager-test.js"></script> 6 <script src="breakpoint-manager-test.js"></script>
7 7
8 <script> 8 <script>
9 9
10 function test() 10 function test()
11 { 11 {
12 function createWorkspaceWithTarget(userCallback) 12 function createWorkspaceWithTarget(userCallback)
13 { 13 {
14 InspectorTest.createWorkspace(); 14 InspectorTest.createWorkspace();
15 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId+ +); 15 var target = InspectorTest.createMockTarget(InspectorTest._mockTargetId+ +);
16 InspectorTest.testWorkspace.addEventListener(WebInspector.Workspace.Even ts.UISourceCodeAdded, uiSourceCodeAdded); 16 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events. UISourceCodeAdded, uiSourceCodeAdded);
17 InspectorTest.testWorkspace.addEventListener(WebInspector.Workspace.Even ts.UISourceCodeRemoved, uiSourceCodeRemoved); 17 InspectorTest.testWorkspace.addEventListener(Workspace.Workspace.Events. UISourceCodeRemoved, uiSourceCodeRemoved);
18 userCallback(target); 18 userCallback(target);
19 } 19 }
20 20
21 function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, s ourceLineNumber, sourceColumnNumber, mapping) 21 function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, s ourceLineNumber, sourceColumnNumber, mapping)
22 { 22 {
23 var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber); 23 var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber);
24 InspectorTest.addResult(sourceURL + " === " + entry.sourceURL); 24 InspectorTest.addResult(sourceURL + " === " + entry.sourceURL);
25 InspectorTest.addResult(sourceLineNumber + " === " + entry.sourceLineNum ber); 25 InspectorTest.addResult(sourceLineNumber + " === " + entry.sourceLineNum ber);
26 InspectorTest.addResult(sourceColumnNumber + " === " + entry.sourceColum nNumber); 26 InspectorTest.addResult(sourceColumnNumber + " === " + entry.sourceColum nNumber);
27 } 27 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 example-compiled.js: 78 example-compiled.js:
79 0 1 2 3 79 0 1 2 3
80 012345678901234567890123456789012345 80 012345678901234567890123456789012345
81 function add(a,b){return a+b}var global="foo"; 81 function add(a,b){return a+b}var global="foo";
82 foo 82 foo
83 */ 83 */
84 var mappingPayload = { 84 var mappingPayload = {
85 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;A", 85 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;A",
86 "sources":["example.js"] 86 "sources":["example.js"]
87 }; 87 };
88 var mapping = new WebInspector.TextSourceMap("compiled.js", "source- map.json", mappingPayload); 88 var mapping = new SDK.TextSourceMap("compiled.js", "source-map.json" , mappingPayload);
89 89
90 checkMapping(0, 9, "example.js", 0, 9, mapping); 90 checkMapping(0, 9, "example.js", 0, 9, mapping);
91 checkMapping(0, 13, "example.js", 0, 13, mapping); 91 checkMapping(0, 13, "example.js", 0, 13, mapping);
92 checkMapping(0, 15, "example.js", 0, 25, mapping); 92 checkMapping(0, 15, "example.js", 0, 25, mapping);
93 checkMapping(0, 18, "example.js", 2, 4, mapping); 93 checkMapping(0, 18, "example.js", 2, 4, mapping);
94 checkMapping(0, 25, "example.js", 2, 11, mapping); 94 checkMapping(0, 25, "example.js", 2, 11, mapping);
95 checkMapping(0, 27, "example.js", 2, 24, mapping); 95 checkMapping(0, 27, "example.js", 2, 24, mapping);
96 checkMapping(1, 0, undefined, undefined, undefined, mapping); 96 checkMapping(1, 0, undefined, undefined, undefined, mapping);
97 97
98 checkReverseMapping(0, 0, "example.js", 0, mapping); 98 checkReverseMapping(0, 0, "example.js", 0, mapping);
99 checkReverseMapping(0, 17, "example.js", 1, mapping); 99 checkReverseMapping(0, 17, "example.js", 1, mapping);
100 checkReverseMapping(0, 18, "example.js", 2, mapping); 100 checkReverseMapping(0, 18, "example.js", 2, mapping);
101 checkReverseMapping(0, 29, "example.js", 4, mapping); 101 checkReverseMapping(0, 29, "example.js", 4, mapping);
102 checkReverseMapping(0, 29, "example.js", 5, mapping); 102 checkReverseMapping(0, 29, "example.js", 5, mapping);
103 103
104 next(); 104 next();
105 }, 105 },
106 106
107 function testNoMappingEntry(next) 107 function testNoMappingEntry(next)
108 { 108 {
109 var mappingPayload = { 109 var mappingPayload = {
110 "mappings":"AAAA,C,CAAE;", 110 "mappings":"AAAA,C,CAAE;",
111 "sources":["example.js"] 111 "sources":["example.js"]
112 }; 112 };
113 var mapping = new WebInspector.TextSourceMap("compiled.js", "source- map.json", mappingPayload); 113 var mapping = new SDK.TextSourceMap("compiled.js", "source-map.json" , mappingPayload);
114 checkMapping(0, 0, "example.js", 0, 0, mapping); 114 checkMapping(0, 0, "example.js", 0, 0, mapping);
115 var entry = mapping.findEntry(0, 1); 115 var entry = mapping.findEntry(0, 1);
116 InspectorTest.assertTrue(!entry.sourceURL); 116 InspectorTest.assertTrue(!entry.sourceURL);
117 checkMapping(0, 2, "example.js", 0, 2, mapping); 117 checkMapping(0, 2, "example.js", 0, 2, mapping);
118 next(); 118 next();
119 }, 119 },
120 120
121 function testEmptyLine(next) 121 function testEmptyLine(next)
122 { 122 {
123 var mappingPayload = { 123 var mappingPayload = {
124 "mappings":"AAAA;;;CACA", 124 "mappings":"AAAA;;;CACA",
125 "sources":["example.js"] 125 "sources":["example.js"]
126 }; 126 };
127 var mapping = new WebInspector.TextSourceMap("compiled.js", "source- map.json", mappingPayload); 127 var mapping = new SDK.TextSourceMap("compiled.js", "source-map.json" , mappingPayload);
128 checkMapping(0, 0, "example.js", 0, 0, mapping); 128 checkMapping(0, 0, "example.js", 0, 0, mapping);
129 checkReverseMapping(3, 1, "example.js", 1, mapping); 129 checkReverseMapping(3, 1, "example.js", 1, mapping);
130 next(); 130 next();
131 }, 131 },
132 132
133 function testSections(next) 133 function testSections(next)
134 { 134 {
135 var mappingPayload = { 135 var mappingPayload = {
136 "sections": [{ 136 "sections": [{
137 "offset": { "line": 0, "column": 0 }, 137 "offset": { "line": 0, "column": 0 },
138 "map": { 138 "map": {
139 "mappings":"AAAA,CAEC", 139 "mappings":"AAAA,CAEC",
140 "sources":["source1.js", "source2.js"] 140 "sources":["source1.js", "source2.js"]
141 } 141 }
142 }, { 142 }, {
143 "offset": { "line": 2, "column": 10 }, 143 "offset": { "line": 2, "column": 10 },
144 "map": { 144 "map": {
145 "mappings":"AAAA,CAEC", 145 "mappings":"AAAA,CAEC",
146 "sources":["source2.js"] 146 "sources":["source2.js"]
147 } 147 }
148 } 148 }
149 ]}; 149 ]};
150 var mapping = new WebInspector.TextSourceMap("compiled.js", "source- map.json", mappingPayload); 150 var mapping = new SDK.TextSourceMap("compiled.js", "source-map.json" , mappingPayload);
151 InspectorTest.assertEquals(2, mapping.sourceURLs().length); 151 InspectorTest.assertEquals(2, mapping.sourceURLs().length);
152 checkMapping(0, 0, "source1.js", 0, 0, mapping); 152 checkMapping(0, 0, "source1.js", 0, 0, mapping);
153 checkMapping(0, 1, "source1.js", 2, 1, mapping); 153 checkMapping(0, 1, "source1.js", 2, 1, mapping);
154 checkMapping(2, 10, "source2.js", 0, 0, mapping); 154 checkMapping(2, 10, "source2.js", 0, 0, mapping);
155 checkMapping(2, 11, "source2.js", 2, 1, mapping); 155 checkMapping(2, 11, "source2.js", 2, 1, mapping);
156 next(); 156 next();
157 }, 157 },
158 158
159 function testResolveSourceMapURL(next) 159 function testResolveSourceMapURL(next)
160 { 160 {
161 var func = WebInspector.ParsedURL.completeURL; 161 var func = Common.ParsedURL.completeURL;
162 InspectorTest.addResult("http://example.com/map.json === " + func("h ttp://example.com/script.js", "http://example.com/map.json")); 162 InspectorTest.addResult("http://example.com/map.json === " + func("h ttp://example.com/script.js", "http://example.com/map.json"));
163 InspectorTest.addResult("http://example.com/map.json === " + func("h ttp://example.com/script.js", "/map.json")); 163 InspectorTest.addResult("http://example.com/map.json === " + func("h ttp://example.com/script.js", "/map.json"));
164 InspectorTest.addResult("http://example.com/maps/map.json === " + fu nc("http://example.com/scripts/script.js", "../maps/map.json")); 164 InspectorTest.addResult("http://example.com/maps/map.json === " + fu nc("http://example.com/scripts/script.js", "../maps/map.json"));
165 function testCompleteURL(base, lhs, rhs) 165 function testCompleteURL(base, lhs, rhs)
166 { 166 {
167 var actual = WebInspector.ParsedURL.completeURL(base, lhs); 167 var actual = Common.ParsedURL.completeURL(base, lhs);
168 InspectorTest.addResult(lhs + " resolves to " + actual + "===" + rhs + " passes: " + (actual === rhs)); 168 InspectorTest.addResult(lhs + " resolves to " + actual + "===" + rhs + " passes: " + (actual === rhs));
169 } 169 }
170 170
171 var rfc3986_5_4_baseURL = "http://a/b/c/d;p?q"; 171 var rfc3986_5_4_baseURL = "http://a/b/c/d;p?q";
172 InspectorTest.addResult("Tests from http://tools.ietf.org/html/rfc39 86#section-5.4 using baseURL=\"" + rfc3986_5_4_baseURL + "\""); 172 InspectorTest.addResult("Tests from http://tools.ietf.org/html/rfc39 86#section-5.4 using baseURL=\"" + rfc3986_5_4_baseURL + "\"");
173 var rfc3986_5_4 = testCompleteURL.bind(null, rfc3986_5_4_baseURL); 173 var rfc3986_5_4 = testCompleteURL.bind(null, rfc3986_5_4_baseURL);
174 rfc3986_5_4("http://h", "http://h"); // modified from RFC3986 174 rfc3986_5_4("http://h", "http://h"); // modified from RFC3986
175 rfc3986_5_4("g", "http://a/b/c/g"); 175 rfc3986_5_4("g", "http://a/b/c/g");
176 rfc3986_5_4("./g", "http://a/b/c/g"); 176 rfc3986_5_4("./g", "http://a/b/c/g");
177 rfc3986_5_4("g/", "http://a/b/c/g/"); 177 rfc3986_5_4("g/", "http://a/b/c/g/");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUIS ourceCodeAdded); 233 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUIS ourceCodeAdded);
234 script = InspectorTest.createScriptMock("compiled.js", 0, 0, tru e, "", target, function(script) { 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"; 235 script.sourceMapURL = "http://localhost:8000/inspector/resou rces/source-map.json";
236 }); 236 });
237 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script }); 237 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
238 } 238 }
239 239
240 function originalUISourceCodeAdded(uiSourceCode) 240 function originalUISourceCodeAdded(uiSourceCode)
241 { 241 {
242 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded); 242 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded);
243 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", WebI nspector.resourceTypes.Script, ""); 243 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", Comm on.resourceTypes.Script, "");
244 } 244 }
245 245
246 function originalResourceUISourceCodeAdded(uiSourceCode) 246 function originalResourceUISourceCodeAdded(uiSourceCode)
247 { 247 {
248 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(stubUISourc eCodeAdded, 1, WebInspector.projectTypes.Service); 248 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(stubUISourc eCodeAdded, 1, Workspace.projectTypes.Service);
249 originalUISourceCode = uiSourceCode; 249 originalUISourceCode = uiSourceCode;
250 } 250 }
251 251
252 function stubUISourceCodeAdded(uiSourceCode) 252 function stubUISourceCodeAdded(uiSourceCode)
253 { 253 {
254 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded); 254 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded);
255 } 255 }
256 256
257 function firstUISourceCodeAdded(uiSourceCode) 257 function firstUISourceCodeAdded(uiSourceCode)
258 { 258 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 function workspaceCreated(newTarget) 305 function workspaceCreated(newTarget)
306 { 306 {
307 target = newTarget; 307 target = newTarget;
308 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { }); 308 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { });
309 script = InspectorTest.createScriptMock("compiled.js", 0, 0, tru e, "", target, function(script) { 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"; 310 script.sourceMapURL = "http://localhost:8000/inspector/resou rces/source-map.json";
311 }); 311 });
312 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script }); 312 InspectorTest.testDebuggerWorkspaceBinding._targetToData.get(tar get)._parsedScriptSource({ data: script });
313 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded); 313 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalRes ourceUISourceCodeAdded);
314 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", WebI nspector.resourceTypes.Script, ""); 314 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", Comm on.resourceTypes.Script, "");
315 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded); 315 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISour ceCodeAdded);
316 } 316 }
317 317
318 function originalResourceUISourceCodeAdded(uiSourceCode) 318 function originalResourceUISourceCodeAdded(uiSourceCode)
319 { 319 {
320 originalUISourceCode = uiSourceCode; 320 originalUISourceCode = uiSourceCode;
321 } 321 }
322 322
323 function firstUISourceCodeAdded(uiSourceCode) 323 function firstUISourceCodeAdded(uiSourceCode)
324 { 324 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 example-compiled.js: 438 example-compiled.js:
439 0 1 2 3 439 0 1 2 3
440 012345678901234567890123456789012345 440 012345678901234567890123456789012345
441 function add(a,b){return a+b}var global="foo"; 441 function add(a,b){return a+b}var global="foo";
442 */ 442 */
443 var mappingPayload = { 443 var mappingPayload = {
444 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;", 444 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
445 "sources":["example.js"], 445 "sources":["example.js"],
446 "sourceRoot":"/" 446 "sourceRoot":"/"
447 }; 447 };
448 var mapping = new WebInspector.TextSourceMap("compiled.js", "source- map.json", mappingPayload); 448 var mapping = new SDK.TextSourceMap("compiled.js", "source-map.json" , mappingPayload);
449 checkMapping(0, 9, "/example.js", 0, 9, mapping); 449 checkMapping(0, 9, "/example.js", 0, 9, mapping);
450 checkReverseMapping(0, 0, "/example.js", 0, mapping); 450 checkReverseMapping(0, 0, "/example.js", 0, mapping);
451 next(); 451 next();
452 }, 452 },
453 453
454 function testNameClash(next) 454 function testNameClash(next)
455 { 455 {
456 var mappingPayload = { 456 var mappingPayload = {
457 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;", 457 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAA OD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
458 "sources":["example.js"], 458 "sources":["example.js"],
459 "sourcesContent":["var i = 0;"] 459 "sourcesContent":["var i = 0;"]
460 }; 460 };
461 var mapping = new WebInspector.TextSourceMap("example.js", "source-m ap.json",mappingPayload); 461 var mapping = new SDK.TextSourceMap("example.js", "source-map.json", mappingPayload);
462 checkMapping(0, 9, "example.js", 0, 9, mapping); 462 checkMapping(0, 9, "example.js", 0, 9, mapping);
463 checkReverseMapping(0, 0, "example.js", 0, mapping); 463 checkReverseMapping(0, 0, "example.js", 0, mapping);
464 next(); 464 next();
465 }, 465 },
466 466
467 function testNameIndexes(next) 467 function testNameIndexes(next)
468 { 468 {
469 /* 469 /*
470 ----------------------------------------------------------------- ------------------- 470 ----------------------------------------------------------------- -------------------
471 chrome_issue_611738.clj: 471 chrome_issue_611738.clj:
(...skipping 21 matching lines...) Expand all
493 chrome_issue_611738.js.map: 493 chrome_issue_611738.js.map:
494 {"version":3,"file":"\/Users\/darwin\/code\/cljs-devtools-sample\ /resources\/public\/_compiled\/demo\/devtools_sample\/chrome_issue_611738.js","s ources":["chrome_issue_611738.cljs"],"lineCount":7,"mappings":";AAAA;;AAGA,kBAAA ,dAAMA;AAAN,AACE,IAAAC,uBAAA;AAAA,AAAA","names":["name1","generated31465"]} 494 {"version":3,"file":"\/Users\/darwin\/code\/cljs-devtools-sample\ /resources\/public\/_compiled\/demo\/devtools_sample\/chrome_issue_611738.js","s ources":["chrome_issue_611738.cljs"],"lineCount":7,"mappings":";AAAA;;AAGA,kBAAA ,dAAMA;AAAN,AACE,IAAAC,uBAAA;AAAA,AAAA","names":["name1","generated31465"]}
495 ----------------------------------------------------------------- ------------------- 495 ----------------------------------------------------------------- -------------------
496 */ 496 */
497 497
498 var mappingPayload = { 498 var mappingPayload = {
499 "sources": ["chrome_issue_611738.cljs"], 499 "sources": ["chrome_issue_611738.cljs"],
500 "mappings": ";AAAA;;AAGA,kBAAA,dAAMA;AAAN,AACE,IAAAC,uBAAA;AAAA, AAAA", 500 "mappings": ";AAAA;;AAGA,kBAAA,dAAMA;AAAN,AACE,IAAAC,uBAAA;AAAA, AAAA",
501 "names": ["name1", "generated31465"] 501 "names": ["name1", "generated31465"]
502 }; 502 };
503 var mapping = new WebInspector.TextSourceMap("chrome_issue_611738.js ", "chrome_issue_611738.js.map", mappingPayload); 503 var mapping = new SDK.TextSourceMap("chrome_issue_611738.js", "chrom e_issue_611738.js.map", mappingPayload);
504 mapping.mappings().forEach(function(entry) { 504 mapping.mappings().forEach(function(entry) {
505 const name = entry.name ? "'" + entry.name + "'" : "[no name ass igned]"; 505 const name = entry.name ? "'" + entry.name + "'" : "[no name ass igned]";
506 InspectorTest.addResult(entry.lineNumber + ":" + entry.columnNum ber + " > " + name); 506 InspectorTest.addResult(entry.lineNumber + ":" + entry.columnNum ber + " > " + name);
507 }); 507 });
508 next(); 508 next();
509 } 509 }
510 ]); 510 ]);
511 }; 511 };
512 512
513 </script> 513 </script>
514 514
515 </head> 515 </head>
516 516
517 <body onload="runTest()"> 517 <body onload="runTest()">
518 <p>Tests SourceMap and CompilerScriptMapping.</p> 518 <p>Tests SourceMap and CompilerScriptMapping.</p>
519 </body> 519 </body>
520 </html> 520 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698