Commit Graph

101 Commits

Author SHA1 Message Date
Nick Alexander
f24cb48487 Bug 1757229 - Ensure Telemetry::CanRecordExtended() is false in background tasks. r=janerik
Differential Revision: https://phabricator.services.mozilla.com/D141291
2022-03-17 15:45:56 +00:00
Nick Alexander
201953d2d2 Bug 1679443 - Add test ensuring profiles created by background tasks are (and remain) "slim". r=bytesized
There are a few ways that we could test this.  We could use the
profiler and "File IO" markers, a la
https://searchfox.org/mozilla-central/source/browser/base/content/test/performance/browser_startup_content_mainthreadio.js.
This would profile content that is transient, which could be good or
bad -- temporary files for atomic writes would show up for example.
But in fact there are profile contents created after the profiler is
shut down (including `Telemetry.ShutdownTime.txt`), so this approach
isn't sufficient.

Therefore we do the simpler thing: we simply don't remove the
temporary profile directory after the background task exits.

Differential Revision: https://phabricator.services.mozilla.com/D139909
2022-03-16 17:18:45 +00:00
Nick Alexander
5c6479a485 Bug 1686344 - Add test for --backgroundtask --jsdebugger --wait-for-jsdebugger. r=devtools-reviewers,jdescottes
This version is as simple as I can make it.  It simply expects the JS
debugger to stop on the breakpoint added automatically by the
backgroundtask debugger command line processing (using
`setBreakpointOnLoad`) and disconnects, expecting the task to continue
execution and exit with exit code 0.

In the future, we'd like to interact with the task environment, for example to:

1. stop on the automatic breakpoint
2. continue
3. stop on a `debugger;`
4. set the task's exit code from a failure code to exit code 0
5. continue
6. verifies the tasks's exit code is 0.

Sadly my attempts to do this fail intermittently in automation.

Differential Revision: https://phabricator.services.mozilla.com/D139156
2022-03-03 03:38:40 +00:00
Nick Alexander
5e08f60944 Bug 1686344 - Support --backgroundtask --jsdebugger (and --wait-for-jsdebugger). r=mossop,jdescottes
Background task mode is roughly equivalent to `xpcshell`, but inside
the regular browser startup flow.  There is no browser window (no
`Window` at all) and there should be no content processes.  It's
sufficient to treat it like `xpcshell`, with its own stripped-down
actor and a few tweaks to the integration points.

The structural changes in this commit keep `--backgroundtask` mode
slim in the regular case when the Devtools are *not* requested.  This
is reflected in the small changes needed to the
`browser_xpcom_graph_wait.js` test: loading the Devtools
unconditionally causes a huge amount of code to be loaded.  In order
to load the Devtools framework conditionally, we check for
Devtools-specific command line flags and delegate to Devtools when
appropriate.  In order to check the command line flags, we turn the
`BackgroundTasksManager` into an XPCOM service, which allows it to be
instantiated by XPCOM in order to handle the command line.

One final note: this leaves two XPCOM components, "backgroundtasks"
and "backgroundtasksmanager".  Why not combine them?  This is
technically possible but not attractive: we really do want a natural
place for native/C++ code ("backgroundtasks") and JavaScript code
("backgroundtasksmanager").

Differential Revision: https://phabricator.services.mozilla.com/D129771
2022-03-03 03:38:39 +00:00
Nick Alexander
889b3e087d Bug 1753718 - Add test(s) ensuring that a running background task does not prevent application updates. r=application-update-reviewers,bytesized
Differential Revision: https://phabricator.services.mozilla.com/D138085
2022-02-10 20:12:26 +00:00
Nick Alexander
218907f4b0 Bug 1753718 - Pre: Prefix child process stdout lines with PID>; add stdout line callback. r=bytesized
We may get multiple lines or incomplete lines from the pipe, so we
need to split the data and keep the leftover.  This makes debugging a
little more pleasant and allows for the consumer to react to stdout as
it is read.

