browser_experimental_features_resetall.js (2315B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { FirefoxLabs } = ChromeUtils.importESModule( 7 "resource://nimbus/FirefoxLabs.sys.mjs" 8 ); 9 10 add_setup(async function setup() { 11 const cleanup = await setupLabsTest(); 12 registerCleanupFunction(cleanup); 13 }); 14 15 // This test verifies that pressing the reset all button for experimental features 16 // resets all of the checkboxes to their default state. 17 add_task(async function testResetAll() { 18 await BrowserTestUtils.openNewForegroundTab( 19 gBrowser, 20 `about:preferences#paneExperimental` 21 ); 22 23 const doc = gBrowser.contentDocument; 24 25 await TestUtils.waitForCondition( 26 () => doc.querySelector(".featureGate"), 27 "wait for features to be added to the DOM" 28 ); 29 30 const qa1El = doc.getElementById("nimbus-qa-1"); 31 const qa2El = doc.getElementById("nimbus-qa-2"); 32 33 ok( 34 !ExperimentAPI._manager.store.get("nimbus-qa-1")?.active, 35 "Should not enroll in nimbus-qa-1" 36 ); 37 ok( 38 !ExperimentAPI._manager.store.get("nimbus-qa-2")?.active, 39 "Should not enroll in nimbus-qa-2" 40 ); 41 ok(!qa1El.checked, "nimbus-qa-1 checkbox unchecked"); 42 ok(!qa2El.checked, "nimbus-qa-2 checkbox unchecked"); 43 44 // Modify the state of some of the features. 45 await enrollByClick(qa1El, true); 46 await enrollByClick(qa2El, true); 47 48 ok( 49 ExperimentAPI._manager.store.get("nimbus-qa-1")?.active, 50 "Should enroll in nimbus-qa-1" 51 ); 52 ok( 53 ExperimentAPI._manager.store.get("nimbus-qa-2")?.active, 54 "Should enroll in nimbus-qa-2" 55 ); 56 ok(qa1El.checked, "nimbus-qa-1 checkbox checked"); 57 ok(qa2El.checked, "nimbus-qa-2 checkbox checked"); 58 59 const unenrollPromises = [ 60 promiseNimbusStoreUpdate("nimbus-qa-1", false), 61 promiseNimbusStoreUpdate("nimbus-qa-2", false), 62 ]; 63 64 doc.getElementById("experimentalCategory-reset").click(); 65 await Promise.all(unenrollPromises); 66 67 ok( 68 !ExperimentAPI._manager.store.get("nimbus-qa-1")?.active, 69 "Should unenroll from nimbus-qa-1" 70 ); 71 ok( 72 !ExperimentAPI._manager.store.get("nimbus-qa-2")?.active, 73 "Should unenroll from nimbus-qa-2" 74 ); 75 ok(!qa1El.checked, "nimbus-qa-1 checkbox unchecked"); 76 ok(!qa2El.checked, "nimbus-qa-2 checkbox unchecked"); 77 78 BrowserTestUtils.removeTab(gBrowser.selectedTab); 79 });