forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1775132 - Part 2: Allow background tasks to have non-ephemeral pe…
…rsistent profiles. r=mossop This is a little tricky since some behaviour must be in the profile service while some is more naturally in the background tasks mechanism. Essentially, some background tasks will have a consistent profile location determined by their "profile prefix", which includes vendor, installation hash, and background task name. Right now, those tasks are determined by their task name, but in the future we could make this more flexible. A few technical notes: 1. I elected to not assume (or provide) a directory service provider in the relevant helper, mostly to ease future commits that might pull this functionality forward in the startup process. 2. These background task profiles are placed in "Background Tasks Profiles" on relevant platforms (non-Unix and macOS), sibling to "Profiles". 3. To avoid any possible vulnerability with predictable profile directories, these non-ephemeral background task profiles are salted. An entry is placed in the `BackgroundTasksProfiles` section of `profiles.ini` mapping the profile prefix to the relative salted path. Differential Revision: https://phabricator.services.mozilla.com/D149919
- Loading branch information
Showing
18 changed files
with
561 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
toolkit/components/backgroundtasks/tests/BackgroundTask_not_ephemeral_profile.jsm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
var EXPORTED_SYMBOLS = ["runBackgroundTask"]; | ||
|
||
async function runBackgroundTask(commandLine) { | ||
// Exact same behaviour as `backgroundtask_specific_pref`, but with | ||
// a task name that is recognized as a task that should not use an | ||
// ephemeral profile. | ||
const taskModule = ChromeUtils.import( | ||
"resource://testing-common/backgroundtasks/BackgroundTask_backgroundtask_specific_pref.jsm" | ||
); | ||
return taskModule.runBackgroundTask(commandLine); | ||
} |
24 changes: 24 additions & 0 deletions
24
...it/components/backgroundtasks/tests/xpcshell/test_backgroundtask_not_ephemeral_profile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- | ||
* vim: sw=4 ts=4 sts=4 et | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
add_task(async function test_not_ephemeral_profile() { | ||
// Get the pref, and then update its value. We ignore the initial return, | ||
// since the persistent profile may already exist. | ||
let exitCode = await do_backgroundtask("not_ephemeral_profile", { | ||
extraArgs: ["test.backgroundtask_specific_pref.exitCode", "80"], | ||
}); | ||
|
||
// Do it again, confirming that the profile is persistent. | ||
exitCode = await do_backgroundtask("not_ephemeral_profile", { | ||
extraArgs: ["test.backgroundtask_specific_pref.exitCode", "81"], | ||
}); | ||
Assert.equal(80, exitCode); | ||
|
||
exitCode = await do_backgroundtask("not_ephemeral_profile", { | ||
extraArgs: ["test.backgroundtask_specific_pref.exitCode", "82"], | ||
}); | ||
Assert.equal(81, exitCode); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.