Differential Revision: https://phabricator.services.mozilla.com/D138222
2022-02-10 20:12:26 +00:00
Chris Peterson
c0ef096bd3 Bug 1744425 - xre: Use nsID::GeneratorUUIDInPlace() instead of the nsUUIDGenerator service. r=mossop
This change is needed to avoid toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js test failures where the nsUUIDGenerator service was loaded during ASan test runs but not non-ASan test runs (due to differences in temp profile directory paths). With this change, the nsUUIDGenerator service is no longer needed in BackgroundTasks.

Using nsID::GenerateUUIDInPlace() also avoids the overhead of instantiating the nsUUIDGenerator service.

Depends on D136992

Differential Revision: https://phabricator.services.mozilla.com/D136993
2022-02-03 04:39:35 +00:00
Mike Kaply
d3e92e4aab Bug 1745022 - Add better debug information for policies.json r=mstriemer
Differential Revision: https://phabricator.services.mozilla.com/D133761
2021-12-17 19:11:14 +00:00
Jens Stutte
b837d77418 Bug 1707963: Remove permission manager from browser_xpcom_graph_wait.js. r=mossop
Once we allow lazy initialization for the permission manager, we do not launch it at startup in any kind of process. We thus need to update the allowlist of this test and remove the permission manager and other (networking) modules it started.

Differential Revision: https://phabricator.services.mozilla.com/D133655
2021-12-14 18:39:42 +00:00
Nick Alexander
c41abc5d3f Bug 1737117 - Only process updates only for --backgroundtask backgroundupdate. r=bytesized
The aim is to avoid background tasks causing unexpected updates, as
happened when we tried to migrate `pingsender` to a Gecko background
task in Bug 1734262.  This commit makes it so that we only process
updates for the `backgroundupdate` task (and the test-only
`shouldprocessupdates` task).

Differential Revision: https://phabricator.services.mozilla.com/D133557
2021-12-14 07:00:59 +00:00
Nick Alexander
3c9849fc72 Bug 1737117 - Pre: Add a reason to "should process updates at startup" logic. r=bytesized
I've elected to rename the function from `Should...` to
`ShouldNot...`, but not to rename the various test files.  The
functionality under test is both "should" and "should not", so I think
the churn of renaming is not justified.

This rearranges the deck chairs to accommodate testing the new
functionality in the next commit.

Differential Revision: https://phabricator.services.mozilla.com/D133556
2021-12-14 07:00:59 +00:00
Butkovits Atila
1ba2cc1c80 Backed out 2 changesets (bug 1737117) for causing bustages at nsAppRunner.cpp. CLOSED TREE
Backed out changeset b78709bc0d0c (bug 1737117)
Backed out changeset b3be1a6a5e3f (bug 1737117)
2021-12-14 06:30:49 +02:00
Nick Alexander
8aaf80be99 Bug 1737117 - Only process updates only for --backgroundtask backgroundupdate. r=bytesized
The aim is to avoid background tasks causing unexpected updates, as
happened when we tried to migrate `pingsender` to a Gecko background
task in Bug 1734262.  This commit makes it so that we only process
updates for the `backgroundupdate` task (and the test-only
`shouldprocessupdates` task).

Differential Revision: https://phabricator.services.mozilla.com/D133557
2021-12-14 03:44:14 +00:00
Nick Alexander
6f9134c94a Bug 1737117 - Pre: Add a reason to "should process updates at startup" logic. r=bytesized
I've elected to rename the function from `Should...` to
`ShouldNot...`, but not to rename the various test files.  The
functionality under test is both "should" and "should not", so I think
the churn of renaming is not justified.

This rearranges the deck chairs to accommodate testing the new
functionality in the next commit.

Differential Revision: https://phabricator.services.mozilla.com/D133556
2021-12-14 03:44:14 +00:00
Mark Banner
1817e82737 Bug 1602940 - Automated replacements to use Services.uuid. r=Gijs,necko-reviewers,preferences-reviewers,kershaw
Depends on D124391

Differential Revision: https://phabricator.services.mozilla.com/D124392
2021-09-06 09:53:52 +00:00
Youhai Li
c53b73c5dd Bug 1672577 - Removed expired probe NUMBER_OF_PROFILES, r=jaws,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D116735
2021-06-21 14:53:09 +00:00
Kirk Steuber
0ac13e7643 Bug 1708752 - Add testing for background task timeout r=nalexander
Depends on D115399

