diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js')
-rw-r--r-- | browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js b/browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js new file mode 100644 index 0000000000..e193181200 --- /dev/null +++ b/browser/components/preferences/tests/browser_ensure_prefs_bindings_initted.js @@ -0,0 +1,40 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* + * Check that panes that aren't the default have their bindings initialized + * and 'preference' attributes are processed correctly. + */ +add_task(async function test_prefs_bindings_initted() { + await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true }); + let doc = gBrowser.selectedBrowser.contentDocument; + let prefReader = doc.ownerGlobal.Preferences; + let prefBasedCheckboxes = Array.from( + doc.querySelectorAll("checkbox[preference]") + ); + + // Then check all the preferences: + for (let checkbox of prefBasedCheckboxes) { + let pref = checkbox.getAttribute("preference"); + if (Services.prefs.getPrefType(pref) == Services.prefs.PREF_BOOL) { + info(`Waiting for checkbox to match pref ${pref}`); + // Ensure the task setting up prefs has run. + await BrowserTestUtils.waitForMutationCondition( + checkbox, + { attributeFilter: ["checked"] }, + () => checkbox.checked == prefReader.get(pref).value + ); + is( + checkbox.checked, + prefReader.get(pref).value, + `Checkbox value should match preference (${pref}).` + ); + // Ignore all other types. The mapping is normally non-trivial and done + // using syncfrompreference handlers in JS. + } + } + + BrowserTestUtils.removeTab(gBrowser.selectedTab); +}); |