browser_styleeditor_nostyle.js (1908B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that 'no styles' indicator is shown if a page doesn't contain any style 6 // sheets. 7 8 const TESTCASE_URI = TEST_BASE_HTTP + "nostyle.html"; 9 10 add_task(async function () { 11 // Make enough room for the "append style sheet" link to not wrap, 12 // as it messes up with EvenEventUtils.synthesizeMouse 13 await pushPref("devtools.styleeditor.navSidebarWidth", 500); 14 const { panel, ui } = await openStyleEditorForURL(TESTCASE_URI); 15 const { panelWindow } = panel; 16 17 ok( 18 !getRootElement(panel).classList.contains("loading"), 19 "style editor root element does not have 'loading' class name anymore" 20 ); 21 22 const newButton = panelWindow.document.querySelector( 23 "toolbarbutton.style-editor-newButton" 24 ); 25 ok(!newButton.hasAttribute("disabled"), "new style sheet button is enabled"); 26 27 const importButton = panelWindow.document.querySelector( 28 ".style-editor-importButton" 29 ); 30 ok(!importButton.hasAttribute("disabled"), "import button is enabled"); 31 32 const emptyPlaceHolderEl = 33 getRootElement(panel).querySelector(".empty.placeholder"); 34 isnot( 35 emptyPlaceHolderEl.ownerGlobal.getComputedStyle(emptyPlaceHolderEl).display, 36 "none", 37 "showing 'no style' indicator" 38 ); 39 40 info( 41 "Check that clicking on the append new stylesheet link do add a stylesheet" 42 ); 43 const onEditorAdded = ui.once("editor-added"); 44 const newLink = emptyPlaceHolderEl.querySelector("a.style-editor-newButton"); 45 46 // Use synthesizeMouse to also check that the element is visible 47 EventUtils.synthesizeMouseAtCenter(newLink, {}, newLink.ownerGlobal); 48 await onEditorAdded; 49 50 ok(true, "A stylesheet was added"); 51 is( 52 emptyPlaceHolderEl.ownerGlobal.getComputedStyle(emptyPlaceHolderEl).display, 53 "none", 54 "The empty placeholder element is now hidden" 55 ); 56 });