Differential Revision: https://phabricator.services.mozilla.com/D115524
2021-05-20 17:38:05 +00:00
Nick Alexander
5573b7b2cf Bug 1704146 - Pre: Extract shared BackgroundTasksTestUtils.jsm. r=bytesized,application-update-reviewers
We duplicate these functions in two head.js files right now, and I'm
loathe to add a third, so let's extract a shared test module.

Differential Revision: https://phabricator.services.mozilla.com/D111527
2021-04-14 18:21:55 +00:00
Adam Gashlin
0c010e42ac Bug 1697955 - Resolve the install path used for sync manager locks. r=application-update-reviewers,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D110722
2021-04-05 22:32:39 +00:00
Nick Alexander
6ecacc7b3c Bug 1700850 - Part 2: Remove temporary background profile directories very late. r=dthayer
When `--backgroundtask TASK` invocations exit, they try to remove
their temporary profile directory.  This mostly works, except there
are some very late writes to the profile directory including
`Telemetry.ShutdownTime.txt` and the `security_state` directory.  This
commit accommodates by moving the profile directory removal even
later.  It might be possible to instead avoid these very late writes,
but that is hard in general, and is more likely to depend on the exact
code invoked by the background task itself.

Differential Revision: https://phabricator.services.mozilla.com/D110472
2021-04-05 04:16:37 +00:00
Nick Alexander
7ec1735b47 Bug 1700850 - Part 1: Make temporary background profiles per-installation and unique. r=bytesized,mossop
Differential Revision: https://phabricator.services.mozilla.com/D110310
2021-04-05 04:16:37 +00:00
Nick Alexander
8e98961a80 Bug 1689519 - Pre: Add BackgroundTasksManager.EXIT_CODE. r=bytesized
Differential Revision: https://phabricator.services.mozilla.com/D108661
2021-03-27 20:43:23 +00:00
Adam Gashlin
185e32f6c3 Bug 1696772 - Don't use FILE_FLAG_DELETE_ON_CLOSE for multi-instance locks. r=nalexander,application-update-reviewers.
FILE_FLAG_DELETE_ON_CLOSE had the wrong semantics, rendering the lock
file unusable after it had been closed once.

Delete the lock file in the uninstaller as a simple alternative (given that
the lock file is not in a temporary location on Windows).

For a test I returned to the older form of
test_backgroundtask_update_sync_manager which initially exposed the issue:
It expects the background task to be able to detect the xpcshell instance
after running resetLock, which failed before this fix.
I also extended the original updateSyncManager test to run the second
copy twice, which also catches the issue.

Differential Revision: https://phabricator.services.mozilla.com/D109565
2021-03-24 20:36:06 +00:00
Nick Alexander
0f35c1060f Bug 1694515 - Part 3: Add BackgroundTasksUtils method for reading Telemetry client ID. r=bytesized,chutten
This will be used from the `backgroundupdate` task to fish the default
profile's Telemetry client ID in order to correlate the task's Glean
ping with regular main pings.

Differential Revision: https://phabricator.services.mozilla.com/D107712
2021-03-12 04:08:42 +00:00
Nick Alexander
783876abd5 Bug 1694515 - Part 2: Add BackgroundTasksUtils module for locking profiles and reading prefs. r=bytesized,mossop
Differential Revision: https://phabricator.services.mozilla.com/D107711
2021-03-12 04:08:42 +00:00
Nick Alexander
04c3e38216 Bug 1694515 - Pre: Extract setupProfileService test helper. r=bytesized
Differential Revision: https://phabricator.services.mozilla.com/D107743
2021-03-12 04:08:41 +00:00
Nick Alexander
62466cac18 Bug 1695797 - In background task mode, only process updates if we're the sole instance running. r=mhowell,application-update-reviewers,dthayer,bytesized
This commit does three main things:

