browser_styleeditor_init.js (1273B)
1 "use strict"; 2 /* Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ */ 4 5 // Checks that style editor contains correct stylesheets after initialization. 6 7 const TESTCASE_URI = TEST_BASE_HTTP + "simple.html"; 8 const EXPECTED_SHEETS = [ 9 { 10 sheetIndex: 0, 11 name: /^simple.css$/, 12 rules: 1, 13 active: true, 14 }, 15 { 16 sheetIndex: 1, 17 name: /^<.*>$/, 18 rules: 3, 19 active: false, 20 }, 21 ]; 22 23 add_task(async function () { 24 const { ui } = await openStyleEditorForURL(TESTCASE_URI); 25 26 is(ui.editors.length, 2, "The UI contains two style sheets."); 27 await checkSheet(ui.editors[0], EXPECTED_SHEETS[0]); 28 await checkSheet(ui.editors[1], EXPECTED_SHEETS[1]); 29 }); 30 31 async function checkSheet(editor, expected) { 32 is( 33 editor.styleSheet.styleSheetIndex, 34 expected.sheetIndex, 35 "Style sheet has correct index." 36 ); 37 38 const summary = editor.summary; 39 const name = summary 40 .querySelector(".stylesheet-name > label") 41 .getAttribute("value"); 42 ok(expected.name.test(name), "The name '" + name + "' is correct."); 43 44 await assertRuleCount(editor, expected.rules); 45 46 is( 47 summary.classList.contains("splitview-active"), 48 expected.active, 49 "The active status for this sheet is correct." 50 ); 51 }