Bug 1696160 - [remote] Only reset those recommended preferences that were previously set. r=remote-protocol-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D107054
This commit is contained in:
Henrik Skupin 2021-03-08 13:44:55 +00:00
Родитель 5319c0f444
Коммит 983c92b44e
2 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -6,23 +6,25 @@
var EXPORTED_SYMBOLS = ["RecommendedPreferences"];
const RecommendedPreferences = {
const RecommendedPreferences = new Map([
// Allow the application to have focus even when it runs in the background.
"focusmanager.testmode": true,
["focusmanager.testmode", true],
// Avoid breaking odd-runs of firefox because of it running in safe mode.
// Firefox will run in safe mode alsmost on every even/odd runs as
// Puppeteer may very easily shutdown Firefox process brutaly and force
// it to run in safe mode in the next run.
"toolkit.startup.max_resumed_crashes": -1,
["toolkit.startup.max_resumed_crashes", -1],
// Prevent various error message on the console
// jest-puppeteer asserts that no error message is emitted by the console
"browser.contentblocking.features.standard":
[
"browser.contentblocking.features.standard",
"-tp,tpPrivate,cookieBehavior0,-cm,-fp",
"network.cookie.cookieBehavior": 0,
],
["network.cookie.cookieBehavior", 0],
// Only allow the old modal dialogs. This should be removed when there is
// support for the new modal UI (see Bug 1686743).
"prompts.contentPromptSubDialog": false,
};
["prompts.contentPromptSubDialog", false],
]);

Просмотреть файл

@ -29,6 +29,10 @@ const FORCE_LOCAL = "remote.force-local";
const LOOPBACKS = ["localhost", "127.0.0.1", "[::1]"];
class RemoteAgentClass {
constructor() {
this.alteredPrefs = new Set();
}
get listening() {
return !!this.server && !this.server.isStopped();
}
@ -76,7 +80,13 @@ class RemoteAgentClass {
port = -1;
}
Preferences.set(RecommendedPreferences);
for (let [k, v] of RecommendedPreferences) {
if (!Preferences.isSet(k)) {
log.debug(`Setting recommended pref ${k} to ${v}`);
Preferences.set(k, v);
this.alteredPrefs.add(k);
}
}
this.server = new HttpServer();
this.server.registerPrefixHandler("/json/", new JSONHandler(this));
@ -114,10 +124,11 @@ class RemoteAgentClass {
close() {
try {
// if called early at startup, preferences may not be available
try {
Preferences.reset(Object.keys(RecommendedPreferences));
} catch (e) {}
for (let k of this.alteredPrefs) {
log.debug(`Resetting recommended pref ${k}`);
Preferences.reset(k);
}
this.alteredPrefs.clear();
// destroy targets before stopping server,
// otherwise the HTTP will fail to stop