1) It allows to configure the global singleton `nsUpdateSyncManager`
with an `nsIFile` rather than having it use the ambient XPCOM
directory service.  This allows to initialize the
`nsUpdateSyncManager` very early: before processing updates and long
before XPCOM is initialized.  This in turn allows us to determine if
other instances early enough to skip processing updates when
appropriate.

When this initialization path is followed, i.e., in Firefox but not
`xpcshell`, the `xpcom-startup` notification will be received but no
action taken, since the singleton will already exist.

There is a classic time-of-check, time-of-use race window in this
implementation: an instance may be launched immediately after we check
for other instances.  In practice this will result in behaviour that
is alreay possible: two independent instances both processing updates.
It is expected that the updater itself will exclude one of the
instances using its existing mutex.

2) It updates an existing background task test to use an explicit
`nsIFile` rather than the existing directory service method.  This
exercises the newer API.  There are other tests that might benefit,
but there's no harm in remaining with the previous approach, since
both are required.

3) It adds a new background task test to verify that update processing
is skipped if we're not the sole instance running.

Differential Revision: https://phabricator.services.mozilla.com/D106994
2021-03-06 05:40:39 +00:00
Nick Alexander
3938566c52 Bug 1686997 - Add test ensuring locked (temporary) profile exits background task with non-zero exit code. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D101953
2021-03-06 05:39:32 +00:00
Brindusan Cristian
83377693d5 Backed out changeset 8a6f82dc06a9 (bug 1695797) for xpcshell failures in test_backgroundtask_update_sync_manager.js. CLOSED TREE 2021-03-05 00:40:39 +02:00
Nick Alexander
7c8fba47f4 Bug 1695797 - In background task mode, only process updates if we're the sole instance running. r=mhowell,application-update-reviewers,dthayer,bytesized
This commit does three main things:

1) It allows to configure the global singleton `nsUpdateSyncManager`
    with an `nsIFile` rather than having it use the ambient XPCOM
    directory service.  This allows to initialize the
    `nsUpdateSyncManager` very early: before processing updates and long
    before XPCOM is initialized.  This in turn allows us to determine if
    other instances early enough to skip processing updates when
    appropriate.

    When this initialization path is followed, i.e., in Firefox but not
    `xpcshell`, the `xpcom-startup` notification will be received but no
    action taken, since the singleton will already exist.

    There is a classic time-of-check, time-of-use race window in this
    implementation: an instance may be launched immediately after we check
    for other instances.  In practice this will result in behaviour that
    is alreay possible: two independent instances both processing updates.
    It is expected that the updater itself will exclude one of the
    instances using its existing mutex.

    To avoid the race, we could take the exclusive multi-instance lock
    ourselves, but that is strictly more complicated.

2) It updates an existing background task test to use an explicit
    `nsIFile` rather than the existing directory service method.  This
    exercises the newer API.  There are other tests that might benefit,
    but there's no harm in remaining with the previous approach, since
    both are required.

3) It adds a new background task test to verify that update processing
    is skipped if we're not the sole instance running.

Differential Revision: https://phabricator.services.mozilla.com/D106994
2021-03-04 17:30:16 +00:00
Mihai Alexandru Michis
444dd08009 Backed out changeset f36b4c0c09c9 (bug 1686997) for causing xpcshell timeouts in test_backgroundtask_locked_profile.js
CLOSED TREE
2021-02-03 00:22:20 +02:00
Nick Alexander
c9eaf7b102 Bug 1687009 - Add test ensuring sync update manager works in background tasks. r=mossop,mhowell
Differential Revision: https://phabricator.services.mozilla.com/D101954
2021-02-02 19:42:44 +00:00
Nick Alexander
b3e404a0c8 Bug 1686997 - Add test ensuring locked (temporary) profile exits background task with non-zero exit code. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D101953
2021-02-02 19:36:02 +00:00
Nick Alexander
aec940b28f Bug 1682069 - Add test ensuring policies engine works for background tasks. r=mossop,mkaply
I've tested this explicitly with `AppUpdateURL` because that's the
policy-controlled value we care about for the first use case for
background tasks, namely the background update agent.

