mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 03:49:42 +00:00
Bug 1784840 - Convert all background tasks to ESM r=nalexander,application-update-reviewers,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D156950
This commit is contained in:
parent
b3fd738eb1
commit
232d5682ef
@ -7,8 +7,7 @@ var { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
if (AppConstants.platform !== "win") {
|
||||
console.log("Not a Windows install, skipping `uninstall` background task.");
|
||||
return;
|
@ -156,5 +156,5 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_uninstall.jsm",
|
||||
"BackgroundTask_uninstall.sys.mjs",
|
||||
]
|
||||
|
@ -2,21 +2,14 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
const lazy = {};
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
});
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
// Recursively removes a directory.
|
||||
// Returns true if it succeeds, false otherwise.
|
||||
@ -187,7 +180,7 @@ async function cleanupOtherCacheDirectories(
|
||||
// otherFoldersSuffix - [optional] The suffix of moved purged cache directories
|
||||
// When not empty, this task will also attempt to remove all directories in
|
||||
// the profile dir that end with this suffix
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
if (commandLine.length < 3) {
|
||||
throw new Error("Insufficient arguments");
|
||||
}
|
@ -66,6 +66,6 @@ FINAL_LIBRARY = "xul"
|
||||
|
||||
if CONFIG["MOZ_BACKGROUNDTASKS"]:
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_purgeHTTPCache.jsm",
|
||||
"BackgroundTask_purgeHTTPCache.sys.mjs",
|
||||
]
|
||||
DEFINES["MOZ_BACKGROUNDTASKS"] = True
|
||||
|
@ -17,7 +17,7 @@ const do_backgroundtask = BackgroundTasksTestUtils.do_backgroundtask.bind(
|
||||
// which are a public API, do not change over time.
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
);
|
||||
|
||||
const LEAF_NAME = "newCacheFolder";
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
* 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() {
|
||||
export async function runBackgroundTask() {
|
||||
console.error("runBackgroundTask: exception");
|
||||
|
||||
throw new Error("test");
|
@ -3,9 +3,7 @@
|
||||
* 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() {
|
||||
export async function runBackgroundTask() {
|
||||
console.error("runBackgroundTask: failure");
|
||||
|
||||
return 1;
|
@ -51,23 +51,13 @@
|
||||
// --no-optoutstudies: set `app.shield.optoutstudies.enabled=false` in the
|
||||
// background task profile.
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
const { ASRouter } = ChromeUtils.import(
|
||||
"resource://activity-stream/lib/ASRouter.jsm"
|
||||
);
|
||||
const { BackgroundTasksUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksUtils.jsm"
|
||||
);
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { BackgroundTasksUtils } from "resource://gre/modules/BackgroundTasksUtils.sys.mjs";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -291,7 +281,7 @@ async function handleCommandLine(commandLine) {
|
||||
}
|
||||
}
|
||||
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
console.error("runBackgroundTask: message");
|
||||
|
||||
// Most of the task is arranging configuration.
|
@ -3,15 +3,9 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
|
||||
async function runBackgroundTask() {
|
||||
export async function runBackgroundTask() {
|
||||
console.error("runBackgroundTask: success");
|
||||
|
||||
return EXIT_CODE.SUCCESS;
|
@ -3,11 +3,7 @@
|
||||
* 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 = ["BackgroundTasksManager"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -68,7 +64,7 @@ function locationsForBackgroundTaskNamed(name) {
|
||||
|
||||
let locations = [];
|
||||
for (const subModule of subModules) {
|
||||
let URI = `${subModule}/backgroundtasks/BackgroundTask_${name}.jsm`;
|
||||
let URI = `${subModule}/backgroundtasks/BackgroundTask_${name}.sys.mjs`;
|
||||
locations.push(URI);
|
||||
}
|
||||
|
||||
@ -76,7 +72,7 @@ function locationsForBackgroundTaskNamed(name) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a JSM named like `backgroundtasks/BackgroundTask_${name}.jsm`,
|
||||
* Find an ES module named like `backgroundtasks/BackgroundTask_${name}.sys.mjs`,
|
||||
* import it, and return the whole module.
|
||||
*
|
||||
* When testing, allow to load from `XPCSHELL_TESTING_MODULES_URI`,
|
||||
@ -92,7 +88,7 @@ function findBackgroundTaskModule(name) {
|
||||
lazy.log.debug(`Looking for background task at URI: ${URI}`);
|
||||
|
||||
try {
|
||||
const taskModule = ChromeUtils.import(URI);
|
||||
const taskModule = ChromeUtils.importESModule(URI);
|
||||
lazy.log.info(`Found background task at URI: ${URI}`);
|
||||
return taskModule;
|
||||
} catch (ex) {
|
||||
@ -109,7 +105,7 @@ function findBackgroundTaskModule(name) {
|
||||
);
|
||||
}
|
||||
|
||||
class BackgroundTasksManager {
|
||||
export class BackgroundTasksManager {
|
||||
// Keep `BackgroundTasksManager.helpInfo` synchronized with `DevToolsStartup.helpInfo`.
|
||||
/* eslint-disable max-len */
|
||||
helpInfo =
|
||||
@ -196,7 +192,7 @@ class BackgroundTasksManager {
|
||||
` '${Services.dirsvc.get("ProfD", Ci.nsIFile).path}'`
|
||||
);
|
||||
|
||||
let exitCode = BackgroundTasksManager.EXIT_CODE.NOT_FOUND;
|
||||
let exitCode = EXIT_CODE.NOT_FOUND;
|
||||
try {
|
||||
let taskModule = findBackgroundTaskModule(name);
|
||||
addMarker("BackgroundTasksManager:AfterFindRunBackgroundTask");
|
||||
@ -214,7 +210,7 @@ class BackgroundTasksManager {
|
||||
new Promise(resolve =>
|
||||
lazy.setTimeout(() => {
|
||||
lazy.log.error(`Background task named '${name}' timed out`);
|
||||
resolve(BackgroundTasksManager.EXIT_CODE.TIMEOUT);
|
||||
resolve(EXIT_CODE.TIMEOUT);
|
||||
}, timeoutSec * 1000)
|
||||
),
|
||||
taskModule.runBackgroundTask(commandLine),
|
||||
@ -224,7 +220,7 @@ class BackgroundTasksManager {
|
||||
);
|
||||
} catch (e) {
|
||||
lazy.log.error(`Backgroundtask named '${name}' threw exception`, e);
|
||||
exitCode = BackgroundTasksManager.EXIT_CODE.EXCEPTION;
|
||||
exitCode = EXIT_CODE.EXCEPTION;
|
||||
}
|
||||
} finally {
|
||||
addMarker("BackgroundTasksManager:AfterAwaitRunBackgroundTask");
|
||||
@ -254,7 +250,7 @@ class BackgroundTasksManager {
|
||||
* greater than 10 to allow for additional shared exit codes to be added here.
|
||||
* Exit codes should be between 0 and 127 to be safe across platforms.
|
||||
*/
|
||||
BackgroundTasksManager.EXIT_CODE = {
|
||||
export const EXIT_CODE = {
|
||||
/**
|
||||
* The task succeeded.
|
||||
*
|
@ -2,10 +2,6 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["BackgroundTasksTestUtils"];
|
||||
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
@ -32,7 +28,7 @@ function getFirefoxExecutableFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
var BackgroundTasksTestUtils = {
|
||||
export var BackgroundTasksTestUtils = {
|
||||
init(scope) {
|
||||
this.testScope = scope;
|
||||
},
|
@ -3,11 +3,7 @@
|
||||
* 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 = ["BackgroundTasksUtils"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -46,7 +42,7 @@ class CannotLockProfileError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
var BackgroundTasksUtils = {
|
||||
export var BackgroundTasksUtils = {
|
||||
// Manage our own default profile that can be overridden for testing. It's
|
||||
// easier to do this here rather than using the profile service itself.
|
||||
_defaultProfileInitialized: false,
|
@ -15,7 +15,7 @@ Classes = [
|
||||
'contract_ids': [
|
||||
'@mozilla.org/backgroundtasksmanager;1',
|
||||
],
|
||||
'jsm': 'resource://gre/modules/BackgroundTasksManager.jsm',
|
||||
'esModule': 'resource://gre/modules/BackgroundTasksManager.sys.mjs',
|
||||
'constructor': 'BackgroundTasksManager',
|
||||
'categories': {
|
||||
'command-line-handler': {
|
||||
|
@ -8,24 +8,23 @@ Support for background task mode is gated on the build flag `MOZ_BACKGROUNDTASKS
|
||||
|
||||
Background tasks are invoked with `--backgroundtask TASKNAME`. Tasks must be packaged at build time; the background task runtime looks for regular JSM modules in the following locations (in order):
|
||||
|
||||
1. (App-specific) `resource:///modules/backgroundtasks/BackgroundTask_TASKNAME.jsm`
|
||||
2. (Toolkit/general) `resource://gre/modules//backgroundtasks/BackgroundTask_TASKNAME.jsm`
|
||||
1. (App-specific) `resource:///modules/backgroundtasks/BackgroundTask_TASKNAME.sys.mjs`
|
||||
2. (Toolkit/general) `resource://gre/modules//backgroundtasks/BackgroundTask_TASKNAME.sys.mjs`
|
||||
|
||||
To add a new background task, add to your `moz.build` file a stanza like:
|
||||
|
||||
```python
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_TASKNAME.jsm",
|
||||
"BackgroundTask_TASKNAME.sys.mjs",
|
||||
]
|
||||
```
|
||||
|
||||
## Implementing a background task
|
||||
|
||||
In `BackgroundTask_TASKNAME.jsm`, define a function `runBackgroundTask` that returns a `Promise`. `runBackgroundTask` will be awaited and the integer value it resolves to will be used as the exit code of the `--backgroundtask TASKNAME` invocation. Optionally, `runBackgroundTask` can take an [`nsICommandLine` instance](https://searchfox.org/mozilla-central/source/toolkit/components/commandlines/nsICommandLine.idl) as a parameter. For example:
|
||||
In `BackgroundTask_TASKNAME.sys.mjs`, define a function `runBackgroundTask` that returns a `Promise`. `runBackgroundTask` will be awaited and the integer value it resolves to will be used as the exit code of the `--backgroundtask TASKNAME` invocation. Optionally, `runBackgroundTask` can take an [`nsICommandLine` instance](https://searchfox.org/mozilla-central/source/toolkit/components/commandlines/nsICommandLine.idl) as a parameter. For example:
|
||||
|
||||
```javascript
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
return Number.parseInt(commandLine.getArgument(0), 10);
|
||||
}
|
||||
```
|
||||
@ -42,7 +41,7 @@ The exit codes 2-4 have special meaning:
|
||||
* Exit code 3 (`EXIT_CODE.EXCEPTION`) means the background task invocation rejected with an exception.
|
||||
* Exit code 4 (`EXIT_CODE.TIMEOUT`) means that the background task timed out before it could complete.
|
||||
|
||||
See [`BackgroundTasksManager.EXIT_CODE`](https://searchfox.org/mozilla-central/source/toolkit/components/backgroundtasks/BackgroundTasksManager.jsm) for details.
|
||||
See [`EXIT_CODE`](https://searchfox.org/mozilla-central/source/toolkit/components/backgroundtasks/BackgroundTasksManager.sys.mjs) for details.
|
||||
|
||||
## Test-only background tasks
|
||||
|
||||
@ -50,7 +49,7 @@ There is special support for test-only background tasks. Add to your `moz.build
|
||||
|
||||
```python
|
||||
TESTING_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_TESTONLYTASKNAME.jsm",
|
||||
"BackgroundTask_TESTONLYTASKNAME.sys.mjs",
|
||||
]
|
||||
```
|
||||
|
||||
@ -86,7 +85,7 @@ Background tasks that are launched at shutdown (and that are not updating) do no
|
||||
gantt
|
||||
title Background tasks launched at Firefox shutdown
|
||||
dateFormat YYYY-MM-DD
|
||||
axisFormat
|
||||
axisFormat
|
||||
section Firefox
|
||||
firefox (version N) :2014-01-03, 3d
|
||||
updater :2014-01-06, 1d
|
||||
|
@ -35,8 +35,8 @@ XPIDL_SOURCES += [
|
||||
XPIDL_MODULE = "toolkit_backgroundtasks"
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"BackgroundTasksManager.jsm",
|
||||
"BackgroundTasksUtils.jsm",
|
||||
"BackgroundTasksManager.sys.mjs",
|
||||
"BackgroundTasksUtils.sys.mjs",
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
@ -44,10 +44,10 @@ EXTRA_JS_MODULES.backgroundtasks += [
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_exception.jsm",
|
||||
"BackgroundTask_failure.jsm",
|
||||
"BackgroundTask_message.jsm",
|
||||
"BackgroundTask_success.jsm",
|
||||
"BackgroundTask_exception.sys.mjs",
|
||||
"BackgroundTask_failure.sys.mjs",
|
||||
"BackgroundTask_message.sys.mjs",
|
||||
"BackgroundTask_success.sys.mjs",
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
@ -58,30 +58,30 @@ BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
|
||||
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
"BackgroundTasksTestUtils.jsm",
|
||||
"BackgroundTasksTestUtils.sys.mjs",
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES.backgroundtasks += [
|
||||
"tests/BackgroundTask_backgroundtask_specific_pref.jsm",
|
||||
"tests/BackgroundTask_crash.jsm",
|
||||
"tests/BackgroundTask_file_exists.jsm",
|
||||
"tests/BackgroundTask_jsdebugger.jsm",
|
||||
"tests/BackgroundTask_localization.jsm",
|
||||
"tests/BackgroundTask_not_ephemeral_profile.jsm",
|
||||
"tests/BackgroundTask_policies.jsm",
|
||||
"tests/BackgroundTask_profile_is_slim.jsm",
|
||||
"tests/BackgroundTask_shouldnotprocessupdates.jsm",
|
||||
"tests/BackgroundTask_shouldprocessupdates.jsm",
|
||||
"tests/BackgroundTask_timeout.jsm",
|
||||
"tests/BackgroundTask_unique_profile.jsm",
|
||||
"tests/BackgroundTask_update_sync_manager.jsm",
|
||||
"tests/BackgroundTask_wait.jsm",
|
||||
"tests/BackgroundTask_backgroundtask_specific_pref.sys.mjs",
|
||||
"tests/BackgroundTask_crash.sys.mjs",
|
||||
"tests/BackgroundTask_file_exists.sys.mjs",
|
||||
"tests/BackgroundTask_jsdebugger.sys.mjs",
|
||||
"tests/BackgroundTask_localization.sys.mjs",
|
||||
"tests/BackgroundTask_not_ephemeral_profile.sys.mjs",
|
||||
"tests/BackgroundTask_policies.sys.mjs",
|
||||
"tests/BackgroundTask_profile_is_slim.sys.mjs",
|
||||
"tests/BackgroundTask_shouldnotprocessupdates.sys.mjs",
|
||||
"tests/BackgroundTask_shouldprocessupdates.sys.mjs",
|
||||
"tests/BackgroundTask_timeout.sys.mjs",
|
||||
"tests/BackgroundTask_unique_profile.sys.mjs",
|
||||
"tests/BackgroundTask_update_sync_manager.sys.mjs",
|
||||
"tests/BackgroundTask_wait.sys.mjs",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_BUILD_APP"] == "browser":
|
||||
# ASRouter is Firefox-only.
|
||||
TESTING_JS_MODULES.backgroundtasks += [
|
||||
"tests/BackgroundTask_targeting.jsm",
|
||||
"tests/BackgroundTask_targeting.sys.mjs",
|
||||
]
|
||||
|
||||
FINAL_TARGET_FILES.browser.defaults.backgroundtasks += [
|
||||
|
@ -3,9 +3,7 @@
|
||||
* 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) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let pref = commandLine.length
|
||||
? commandLine.getArgument(0)
|
||||
: "test.backgroundtask_specific_pref.exitCode";
|
@ -3,9 +3,7 @@
|
||||
* 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) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
// This task depends on `CrashTestUtils.jsm` and requires the
|
||||
// sibling `testcrasher` library to be in the current working
|
||||
// directory. Fail right away if we can't find the module or the
|
@ -3,17 +3,13 @@
|
||||
* 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"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
/**
|
||||
* Return 0 (success) if the given absolute file path exists, 11
|
||||
* (failure) otherwise.
|
||||
*/
|
||||
function runBackgroundTask(commandLine) {
|
||||
export function runBackgroundTask(commandLine) {
|
||||
let path = commandLine.getArgument(0);
|
||||
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(path);
|
@ -3,8 +3,6 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This task is intended to be interrupted by the JS debugger in tests.
|
||||
*
|
||||
@ -13,9 +11,7 @@
|
||||
* code to exit code 0.
|
||||
*/
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
function runBackgroundTask(commandLine) {
|
||||
export function runBackgroundTask(commandLine) {
|
||||
// In the future, will be modifed by the JS debugger (to 0, success).
|
||||
var exposedExitCode = 0;
|
||||
|
@ -3,17 +3,13 @@
|
||||
* 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"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
/**
|
||||
* Return 0 (success) if in the given resource file, the given string
|
||||
* identifier has the given string value, 11 (failure) otherwise.
|
||||
*/
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let resource = commandLine.getArgument(0);
|
||||
let id = commandLine.getArgument(1);
|
||||
let expected = commandLine.getArgument(2);
|
@ -3,9 +3,7 @@
|
||||
* 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) {
|
||||
export 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.
|
@ -3,16 +3,12 @@
|
||||
* 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"];
|
||||
|
||||
const { Checker } = ChromeUtils.import(
|
||||
"resource://gre/modules/UpdateService.jsm"
|
||||
);
|
||||
const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/EnterprisePolicyTesting.sys.mjs"
|
||||
);
|
||||
import { EnterprisePolicyTesting } from "resource://testing-common/EnterprisePolicyTesting.sys.mjs";
|
||||
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let filePath = commandLine.getArgument(0);
|
||||
await EnterprisePolicyTesting.setupPolicyEngineWithJson(filePath);
|
||||
|
@ -7,15 +7,9 @@
|
||||
// the temporary profile created during background tasks. This will
|
||||
// be a dumping ground for functionality that writes to the profile.
|
||||
|
||||
"use strict";
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
console.error("runBackgroundTask: is_profile_slim");
|
||||
|
||||
// For now, just verify contents of profile after a network request.
|
@ -3,13 +3,11 @@
|
||||
* 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) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
// Exact same behaviour as `shouldprocessupdates`, but with a task name that
|
||||
// is not recognized as a task that should process updates.
|
||||
const taskModule = ChromeUtils.import(
|
||||
"resource://testing-common/backgroundtasks/BackgroundTask_shouldprocessupdates.jsm"
|
||||
const taskModule = ChromeUtils.importESModule(
|
||||
"resource://testing-common/backgroundtasks/BackgroundTask_shouldprocessupdates.sys.mjs"
|
||||
);
|
||||
return taskModule.runBackgroundTask(commandLine);
|
||||
}
|
@ -3,9 +3,7 @@
|
||||
* 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) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
var env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
@ -3,11 +3,7 @@
|
||||
* 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/. */
|
||||
|
||||
const EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
const { ASRouterTargeting } = ChromeUtils.import(
|
||||
"resource://activity-stream/lib/ASRouterTargeting.jsm"
|
||||
@ -26,7 +22,7 @@ const EXCLUDED_NAMES = [
|
||||
* Return 0 (success) if all targeting getters succeed, 11 (failure)
|
||||
* otherwise.
|
||||
*/
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let exitCode = EXIT_CODE.SUCCESS;
|
||||
|
||||
// Can't use `ASRouterTargeting.getEnvironmentSnapshot`, since that
|
@ -3,18 +3,15 @@
|
||||
* 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 = ["backgroundTaskTimeoutSec", "runBackgroundTask"];
|
||||
import { EXIT_CODE } from "resource://gre/modules/BackgroundTasksManager.sys.mjs";
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
// Time out in just a single second. The task is set up to run for 5 minutes,
|
||||
// so it should always time out.
|
||||
const backgroundTaskTimeoutSec = 1;
|
||||
export const backgroundTaskTimeoutSec = 1;
|
||||
|
||||
async function runBackgroundTask() {
|
||||
export async function runBackgroundTask() {
|
||||
await new Promise(resolve => {
|
||||
const fiveMinutesInMs = 5 * 60 * 1000;
|
||||
setTimeout(resolve, fiveMinutesInMs);
|
@ -3,15 +3,11 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
|
||||
const { Subprocess } = ChromeUtils.import(
|
||||
"resource://gre/modules/Subprocess.jsm"
|
||||
);
|
||||
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let sentinel = commandLine.getArgument(0);
|
||||
let count =
|
||||
commandLine.length > 1
|
@ -3,9 +3,7 @@
|
||||
* 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) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let syncManager = Cc["@mozilla.org/updates/update-sync-manager;1"].getService(
|
||||
Ci.nsIUpdateSyncManager
|
||||
);
|
@ -3,11 +3,9 @@
|
||||
* 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"];
|
||||
|
||||
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
function runBackgroundTask(commandLine) {
|
||||
export function runBackgroundTask(commandLine) {
|
||||
let delay = 10;
|
||||
if (commandLine.length) {
|
||||
delay = Number.parseInt(commandLine.getArgument(0));
|
@ -31,7 +31,7 @@ const backgroundtaskPhases = {
|
||||
modules: [
|
||||
"resource://gre/modules/AppConstants.jsm",
|
||||
"resource://gre/modules/AsyncShutdown.jsm",
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm",
|
||||
"resource://gre/modules/BackgroundTasksManager.sys.mjs",
|
||||
"resource://gre/modules/Console.jsm",
|
||||
"resource://gre/modules/EnterprisePolicies.sys.mjs",
|
||||
"resource://gre/modules/EnterprisePoliciesParent.sys.mjs",
|
||||
@ -120,17 +120,15 @@ const backgroundtaskPhases = {
|
||||
allowlist: {
|
||||
modules: [
|
||||
// We have a profile marker for this, even though it failed to load!
|
||||
"resource:///modules/backgroundtasks/BackgroundTask_wait.jsm",
|
||||
"resource:///modules/backgroundtasks/BackgroundTask_wait.sys.mjs",
|
||||
|
||||
"resource://gre/modules/ConsoleAPIStorage.jsm",
|
||||
"resource://gre/modules/Timer.jsm",
|
||||
|
||||
// We have a profile marker for this, even though it failed to load!
|
||||
"resource://gre/modules/backgroundtasks/BackgroundTask_wait.jsm",
|
||||
"resource://gre/modules/backgroundtasks/BackgroundTask_wait.sys.mjs",
|
||||
|
||||
"resource://testing-common/backgroundtasks/BackgroundTask_wait.jsm",
|
||||
"resource://testing-common/backgroundtasks/BackgroundTask_wait.sys.mjs",
|
||||
],
|
||||
services: ["@mozilla.org/consoleAPI-storage;1"],
|
||||
},
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { BackgroundTasksTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/BackgroundTasksTestUtils.jsm"
|
||||
const { BackgroundTasksTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/BackgroundTasksTestUtils.sys.mjs"
|
||||
);
|
||||
BackgroundTasksTestUtils.init(this);
|
||||
const do_backgroundtask = BackgroundTasksTestUtils.do_backgroundtask.bind(
|
||||
|
@ -10,8 +10,8 @@ const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
|
||||
const { BackgroundTasksTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/BackgroundTasksTestUtils.jsm"
|
||||
const { BackgroundTasksTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/BackgroundTasksTestUtils.sys.mjs"
|
||||
);
|
||||
BackgroundTasksTestUtils.init(this);
|
||||
const do_backgroundtask = BackgroundTasksTestUtils.do_backgroundtask.bind(
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
// This test exercises functionality and also ensures the exit codes,
|
||||
// which are a public API, do not change over time.
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
const { EXIT_CODE } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/BackgroundTasksManager.sys.mjs"
|
||||
);
|
||||
|
||||
add_task(async function test_success() {
|
||||
let exitCode = await do_backgroundtask("success");
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
).BackgroundTasksManager;
|
||||
const { EXIT_CODE } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/BackgroundTasksManager.sys.mjs"
|
||||
);
|
||||
|
||||
add_task(async function test_targeting() {
|
||||
// The task itself fails if any targeting getter fails.
|
||||
|
@ -4,8 +4,8 @@
|
||||
* 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/. */
|
||||
|
||||
const { BackgroundTasksUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksUtils.jsm"
|
||||
const { BackgroundTasksUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/BackgroundTasksUtils.sys.mjs"
|
||||
);
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
|
@ -127,7 +127,7 @@ EXTRA_JS_MODULES += [
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"pings/BackgroundTask_pingsender.jsm",
|
||||
"pings/BackgroundTask_pingsender.sys.mjs",
|
||||
]
|
||||
|
||||
if CONFIG["OS_ARCH"] == "WINNT":
|
||||
|
@ -3,14 +3,11 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { sendStandalonePing } = ChromeUtils.import(
|
||||
"resource://gre/modules/TelemetrySend.jsm"
|
||||
);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let sends = [];
|
||||
for (let i = 0; i < commandLine.length; i += 2) {
|
||||
sends.push(
|
@ -3,21 +3,12 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"backgroundTaskTimeoutSec",
|
||||
"maybeSubmitBackgroundUpdatePing",
|
||||
"runBackgroundTask",
|
||||
];
|
||||
|
||||
const { BackgroundUpdate } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundUpdate.jsm"
|
||||
);
|
||||
const { EXIT_CODE } = BackgroundUpdate;
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
@ -25,13 +16,13 @@ const { AppConstants } = ChromeUtils.import(
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
BackgroundTasksUtils: "resource://gre/modules/BackgroundTasksUtils.sys.mjs",
|
||||
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
||||
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
AppUpdater: "resource:///modules/AppUpdater.jsm",
|
||||
BackgroundTasksUtils: "resource://gre/modules/BackgroundTasksUtils.jsm",
|
||||
ExtensionUtils: "resource://gre/modules/ExtensionUtils.jsm",
|
||||
});
|
||||
|
||||
@ -54,7 +45,7 @@ XPCOMUtils.defineLazyGetter(lazy, "log", () => {
|
||||
return new ConsoleAPI(consoleOptions);
|
||||
});
|
||||
|
||||
const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
|
||||
export const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
|
||||
"app.update.background.timeoutSec",
|
||||
10 * 60
|
||||
);
|
||||
@ -189,7 +180,7 @@ async function _attemptBackgroundUpdate() {
|
||||
* profile. Note that the Firefox policy mechanism will manage this pref, locking it to particular
|
||||
* values as appropriate.
|
||||
*/
|
||||
async function maybeSubmitBackgroundUpdatePing() {
|
||||
export async function maybeSubmitBackgroundUpdatePing() {
|
||||
let SLUG = "maybeSubmitBackgroundUpdatePing";
|
||||
|
||||
// It should be possible to turn AUSTLMY data into Glean data, but mapping histograms isn't
|
||||
@ -200,7 +191,7 @@ async function maybeSubmitBackgroundUpdatePing() {
|
||||
lazy.log.info(`${SLUG}: submitted "background-update" ping`);
|
||||
}
|
||||
|
||||
async function runBackgroundTask(commandLine) {
|
||||
export async function runBackgroundTask(commandLine) {
|
||||
let SLUG = "runBackgroundTask";
|
||||
lazy.log.error(`${SLUG}: backgroundupdate`);
|
||||
|
@ -10,7 +10,7 @@ var EXPORTED_SYMBOLS = ["BackgroundUpdate"];
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
const { BackgroundTasksManager } = ChromeUtils.import(
|
||||
const { EXIT_CODE } = ChromeUtils.import(
|
||||
"resource://gre/modules/BackgroundTasksManager.jsm"
|
||||
);
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
@ -708,7 +708,7 @@ BackgroundUpdate.REASON = {
|
||||
* more general errors reading from the default profile.
|
||||
*/
|
||||
BackgroundUpdate.EXIT_CODE = {
|
||||
...BackgroundTasksManager.EXIT_CODE,
|
||||
...EXIT_CODE,
|
||||
// We clone the other exit codes simply so we can use one object for all the codes.
|
||||
DEFAULT_PROFILE_DOES_NOT_EXIST: 11,
|
||||
DEFAULT_PROFILE_CANNOT_BE_LOCKED: 12,
|
||||
|
@ -44,7 +44,7 @@ if (
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.backgroundtasks += [
|
||||
"BackgroundTask_backgroundupdate.jsm",
|
||||
"BackgroundTask_backgroundupdate.sys.mjs",
|
||||
]
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
|
Loading…
x
Reference in New Issue
Block a user