OLD | NEW |
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 | 5 |
6 <script> | 6 <script> |
7 function addStyleSheet() | 7 function addStyleSheet() |
8 { | 8 { |
9 var style = document.createElement("link"); | 9 var style = document.createElement("link"); |
10 style.setAttribute("rel", "stylesheet"); | 10 style.setAttribute("rel", "stylesheet"); |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 function cssUISourceCodeAdded(uiSourceCode) | 40 function cssUISourceCodeAdded(uiSourceCode) |
41 { | 41 { |
42 styleSheetId = cssModel.styleSheetIdsForURL(styleSheetURL)[0]; | 42 styleSheetId = cssModel.styleSheetIdsForURL(styleSheetURL)[0]; |
43 InspectorTest.addSniffer(Bindings.CSSWorkspaceBinding.ModelInfo.prototyp
e, "_updateLocations", locationsUpdated, true); | 43 InspectorTest.addSniffer(Bindings.CSSWorkspaceBinding.ModelInfo.prototyp
e, "_updateLocations", locationsUpdated, true); |
44 InspectorTest.addResult("Added CSS uiSourceCode: " + uiSourceCode.url())
; | 44 InspectorTest.addResult("Added CSS uiSourceCode: " + uiSourceCode.url())
; |
45 InspectorTest.waitForUISourceCode(sourceURL).then(scssUISourceCodeAdded)
; | 45 InspectorTest.waitForUISourceCode(sourceURL).then(scssUISourceCodeAdded)
; |
46 } | 46 } |
47 | 47 |
48 function rawLocationToUILocation(line, column) | 48 function testAndDumpLocation(uiSourceCode, expectedLine, expectedColumn, lin
e, column) { |
49 { | |
50 var header = cssModel.styleSheetHeaderForId(styleSheetId); | 49 var header = cssModel.styleSheetHeaderForId(styleSheetId); |
51 return Bindings.cssWorkspaceBinding.rawLocationToUILocation(new SDK.CSSL
ocation(header, line, column)); | 50 var uiLocation = Bindings.cssWorkspaceBinding.rawLocationToUILocation(ne
w SDK.CSSLocation(header, line, column)); |
| 51 InspectorTest.assertEquals(uiSourceCode, uiLocation.uiSourceCode, |
| 52 `Incorrect uiSourceCode, expected ${uiSourceCode.url()}, but got ${l
ocation.uiSourceCode ? location.uiSourceCode.url() : null}`); |
| 53 var reverseRaw = Bindings.cssWorkspaceBinding.uiLocationToRawLocations(u
iLocation)[0]; |
| 54 InspectorTest.addResult(`${line}:${column} ${uiLocation.lineNumber}:${ui
Location.columnNumber}` + |
| 55 `(expected: ${expectedLine}:${expectedColumn}) -> ${reverseRaw.line
Number}:${reverseRaw.columnNumber}`); |
52 } | 56 } |
53 | 57 |
54 function scssUISourceCodeAdded(uiSourceCode) | 58 function scssUISourceCodeAdded(uiSourceCode) |
55 { | 59 { |
56 InspectorTest.addResult("Added SCSS uiSourceCode: " + uiSourceCode.url()
); | 60 InspectorTest.addResult("Added SCSS uiSourceCode: " + uiSourceCode.url()
); |
57 var cssUISourceCode = Workspace.workspace.uiSourceCodeForURL(styleSheetU
RL); | 61 var cssUISourceCode = Workspace.workspace.uiSourceCodeForURL(styleSheetU
RL); |
58 var scssUISourceCode = Workspace.workspace.uiSourceCodeForURL(sourceURL)
; | 62 var scssUISourceCode = Workspace.workspace.uiSourceCodeForURL(sourceURL)
; |
59 | 63 |
60 InspectorTest.checkUILocation(cssUISourceCode, 0, 3, rawLocationToUILoca
tion(0, 3)); | 64 testAndDumpLocation(cssUISourceCode, 0, 3, 0, 3); |
61 InspectorTest.checkUILocation(scssUISourceCode, 1, 0, rawLocationToUILoc
ation(1, 0)); | 65 testAndDumpLocation(scssUISourceCode, 1, 0, 1, 0); |
62 InspectorTest.checkUILocation(scssUISourceCode, 2, 2, rawLocationToUILoc
ation(2, 4)); | 66 testAndDumpLocation(scssUISourceCode, 2, 2, 2, 4); |
63 InspectorTest.checkUILocation(scssUISourceCode, 2, 5, rawLocationToUILoc
ation(2, 6)); | 67 testAndDumpLocation(scssUISourceCode, 2, 5, 2, 6); |
64 InspectorTest.checkUILocation(scssUISourceCode, 2, 7, rawLocationToUILoc
ation(2, 9)); | 68 testAndDumpLocation(scssUISourceCode, 2, 7, 2, 9); |
65 InspectorTest.checkUILocation(scssUISourceCode, 2, 10, rawLocationToUILo
cation(3, 7)); | 69 testAndDumpLocation(scssUISourceCode, 2, 10, 3, 7); |
66 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc
ation(4, 8)); | 70 testAndDumpLocation(scssUISourceCode, 4, 2, 4, 8); |
67 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc
ation(4, 10)); | 71 testAndDumpLocation(scssUISourceCode, 4, 2, 4, 10); |
68 InspectorTest.checkUILocation(scssUISourceCode, 4, 11, rawLocationToUILo
cation(4, 11)); | 72 testAndDumpLocation(scssUISourceCode, 4, 11, 4, 11); |
69 InspectorTest.checkUILocation(scssUISourceCode, 4, 13, rawLocationToUILo
cation(4, 15)); | 73 testAndDumpLocation(scssUISourceCode, 4, 13, 4, 15); |
70 InspectorTest.checkUILocation(scssUISourceCode, 4, 17, rawLocationToUILo
cation(4, 20)); | 74 testAndDumpLocation(scssUISourceCode, 4, 17, 4, 20); |
71 scssUISourceCode.requestContent().then(didRequestContent); | 75 scssUISourceCode.requestContent().then(didRequestContent); |
72 | 76 |
73 function didRequestContent(content, contentEncoded, mimeType) | 77 function didRequestContent(content, contentEncoded, mimeType) |
74 { | 78 { |
75 InspectorTest.assertEquals(0, content.indexOf("/* Comment */")); | 79 InspectorTest.assertEquals(0, content.indexOf("/* Comment */")); |
76 contentReceived = true; | 80 contentReceived = true; |
77 join(); | 81 join(); |
78 } | 82 } |
79 } | 83 } |
80 | 84 |
81 function join() | 85 function join() |
82 { | 86 { |
83 if (!contentReceived || !finalMappedLocation) | 87 if (!contentReceived || !finalMappedLocation) |
84 return; | 88 return; |
85 InspectorTest.addResult("UILocation upon LiveLocation update: " + finalM
appedLocation); | 89 InspectorTest.addResult("UILocation upon LiveLocation update: " + finalM
appedLocation); |
86 InspectorTest.completeTest(); | 90 InspectorTest.completeTest(); |
87 } | 91 } |
88 } | 92 } |
89 | 93 |
90 </script> | 94 </script> |
91 | 95 |
92 </head> | 96 </head> |
93 | 97 |
94 <body onload="runTest()"> | 98 <body onload="runTest()"> |
95 <p>Tests SourceMap and StyleSheetMapping.</p> | 99 <p>Tests SourceMap and StyleSheetMapping.</p> |
96 </body> | 100 </body> |
97 </html> | 101 </html> |
OLD | NEW |