| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 | 3 |
| 4 <link rel="stylesheet" href="resources/test-mapping-bad.css"> | 4 <link rel="stylesheet" href="resources/test-mapping-bad.css"> |
| 5 | 5 |
| 6 <script src="../../http/tests/inspector/inspector-test.js"></script> | 6 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 7 <script src="../../http/tests/inspector/debugger-test.js"></script> | 7 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 8 <script src="./sass-test.js"></script> | 8 <script src="./sass-test.js"></script> |
| 9 <script> | 9 <script> |
| 10 | 10 |
| 11 function test() | 11 function test() |
| 12 { | 12 { |
| 13 var header = InspectorTest.cssModel.styleSheetHeaders().find(header => !!hea
der.sourceMapURL) | 13 var header = InspectorTest.cssModel.styleSheetHeaders().find(header => !!hea
der.sourceMapURL) |
| 14 InspectorTest.loadSourceMap(header, onSourceMapLoaded); | 14 InspectorTest.loadASTMapping(header, onMapping); |
| 15 InspectorTest.waitForScriptSource("test-mapping-bad.css", onCSSLoaded); | |
| 16 InspectorTest.waitForScriptSource("test-mapping-bad.scss", onSCSSLoaded); | |
| 17 | 15 |
| 18 var cssAST; | 16 function onMapping(mapping) |
| 19 var sassModels = new Map(); | |
| 20 var sourceMap; | |
| 21 | |
| 22 function onCSSLoaded(uiSourceCode) | |
| 23 { | 17 { |
| 24 uiSourceCode.requestContent() | |
| 25 .then(text => InspectorTest.parseCSS(uiSourceCode.url(), text)) | |
| 26 .then(ast => cssAST = ast) | |
| 27 .then(maybeCreateMapping); | |
| 28 } | |
| 29 | |
| 30 function onSCSSLoaded(uiSourceCode) | |
| 31 { | |
| 32 uiSourceCode.requestContent() | |
| 33 .then(text => InspectorTest.parseSCSS(uiSourceCode.url(), text)) | |
| 34 .then(ast => sassModels.set(ast.document.url, ast)) | |
| 35 .then(maybeCreateMapping); | |
| 36 } | |
| 37 | |
| 38 function onSourceMapLoaded(sm) | |
| 39 { | |
| 40 sourceMap = sm; | |
| 41 maybeCreateMapping(); | |
| 42 } | |
| 43 | |
| 44 function maybeCreateMapping() | |
| 45 { | |
| 46 if (!cssAST || !sassModels.size || !sourceMap) | |
| 47 return; | |
| 48 var mapping = WebInspector.SASSLiveSourceMap.CSSToSASSMapping.fromSource
Map(sourceMap, cssAST, sassModels); | |
| 49 if (mapping.isValid()) { | 18 if (mapping.isValid()) { |
| 50 InspectorTest.addResult("ERROR: a valid mapping created for misalign
ed sourcemap."); | 19 InspectorTest.addResult("ERROR: a valid mapping created for misalign
ed sourcemap."); |
| 20 } else { |
| 21 InspectorTest.addResult("OK: the mapping successfully reported misal
ignment."); |
| 51 } | 22 } |
| 52 InspectorTest.completeTest(); | 23 InspectorTest.completeTest(); |
| 53 } | 24 } |
| 54 } | 25 } |
| 55 | 26 |
| 56 </script> | 27 </script> |
| 57 | 28 |
| 58 </head> | 29 </head> |
| 59 | 30 |
| 60 <body onload="runTest()"> | 31 <body onload="runTest()"> |
| 61 <p>Verify that mapping is not valid for misaligned sources.</p> | 32 <p>Verify that mapping is not valid for misaligned sources.</p> |
| 62 </body> | 33 </body> |
| 63 </html> | 34 </html> |
| OLD | NEW |