[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 10/179: Bug 1764585 - Wait for some pref changes to take effect. r=tnikkel, a=test-only
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-102.2.0esr-12.0-1
in repository tor-browser.
commit af2abc71a085e1b61426b0e6c606f29520bb3478
Author: Emilio Cobos Álvarez <emilio@xxxxxxxxx>
AuthorDate: Mon Jun 20 17:22:13 2022 +0200
Bug 1764585 - Wait for some pref changes to take effect. r=tnikkel, a=test-only
---
layout/tools/reftest/reftest.jsm | 91 ++++++++++++++--------
.../specialpowers/content/SpecialPowersParent.jsm | 1 +
2 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/layout/tools/reftest/reftest.jsm b/layout/tools/reftest/reftest.jsm
index 6e6b171ae650f..aced2511cdbfd 100644
--- a/layout/tools/reftest/reftest.jsm
+++ b/layout/tools/reftest/reftest.jsm
@@ -687,7 +687,7 @@ function Blur()
g.containingWindow.blur();
}
-function StartCurrentTest()
+async function StartCurrentTest()
{
g.testLog = [];
@@ -716,7 +716,7 @@ function StartCurrentTest()
if ((g.urls.length == 0 && g.repeat == 0) ||
(g.runUntilFailure && HasUnexpectedResult())) {
- RestoreChangedPreferences();
+ await RestoreChangedPreferences();
DoneTests();
} else if (g.urls.length == 0 && g.repeat > 0) {
// Repeat
@@ -772,6 +772,14 @@ function updateBrowserRemotenessByURL(aBrowser, aURL) {
return Promise.resolve();
}
+// This logic should match SpecialPowersParent._applyPrefs.
+function PrefRequiresRefresh(name) {
+ return name == "layout.css.prefers-color-scheme.content-override" ||
+ name.startsWith("ui.") ||
+ name.startsWith("browser.display.") ||
+ name.startsWith("font.");
+}
+
async function StartCurrentURI(aURLTargetType)
{
const isStartingRef = (aURLTargetType == URL_TARGET_TYPE_REFERENCE);
@@ -779,7 +787,7 @@ async function StartCurrentURI(aURLTargetType)
g.currentURL = g.urls[0][isStartingRef ? "url2" : "url1"].spec;
g.currentURLTargetType = aURLTargetType;
- RestoreChangedPreferences();
+ await RestoreChangedPreferences();
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
@@ -787,6 +795,8 @@ async function StartCurrentURI(aURLTargetType)
const prefSettings =
g.urls[0][isStartingRef ? "prefSettings2" : "prefSettings1"];
+ var prefsRequireRefresh = false;
+
if (prefSettings.length > 0) {
var badPref = undefined;
try {
@@ -829,10 +839,13 @@ async function StartCurrentURI(aURLTargetType)
}
}
if (!prefExists || oldVal != ps.value) {
+ var requiresRefresh = PrefRequiresRefresh(ps.name);
+ prefsRequireRefresh = prefsRequireRefresh || requiresRefresh;
g.prefsToRestore.push( { name: ps.name,
- type: ps.type,
- value: oldVal,
- prefExisted: prefExists } );
+ type: ps.type,
+ value: oldVal,
+ requiresRefresh,
+ prefExisted: prefExists } );
var value = ps.value;
if (ps.type == PREF_BOOLEAN) {
prefs.setBoolPref(ps.name, value);
@@ -860,7 +873,7 @@ async function StartCurrentURI(aURLTargetType)
// skip the test that had a bad preference
g.urls.shift();
- StartCurrentTest();
+ await StartCurrentTest();
return;
} else {
throw e;
@@ -885,6 +898,10 @@ async function StartCurrentURI(aURLTargetType)
TestBuffer("START " + g.currentURL);
await updateBrowserRemotenessByURL(g.browser, g.currentURL);
+ if (prefsRequireRefresh) {
+ await new Promise(resolve => g.containingWindow.requestAnimationFrame(resolve));
+ }
+
var type = g.urls[0].type
if (TYPE_SCRIPT == type) {
SendLoadScriptTest(g.currentURL, g.loadTimeout);
@@ -1500,7 +1517,7 @@ function FinishTestItem()
g.failedAssignedLayerMessages = [];
}
-function DoAssertionCheck(numAsserts)
+async function DoAssertionCheck(numAsserts)
{
if (g.debug.isDebugBuild) {
if (g.browserIsRemote) {
@@ -1532,7 +1549,7 @@ function DoAssertionCheck(numAsserts)
// And start the next test.
g.urls.shift();
- StartCurrentTest();
+ await StartCurrentTest();
}
function ResetRenderingState()
@@ -1541,30 +1558,38 @@ function ResetRenderingState()
// We would want to clear any viewconfig here, if we add support for it
}
-function RestoreChangedPreferences()
+async function RestoreChangedPreferences()
{
- if (g.prefsToRestore.length > 0) {
- var prefs = Cc["@mozilla.org/preferences-service;1"].
- getService(Ci.nsIPrefBranch);
- g.prefsToRestore.reverse();
- g.prefsToRestore.forEach(function(ps) {
- if (ps.prefExisted) {
- var value = ps.value;
- if (ps.type == PREF_BOOLEAN) {
- prefs.setBoolPref(ps.name, value);
- } else if (ps.type == PREF_STRING) {
- prefs.setStringPref(ps.name, value);
- value = '"' + value + '"';
- } else if (ps.type == PREF_INTEGER) {
- prefs.setIntPref(ps.name, value);
- }
- logger.info("RESTORE PREFERENCE pref(" + ps.name + "," + value + ")");
- } else {
- prefs.clearUserPref(ps.name);
- logger.info("RESTORE PREFERENCE pref(" + ps.name + ", <no value set>) (clearing user pref)");
+ if (!g.prefsToRestore.length) {
+ return;
+ }
+ var prefs = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ var requiresRefresh = false;
+ g.prefsToRestore.reverse();
+ g.prefsToRestore.forEach(function(ps) {
+ requiresRefresh = requiresRefresh || ps.requiresRefresh;
+ if (ps.prefExisted) {
+ var value = ps.value;
+ if (ps.type == PREF_BOOLEAN) {
+ prefs.setBoolPref(ps.name, value);
+ } else if (ps.type == PREF_STRING) {
+ prefs.setStringPref(ps.name, value);
+ value = '"' + value + '"';
+ } else if (ps.type == PREF_INTEGER) {
+ prefs.setIntPref(ps.name, value);
}
- });
- g.prefsToRestore = [];
+ logger.info("RESTORE PREFERENCE pref(" + ps.name + "," + value + ")");
+ } else {
+ prefs.clearUserPref(ps.name);
+ logger.info("RESTORE PREFERENCE pref(" + ps.name + ", <no value set>) (clearing user pref)");
+ }
+ });
+
+ g.prefsToRestore = [];
+
+ if (requiresRefresh) {
+ await new Promise(resolve => g.containingWindow.requestAnimationFrame(resolve));
}
}
@@ -1664,9 +1689,9 @@ function RegisterMessageListenersAndLoadContentScript(aReload)
});
}
-function RecvAssertionCount(count)
+async function RecvAssertionCount(count)
{
- DoAssertionCheck(count);
+ await DoAssertionCheck(count);
}
function RecvContentReady(info)
diff --git a/testing/specialpowers/content/SpecialPowersParent.jsm b/testing/specialpowers/content/SpecialPowersParent.jsm
index 64f7c210eeaa7..85dbc4ab66e8c 100644
--- a/testing/specialpowers/content/SpecialPowersParent.jsm
+++ b/testing/specialpowers/content/SpecialPowersParent.jsm
@@ -410,6 +410,7 @@ class SpecialPowersParent extends JSWindowActorParent {
_applyPrefs(actions) {
let requiresRefresh = false;
for (let pref of actions) {
+ // This logic should match PrefRequiresRefresh in reftest.jsm
requiresRefresh =
requiresRefresh ||
pref.name == "layout.css.prefers-color-scheme.content-override" ||
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits