| 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="../../isolated-filesystem-test.js"></script> | 4 <script src="../../isolated-filesystem-test.js"></script> |
| 5 <script src="../../workspace-test.js"></script> | 5 <script src="../../workspace-test.js"></script> |
| 6 <script> | 6 <script> |
| 7 function loadCSS() | 7 function loadCSS() |
| 8 { | 8 { |
| 9 var link = document.createElement("link"); | 9 var link = document.createElement("link"); |
| 10 link.rel = "stylesheet"; | 10 link.rel = "stylesheet"; |
| 11 link.type = "text/css"; | 11 link.type = "text/css"; |
| 12 link.href = "resources/update-locations-on-filesystem-scss-load.css"; | 12 link.href = "resources/update-locations-on-filesystem-scss-load.css"; |
| 13 document.head.appendChild(link); | 13 document.head.appendChild(link); |
| 14 } | 14 } |
| 15 | 15 |
| 16 function test() | 16 function test() |
| 17 { | 17 { |
| 18 InspectorTest.addResult("Creating filesystem with the SCSS file..."); | 18 InspectorTest.addResult("Creating filesystem with the SCSS file..."); |
| 19 var fs = new InspectorTest.TestFileSystem("file:///var/www"); | 19 var fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 20 fs.root.addFile("update-locations-on-filesystem-scss-load.scss", ["a {", "
foo: bar;", "/* COMMENT */", " font-size: 12px;", "}"].join("\n")); | 20 fs.root.addFile("update-locations-on-filesystem-scss-load.scss", ["a {", "
foo: bar;", "/* COMMENT */", " font-size: 12px;", "}"].join("\n")); |
| 21 fs.addFileMapping(WebInspector.ParsedURL.completeURL(InspectorTest.mainTarge
t.inspectedURL(), "resources/source/"), "/"); | 21 fs.addFileMapping(Common.ParsedURL.completeURL(InspectorTest.mainTarget.insp
ectedURL(), "resources/source/"), "/"); |
| 22 fs.reportCreated(fileSystemCreated); | 22 fs.reportCreated(fileSystemCreated); |
| 23 | 23 |
| 24 function fileSystemCreated() | 24 function fileSystemCreated() |
| 25 { | 25 { |
| 26 InspectorTest.addResult("Loading raw css with mapping..."); | 26 InspectorTest.addResult("Loading raw css with mapping..."); |
| 27 InspectorTest.cssModel.addEventListener(WebInspector.CSSModel.Events.Sty
leSheetAdded, styleSheetAdded); | 27 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAd
ded, styleSheetAdded); |
| 28 InspectorTest.evaluateInPage("loadCSS()"); | 28 InspectorTest.evaluateInPage("loadCSS()"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 var liveLocation; | 31 var liveLocation; |
| 32 | 32 |
| 33 function styleSheetAdded(event) | 33 function styleSheetAdded(event) |
| 34 { | 34 { |
| 35 InspectorTest.addResult("Stylesheet was added, dumping location:"); | 35 InspectorTest.addResult("Stylesheet was added, dumping location:"); |
| 36 var header = event.data; | 36 var header = event.data; |
| 37 var cssLocation = new WebInspector.CSSLocation(header, 0, 1); | 37 var cssLocation = new SDK.CSSLocation(header, 0, 1); |
| 38 liveLocation = WebInspector.cssWorkspaceBinding.createLiveLocation(cssLo
cation, function() {}, new WebInspector.LiveLocationPool()); | 38 liveLocation = Bindings.cssWorkspaceBinding.createLiveLocation(cssLocati
on, function() {}, new Bindings.LiveLocationPool()); |
| 39 InspectorTest.cssModel.addEventListener(WebInspector.CSSModel.Events.Sou
rceMapAttached, afterBind); | 39 InspectorTest.cssModel.addEventListener(SDK.CSSModel.Events.SourceMapAtt
ached, afterBind); |
| 40 dumpLiveLocation(); | 40 dumpLiveLocation(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 function afterBind() | 43 function afterBind() |
| 44 { | 44 { |
| 45 InspectorTest.addResult("Source map was bound to the file loaded from fi
lesystem:"); | 45 InspectorTest.addResult("Source map was bound to the file loaded from fi
lesystem:"); |
| 46 dumpLiveLocation(); | 46 dumpLiveLocation(); |
| 47 InspectorTest.completeTest(); | 47 InspectorTest.completeTest(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 function dumpLiveLocation() | 50 function dumpLiveLocation() |
| 51 { | 51 { |
| 52 var uiLocation = liveLocation.uiLocation(); | 52 var uiLocation = liveLocation.uiLocation(); |
| 53 if (!uiLocation) { | 53 if (!uiLocation) { |
| 54 InspectorTest.addResult("Null uiLocation"); | 54 InspectorTest.addResult("Null uiLocation"); |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 InspectorTest.addResult(uiLocation.uiSourceCode.url() + ":" + uiLocation
.lineNumber + ":" + uiLocation.columnNumber); | 57 InspectorTest.addResult(uiLocation.uiSourceCode.url() + ":" + uiLocation
.lineNumber + ":" + uiLocation.columnNumber); |
| 58 } | 58 } |
| 59 }; | 59 }; |
| 60 </script> | 60 </script> |
| 61 </head> | 61 </head> |
| 62 <body onload="runTest()"> | 62 <body onload="runTest()"> |
| 63 <p>Tests that stylesheet LiveLocations are updated when an SCSS file is loaded f
rom the filesystem.</p> | 63 <p>Tests that stylesheet LiveLocations are updated when an SCSS file is loaded f
rom the filesystem.</p> |
| 64 </body> | 64 </body> |
| 65 </html> | 65 </html> |
| OLD | NEW |