Differential Revision: https://phabricator.services.mozilla.com/D99846
2021-01-27 22:54:37 +00:00
Nick Alexander
cebc69aa7d Bug 1679440 - Add test ensuring crash reporter works for background tasks. r=mossop,gsvelto
This adds a test to ensure that crash reporting works inside of
`application --backgroundtask ...` invocations.  A test-only `crash`
task is added that uses `CrashTestUtils.jsm` to trigger a crash.  The
`xpcshell` harness invokes that background task and processes any
minidump and extras just as it does for existing `xpcshell`
subprocesses.

The test is homed in `toolkit/crashreporter`, rather than in
`toolkit/components/backgroundtasks`, because there is special
handling for `CrashTestUtils.jsm` and the `testcrasher` library.  It's
probably possible to make that infrastructure usable from multiple
locations but it seems low value.

Differential Revision: https://phabricator.services.mozilla.com/D98096
2021-01-27 22:54:35 +00:00
Nick Alexander
0d07f845e9 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
Nick Alexander
e34bcaa858 Bug 1667276 - Part 3: Load a custom prefs file when running a background task. r=mossop,KrisWright
There are some complications here to handle unpackaged and packaged
builds.  In addition, there could be a difference between App prefs
and GRE prefs.  Since the underlying backgroundtasks code is built as
part of Gecko (i.e., `toolkit/...` rather than `browser/...`) I have
favoured GRE prefs.  I think, however, that what is written will work
for App-specific prefs, but I'm not concerned with that detail at this
time.

This also add tests for backgroundtask-specific prefs, which are
structured as both xpcshell and mochitest-chrome tests because
locally, the former tests unpackaged builds and the latter can
accommodate testing packaged builds.  We could use mochitest-chrome
for both, but this has been pleasant to work with locally.

Differential Revision: https://phabricator.services.mozilla.com/D97510
2021-01-27 22:54:25 +00:00
Nick Alexander
fb6e71f85d Bug 1667276 - Part 2: Add BackgroundTasksManager to invoke task defined in JS. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D97512
2021-01-27 22:54:17 +00:00
Butkovits Atila
e59146095f Backed out 8 changesets (bug 1679440, bug 1682069, bug 1667276) for causing failure on test_crash_backgroundtask_moz_crash.js. CLOSED TREE
Backed out changeset f06504e3219f (bug 1682069)
Backed out changeset 4d325f68ea24 (bug 1679440)
Backed out changeset 9ab334e527a5 (bug 1667276)
Backed out changeset 1c8d51d2c90f (bug 1667276)
Backed out changeset 8d6f10d83c6b (bug 1667276)
Backed out changeset 62488ec634f9 (bug 1667276)
Backed out changeset 1dcb2d1be264 (bug 1667276)
Backed out changeset c673fff5bd85 (bug 1667276)
2021-01-27 22:17:17 +02:00
Nick Alexander
88c0b48272 Bug 1682069 - Add test ensuring policies engine works for background tasks. r=mossop,mkaply
I've tested this explicitly with `AppUpdateURL` because that's the
policy-controlled value we care about for the first use case for
background tasks, namely the background update agent.

Differential Revision: https://phabricator.services.mozilla.com/D99846
2021-01-26 21:37:49 +00:00
Nick Alexander
04774bbbed Bug 1679440 - Add test ensuring crash reporter works for background tasks. r=mossop,gsvelto
This adds a test to ensure that crash reporting works inside of
`application --backgroundtask ...` invocations.  A test-only `crash`
task is added that uses `CrashTestUtils.jsm` to trigger a crash.  The
`xpcshell` harness invokes that background task and processes any
minidump and extras just as it does for existing `xpcshell`
subprocesses.

The test is homed in `toolkit/crashreporter`, rather than in
`toolkit/components/backgroundtasks`, because there is special
handling for `CrashTestUtils.jsm` and the `testcrasher` library.  It's
probably possible to make that infrastructure usable from multiple
locations but it seems low value.

