browser_experimental_features_hidden_when_not_public.js (2254B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function testNonPublicFeaturesShouldntGetDisplayed() { 7 const cleanup = await setupLabsTest(); 8 9 await BrowserTestUtils.openNewForegroundTab( 10 gBrowser, 11 "about:preferences#paneExperimental" 12 ); 13 let doc = gBrowser.contentDocument; 14 15 await TestUtils.waitForCondition( 16 () => doc.getElementById("nimbus-qa-1"), 17 "wait for features to be added to the DOM" 18 ); 19 20 Assert.ok( 21 !!doc.getElementById("nimbus-qa-1"), 22 "nimbus-qa-1 checkbox in the document" 23 ); 24 Assert.ok( 25 !!doc.getElementById("nimbus-qa-2"), 26 "nimbus-qa-2 checkbox in the document" 27 ); 28 29 Assert.ok( 30 !doc.getElementById("targeting-false"), 31 "targeting-false checkbox not in the document" 32 ); 33 Assert.ok( 34 !doc.getElementById("bucketing-false"), 35 "bucketing-false checkbox not in the document" 36 ); 37 38 BrowserTestUtils.removeTab(gBrowser.selectedTab); 39 40 await cleanup(); 41 }); 42 43 add_task(async function testNonPublicFeaturesShouldntGetDisplayed() { 44 // Only recipes that do not match targeting or bucketing 45 const cleanup = await setupLabsTest(DEFAULT_LABS_RECIPES.slice(2)); 46 47 await SpecialPowers.pushPrefEnv({ 48 set: [["browser.preferences.experimental.hidden", false]], 49 }); 50 51 await BrowserTestUtils.openNewForegroundTab( 52 gBrowser, 53 "about:preferences#paneExperimental" 54 ); 55 const doc = gBrowser.contentDocument; 56 57 await TestUtils.waitForCondition( 58 () => doc.getElementById("category-experimental").hidden, 59 "Wait for Experimental Features section to get hidden" 60 ); 61 62 ok( 63 doc.getElementById("category-experimental").hidden, 64 "Experimental Features section should be hidden when all features are hidden" 65 ); 66 ok( 67 doc.getElementById("firefoxExperimentalCategory").hidden, 68 "Experimental Features header should be hidden when all features are hidden" 69 ); 70 is( 71 doc.querySelector(".category[selected]").id, 72 "category-general", 73 "When the experimental features section is hidden, navigating to #experimental should redirect to #general" 74 ); 75 76 BrowserTestUtils.removeTab(gBrowser.selectedTab); 77 78 await cleanup(); 79 await SpecialPowers.popPrefEnv(); 80 });