Skip to content

Commit

Permalink
Bug 1722622 - Set background-delayed-startup to true in test_ext_back…
Browse files Browse the repository at this point in the history
…ground_service_worker to prevent intermittent failures in Thunderbird builds. r=darktrojan

Differential Revision: https://phabricator.services.mozilla.com/D121057
  • Loading branch information
rpl committed Jul 28, 2021
1 parent 75a04f1 commit 7c5c695
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,26 @@ add_task(async function setup() {
"force-serviceworkerrestart-init"
);

info("Set a low service worker idle timeout");
// Make sure background-delayed-startup is set to true (in some builds,
// in particular Thunderbird, it is set to false) otherwise the extension
// service worker will be started before the test cases can properly
// mock the behavior expected on browser startup by calling the
// nsIServiceWorkerManager.reloadRegistrationsForTest (and then the test task
// test_serviceworker_lifecycle_events will fail because the worker will
// refuse to be spawned while the extension is still disabled).
Services.prefs.setBoolPref(
"extensions.webextensions.background-delayed-startup",
true
);

Services.prefs.setBoolPref("dom.serviceWorkers.testing.enabled", true);

registerCleanupFunction(() => {
Services.prefs.clearUserPref("dom.serviceWorkers.idle_timeout");
Services.prefs.clearUserPref(
"extensions.webextensions.background-delayed-startup"
);
Services.prefs.clearUserPref("dom.serviceWorkers.testing.enabled");
Services.prefs.clearUserPref("dom.serviceWorkers.idle_timeout");
});
});

Expand Down

0 comments on commit 7c5c695

Please sign in to comment.