Differential Revision: https://phabricator.services.mozilla.com/D98096
2021-01-26 21:37:42 +00:00
Nick Alexander
94f6de1c6b 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-26 21:37:39 +00:00
Nick Alexander
e0aaf77718 Bug 1667276 - Part 3: Load a custom prefs file when running a background task. r=mossop,KrisWright
There are some complications here to handle unpackaged and packaged
builds.  In addition, there could be a difference between App prefs
and GRE prefs.  Since the underlying backgroundtasks code is built as
part of Gecko (i.e., `toolkit/...` rather than `browser/...`) I have
favoured GRE prefs.  I think, however, that what is written will work
for App-specific prefs, but I'm not concerned with that detail at this
time.

This also add tests for backgroundtask-specific prefs, which are
structured as both xpcshell and mochitest-chrome tests because
locally, the former tests unpackaged builds and the latter can
accommodate testing packaged builds.  We could use mochitest-chrome
for both, but this has been pleasant to work with locally.

Differential Revision: https://phabricator.services.mozilla.com/D97510
2021-01-27 18:10:33 +00:00
Nick Alexander
bd3bf6cb93 Bug 1667276 - Part 2: Add BackgroundTasksManager to invoke task defined in JS. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D97512
2021-01-27 18:10:15 +00:00
Csoregi Natalia
5459103578 Backed out 8 changesets (bug 1679440, bug 1682069, bug 1667276) for causing failures on browser_all_files_referenced.js. CLOSED TREE
Backed out changeset f1a65c9b3ca2 (bug 1682069)
Backed out changeset 310d2116faf7 (bug 1679440)
Backed out changeset f970ef0897cd (bug 1667276)
Backed out changeset 38c20196aabc (bug 1667276)
Backed out changeset 60c2f2dbc676 (bug 1667276)
Backed out changeset cf52687c4433 (bug 1667276)
Backed out changeset 74580a0f2633 (bug 1667276)
Backed out changeset ab6f830f6e75 (bug 1667276)
2021-01-26 06:49:04 +02:00
Nick Alexander
85216c2703 Bug 1682069 - Add test ensuring policies engine works for background tasks. r=mossop,mkaply
I've tested this explicitly with `AppUpdateURL` because that's the
policy-controlled value we care about for the first use case for
background tasks, namely the background update agent.

Differential Revision: https://phabricator.services.mozilla.com/D99846
2021-01-25 23:45:32 +00:00
Nick Alexander
13a2d260c0 Bug 1679440 - Add test ensuring crash reporter works for background tasks. r=mossop,gsvelto
This adds a test to ensure that crash reporting works inside of
`application --backgroundtask ...` invocations.  A test-only `crash`
task is added that uses `CrashTestUtils.jsm` to trigger a crash.  The
`xpcshell` harness invokes that background task and processes any
minidump and extras just as it does for existing `xpcshell`
subprocesses.

The test is homed in `toolkit/crashreporter`, rather than in
`toolkit/components/backgroundtasks`, because there is special
handling for `CrashTestUtils.jsm` and the `testcrasher` library.  It's
probably possible to make that infrastructure usable from multiple
locations but it seems low value.

Differential Revision: https://phabricator.services.mozilla.com/D98096
2021-01-25 23:45:29 +00:00
Nick Alexander
4cceada07e 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-25 23:49:18 +00:00
Nick Alexander
2c930d271f Bug 1667276 - Part 3: Load a custom prefs file when running a background task. r=mossop,KrisWright
There are some complications here to handle unpackaged and packaged
builds.  In addition, there could be a difference between App prefs
and GRE prefs.  Since the underlying backgroundtasks code is built as
part of Gecko (i.e., `toolkit/...` rather than `browser/...`) I have
favoured GRE prefs.  I think, however, that what is written will work
for App-specific prefs, but I'm not concerned with that detail at this
time.

This also add tests for backgroundtask-specific prefs, which are
structured as both xpcshell and mochitest-chrome tests because
locally, the former tests unpackaged builds and the latter can
accommodate testing packaged builds.  We could use mochitest-chrome
for both, but this has been pleasant to work with locally.

Differential Revision: https://phabricator.services.mozilla.com/D97510
2021-01-25 23:49:23 +00:00
Nick Alexander
00c4c1f99c Bug 1667276 - Part 2: Add BackgroundTasksManager to invoke task defined in JS. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D97512
2021-01-25 23:45:17 +00:00