fune/toolkit/components/backgroundtasks/tests/BackgroundTask_wait.jsm
Nick Alexander c72bc82a74 Bug 1667276 - Post: Add test limiting the XPCOM graph of the no-op wait background task. r=mossop
This establishes a high water mark for code loaded (even after a short
delay) by a background task that does nothing.

Code loaded here means:

1) Chrome JSMs imported using `ChromeUtils.import`;

2) XPCOM services, generally long-lived, loaded using `do_getService`
   or `Services.*` or an equivalent;

3) XPCOM components defined in JavaScript and loaded via
   `chrome.manifest` entries.

At this time background tasks do not load any of category 3.  The
distinction is made because they are reported separately by Gecko.

This test is browser-chrome to make it easy/possible to work with
packaged builds.

Differential Revision: https://phabricator.services.mozilla.com/D98095
2021-01-27 22:54:27 +00:00

19 lines
668 B
JavaScript

/* -*- 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"];
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
function runBackgroundTask(commandLine) {
let delay = 10;
if (commandLine.length) {
delay = Number.parseInt(commandLine.getArgument(0));
}
console.error(`runBackgroundTask: wait ${delay} seconds`);
return new Promise(resolve => setTimeout(resolve, delay * 1000));
}