browser_sourcemap_comment.js (1460B)
1 add_task(async function () { 2 // Test text and expected results. 3 let test_cases = [ 4 ["/*# sourceMappingURL=here*/", "here"], 5 ["/*# sourceMappingURL=here */", "here"], 6 ["/*@ sourceMappingURL=here*/", "here"], 7 ["/*@ sourceMappingURL=there*/ /*# sourceMappingURL=here*/", "here"], 8 ["/*# sourceMappingURL=here there */", "here"], 9 10 ["/*# sourceMappingURL= here */", ""], 11 ["/*# sourceMappingURL=*/", ""], 12 ["/*# sourceMappingUR=here */", ""], 13 ["/*! sourceMappingURL=here */", ""], 14 ["/*# sourceMappingURL = here */", ""], 15 ["/* # sourceMappingURL=here */", ""], 16 ]; 17 18 let page = "<!DOCTYPE HTML>\n<html>\n<head>\n"; 19 for (let i = 0; i < test_cases.length; ++i) { 20 page += `<style type="text/css"> #x${i} { color: red; }${test_cases[i][0]}</style>\n`; 21 } 22 page += "</head><body>some text</body></html>"; 23 24 let uri = "data:text/html;base64," + btoa(page); 25 info(`URI is ${uri}`); 26 27 await BrowserTestUtils.withNewTab( 28 { 29 gBrowser, 30 url: uri, 31 }, 32 async function (browser) { 33 await SpecialPowers.spawn(browser, [test_cases], function (tests) { 34 for (let i = 0; i < content.document.styleSheets.length; ++i) { 35 let sheet = content.document.styleSheets[i]; 36 37 info(`Checking sheet #${i}`); 38 is( 39 sheet.sourceMapURL, 40 tests[i][1], 41 `correct source map for sheet ${i}` 42 ); 43 } 44 }); 45 } 46 ); 47 });