no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / layout / style / test / browser_sourcemap_comment.js
blobe0bbff8de44fbd705cfce6016ce0c13a300f33cd
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"],
10     ["/*# sourceMappingURL=  here  */", ""],
11     ["/*# sourceMappingURL=*/", ""],
12     ["/*# sourceMappingUR=here  */", ""],
13     ["/*! sourceMappingURL=here  */", ""],
14     ["/*# sourceMappingURL = here  */", ""],
15     ["/*   # sourceMappingURL=here   */", ""],
16   ];
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>";
24   let uri = "data:text/html;base64," + btoa(page);
25   info(`URI is ${uri}`);
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];
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 });