browser_885052_customize_mode_observers_disabed.js (3037B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 function promiseButtonCheckedState(button, expectedCheckedState) { 8 return BrowserTestUtils.waitForMutationCondition( 9 button, 10 { 11 attributes: true, 12 attributeFilter: ["checked"], 13 }, 14 () => button.checked === expectedCheckedState 15 ).then(() => info("Button checked state now correct.")); 16 } 17 18 function promiseSizemodeChange(expectedSizeMode) { 19 return BrowserTestUtils.waitForEvent(window, "sizemodechange", false, () => { 20 let sizemode = document.documentElement.getAttribute("sizemode"); 21 info(`Sizemode changed to ${sizemode}. Expected: ${expectedSizeMode}`); 22 return ( 23 document.documentElement.getAttribute("sizemode") === expectedSizeMode 24 ); 25 }).then(() => info("Sizemode changed to " + expectedSizeMode + ".")); 26 } 27 28 // Observers should be disabled when in customization mode. 29 add_task(async function () { 30 CustomizableUI.addWidgetToArea( 31 "fullscreen-button", 32 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 33 ); 34 35 await waitForOverflowButtonShown(); 36 37 // Show the panel so it isn't hidden and has bindings applied etc.: 38 await document.getElementById("nav-bar").overflowable.show(); 39 40 // Hide it again. 41 document.getElementById("widget-overflow").hidePopup(); 42 43 let fullscreenButton = document.getElementById("fullscreen-button"); 44 ok( 45 !fullscreenButton.checked, 46 "Fullscreen button should not be checked when not in fullscreen." 47 ); 48 let oldSizemode = document.documentElement.getAttribute("sizemode"); 49 Assert.notEqual( 50 oldSizemode, 51 "fullscreen", 52 "Should not be in fullscreen sizemode before we enter fullscreen." 53 ); 54 55 let sizemodeChangePromise = promiseSizemodeChange("fullscreen"); 56 BrowserCommands.fullScreen(); 57 await Promise.all([ 58 promiseButtonCheckedState(fullscreenButton, true), 59 sizemodeChangePromise, 60 ]); 61 62 ok( 63 fullscreenButton.checked, 64 "Fullscreen button should be checked when in fullscreen." 65 ); 66 67 await startCustomizing(); 68 69 let fullscreenButtonWrapper = document.getElementById( 70 "wrapper-fullscreen-button" 71 ); 72 ok( 73 fullscreenButtonWrapper.hasAttribute("itemobserves"), 74 "Observer should be moved to wrapper" 75 ); 76 fullscreenButton = document.getElementById("fullscreen-button"); 77 ok( 78 !fullscreenButton.hasAttribute("observes"), 79 "Observer should be removed from button" 80 ); 81 ok( 82 !fullscreenButton.checked, 83 "Fullscreen button should no longer be checked during customization mode" 84 ); 85 86 await endCustomizing(); 87 88 sizemodeChangePromise = promiseSizemodeChange(oldSizemode); 89 BrowserCommands.fullScreen(); 90 await Promise.all([ 91 promiseButtonCheckedState(fullscreenButton, false), 92 sizemodeChangePromise, 93 ]); 94 ok( 95 !fullscreenButton.checked, 96 "Fullscreen button should not be checked when not in fullscreen." 97 ); 98 CustomizableUI.reset(); 99 });