| 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 <script src="workspace-test.js"></script> | 5 <script src="workspace-test.js"></script> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 function test() | 9 function test() |
| 10 { | 10 { |
| 11 var contentReceived; | 11 var contentReceived; |
| 12 var finalMappedLocation; | 12 var finalMappedLocation; |
| 13 InspectorTest.createWorkspace(); | 13 InspectorTest.createWorkspace(); |
| 14 var cssModel = new WebInspector.CSSStyleModel(WebInspector.targetManager.act
iveTarget(), InspectorTest.testWorkspace); | 14 var cssModel = new WebInspector.CSSStyleModel(WebInspector.targetManager.mai
nTarget(), InspectorTest.testWorkspace); |
| 15 WebInspector.targetManager.activeTarget().cssModel = cssModel; | 15 WebInspector.targetManager.mainTarget().cssModel = cssModel; |
| 16 var mapping = new WebInspector.CSSStyleSheetMapping(cssModel, InspectorTest.
testWorkspace, InspectorTest.testNetworkWorkspaceBinding); | 16 var mapping = new WebInspector.CSSStyleSheetMapping(cssModel, InspectorTest.
testWorkspace, InspectorTest.testNetworkWorkspaceBinding); |
| 17 | 17 |
| 18 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(cssUISourceCodeAdded); | 18 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(cssUISourceCodeAdded); |
| 19 const styleSheetURL = "http://localhost:8000/inspector/resources/example.css
"; | 19 const styleSheetURL = "http://localhost:8000/inspector/resources/example.css
"; |
| 20 const sourceMapURL = "example.css.map"; | 20 const sourceMapURL = "example.css.map"; |
| 21 InspectorTest.addMockUISourceCodeToWorkspace(styleSheetURL, WebInspector.res
ourceTypes.Stylesheet, ""); | 21 InspectorTest.addMockUISourceCodeToWorkspace(styleSheetURL, WebInspector.res
ourceTypes.Stylesheet, ""); |
| 22 | 22 |
| 23 InspectorTest.addSniffer(WebInspector.CSSStyleSheetHeader.prototype, "update
Locations", locationsUpdated, true); | 23 InspectorTest.addSniffer(WebInspector.CSSStyleSheetHeader.prototype, "update
Locations", locationsUpdated, true); |
| 24 cssModel._styleSheetAdded(createMockStyleSheetHeader(styleSheetURL, sourceMa
pURL)); | 24 cssModel._styleSheetAdded(createMockStyleSheetHeader(styleSheetURL, sourceMa
pURL)); |
| 25 | 25 |
| 26 function locationsUpdated() | 26 function locationsUpdated() |
| 27 { | 27 { |
| 28 var uiLocation = new WebInspector.CSSLocation(WebInspector.targetManager
.activeTarget(), "http://localhost:8000/inspector/resources/example.css", 2, 3).
toUILocation(); | 28 var uiLocation = new WebInspector.CSSLocation(WebInspector.targetManager
.mainTarget(), "http://localhost:8000/inspector/resources/example.css", 2, 3).to
UILocation(); |
| 29 if (uiLocation.uiSourceCode.url.indexOf(".scss") === -1) | 29 if (uiLocation.uiSourceCode.url.indexOf(".scss") === -1) |
| 30 return; | 30 return; |
| 31 finalMappedLocation = uiLocation.uiSourceCode.url + ":" + uiLocation.lin
eNumber + ":" + uiLocation.columnNumber; | 31 finalMappedLocation = uiLocation.uiSourceCode.url + ":" + uiLocation.lin
eNumber + ":" + uiLocation.columnNumber; |
| 32 join(); | 32 join(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 function createMockStyleSheetHeader(url, sourceMapURL) | 36 function createMockStyleSheetHeader(url, sourceMapURL) |
| 37 { | 37 { |
| 38 const frame = WebInspector.resourceTreeModel.mainFrame; | 38 const frame = WebInspector.resourceTreeModel.mainFrame; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 65 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(scssUISourceCodeAdd
ed); | 65 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(scssUISourceCodeAdd
ed); |
| 66 } | 66 } |
| 67 | 67 |
| 68 function scssUISourceCodeAdded(uiSourceCode) | 68 function scssUISourceCodeAdded(uiSourceCode) |
| 69 { | 69 { |
| 70 afterStyleSheetAdded(); | 70 afterStyleSheetAdded(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 function rawLocationToUILocation(line, column) | 73 function rawLocationToUILocation(line, column) |
| 74 { | 74 { |
| 75 return new WebInspector.CSSLocation(WebInspector.targetManager.activeTar
get(), "http://localhost:8000/inspector/resources/example.css", line, column).to
UILocation(); | 75 return new WebInspector.CSSLocation(WebInspector.targetManager.mainTarge
t(), "http://localhost:8000/inspector/resources/example.css", line, column).toUI
Location(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 function afterStyleSheetAdded() | 78 function afterStyleSheetAdded() |
| 79 { | 79 { |
| 80 var cssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForOriginU
RL("http://localhost:8000/inspector/resources/example.css"); | 80 var cssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForOriginU
RL("http://localhost:8000/inspector/resources/example.css"); |
| 81 var scssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForOrigin
URL("http://localhost:8000/inspector/resources/example.scss"); | 81 var scssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForOrigin
URL("http://localhost:8000/inspector/resources/example.scss"); |
| 82 | 82 |
| 83 InspectorTest.checkUILocation(cssUISourceCode, 0, 3, rawLocationToUILoca
tion(0, 3)); | 83 InspectorTest.checkUILocation(cssUISourceCode, 0, 3, rawLocationToUILoca
tion(0, 3)); |
| 84 InspectorTest.checkUILocation(scssUISourceCode, 1, 0, rawLocationToUILoc
ation(1, 0)); | 84 InspectorTest.checkUILocation(scssUISourceCode, 1, 0, rawLocationToUILoc
ation(1, 0)); |
| 85 InspectorTest.checkUILocation(scssUISourceCode, 2, 2, rawLocationToUILoc
ation(2, 4)); | 85 InspectorTest.checkUILocation(scssUISourceCode, 2, 2, rawLocationToUILoc
ation(2, 4)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 </script> | 113 </script> |
| 114 | 114 |
| 115 </head> | 115 </head> |
| 116 | 116 |
| 117 <body onload="runTest()"> | 117 <body onload="runTest()"> |
| 118 <p>Tests SourceMap and StyleSheetMapping.</p> | 118 <p>Tests SourceMap and StyleSheetMapping.</p> |
| 119 </body> | 119 </body> |
| 120 </html> | 120 </html> |
| OLD | NEW |