browser_947914_button_cut.js (1806B)
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 var initialLocation = gBrowser.currentURI.spec; 8 var globalClipboard; 9 10 add_setup(async function () { 11 await SpecialPowers.pushPrefEnv({ 12 set: [["test.wait300msAfterTabSwitch", true]], 13 }); 14 }); 15 16 add_task(async function () { 17 await BrowserTestUtils.withNewTab( 18 { gBrowser, url: "about:blank" }, 19 async function () { 20 info("Check cut button existence and functionality"); 21 CustomizableUI.addWidgetToArea( 22 "edit-controls", 23 CustomizableUI.AREA_FIXED_OVERFLOW_PANEL 24 ); 25 26 await waitForOverflowButtonShown(); 27 28 let testText = "cut text test"; 29 30 gURLBar.focus(); 31 await document.getElementById("nav-bar").overflowable.show(); 32 info("Menu panel was opened"); 33 34 let cutButton = document.getElementById("cut-button"); 35 ok(cutButton, "Cut button exists in Panel Menu"); 36 ok(cutButton.hasAttribute("disabled"), "Cut button is disabled"); 37 38 // cut text from URL bar 39 gURLBar.value = testText; 40 gURLBar.valueIsTyped = true; 41 gURLBar.focus(); 42 gURLBar.select(); 43 await document.getElementById("nav-bar").overflowable.show(); 44 info("Menu panel was opened"); 45 46 ok( 47 !cutButton.hasAttribute("disabled"), 48 "Cut button is enabled when selecting" 49 ); 50 await SimpleTest.promiseClipboardChange(testText, () => { 51 cutButton.click(); 52 }); 53 is( 54 gURLBar.value, 55 "", 56 "Selected text is removed from source when clicking on cut" 57 ); 58 } 59 ); 60 }); 61 62 registerCleanupFunction(function cleanup() { 63 CustomizableUI.reset(); 64 });