From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- testing/modules/TestUtils.sys.mjs | 47 ++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'testing/modules/TestUtils.sys.mjs') diff --git a/testing/modules/TestUtils.sys.mjs b/testing/modules/TestUtils.sys.mjs index 51030f5fbc..cbf6b2d439 100644 --- a/testing/modules/TestUtils.sys.mjs +++ b/testing/modules/TestUtils.sys.mjs @@ -207,33 +207,30 @@ export var TestUtils = { */ waitForPrefChange(prefName, checkFn) { return new Promise((resolve, reject) => { - Services.prefs.addObserver( - prefName, - function observer(subject, topic, data) { - try { - let prefValue = null; - switch (Services.prefs.getPrefType(prefName)) { - case Services.prefs.PREF_STRING: - prefValue = Services.prefs.getStringPref(prefName); - break; - case Services.prefs.PREF_INT: - prefValue = Services.prefs.getIntPref(prefName); - break; - case Services.prefs.PREF_BOOL: - prefValue = Services.prefs.getBoolPref(prefName); - break; - } - if (checkFn && !checkFn(prefValue)) { - return; - } - Services.prefs.removeObserver(prefName, observer); - resolve(prefValue); - } catch (ex) { - Services.prefs.removeObserver(prefName, observer); - reject(ex); + Services.prefs.addObserver(prefName, function observer() { + try { + let prefValue = null; + switch (Services.prefs.getPrefType(prefName)) { + case Services.prefs.PREF_STRING: + prefValue = Services.prefs.getStringPref(prefName); + break; + case Services.prefs.PREF_INT: + prefValue = Services.prefs.getIntPref(prefName); + break; + case Services.prefs.PREF_BOOL: + prefValue = Services.prefs.getBoolPref(prefName); + break; + } + if (checkFn && !checkFn(prefValue)) { + return; } + Services.prefs.removeObserver(prefName, observer); + resolve(prefValue); + } catch (ex) { + Services.prefs.removeObserver(prefName, observer); + reject(ex); } - ); + }); }); }, -- cgit v1.2.3