browser_searchModeSwitcher.js (1408B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_setup(async function setup() { 7 // Wait for the search service to make sure icons are available immediately. 8 await Services.search.init(); 9 }); 10 11 // keyword.enabled=false should have no effect on icon and label. 12 add_task(async function test_keyword_disabled() { 13 await SpecialPowers.pushPrefEnv({ 14 set: [["keyword.enabled", false]], 15 }); 16 let win = await BrowserTestUtils.openNewBrowserWindow(); 17 18 // Getting the icon is async, so wait until the icon is set. 19 await BrowserTestUtils.waitForCondition( 20 async () => 21 SearchbarTestUtils.getSearchModeSwitcherIcon(win) == 22 (await Services.search.defaultEngine.getIconURL()) 23 ); 24 25 Assert.ok( 26 true, 27 "The search mode switcher should have the default icon " + 28 "despite keyword.enabled being false" 29 ); 30 31 Assert.equal( 32 document 33 .querySelector("#searchbar-new .searchmode-switcher") 34 .getAttribute("data-l10n-id"), 35 "urlbar-searchmode-button2", 36 "Searchbar has regular l10n id" 37 ); 38 39 Assert.equal( 40 win.document 41 .querySelector("#urlbar .searchmode-switcher") 42 .getAttribute("data-l10n-id"), 43 "urlbar-searchmode-no-keyword", 44 "Urlbar has l10n id for keyword disabled" 45 ); 46 47 await BrowserTestUtils.closeWindow(win); 48 await SpecialPowers.popPrefEnv(); 49 });