Commit Graph

120 Commits

Author SHA1 Message Date
Christian Holler
8696367b25 Bug 1790555 - Add missing fuzzing instrumentation. r=truber
Differential Revision: https://phabricator.services.mozilla.com/D157188
2022-09-14 15:52:20 +00:00
Olli Pettay
048bd344c4 Bug 1777574, automate CC zone handling, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D155084
2022-09-07 11:22:51 +00:00
William Durand
086e396308 Bug 1782702 - Update header files (and template) to have the private members at the end of the class definition. r=rpl
I also moved a few protected members and re-ordered the sections to have public, protected, private.

Differential Revision: https://phabricator.services.mozilla.com/D153467
2022-08-02 16:07:43 +00:00
William Durand
aaf5c93693 Bug 1748315 - Part 3 - Generate WebIDL bindings for the scripting namespace. r=rpl,webidl,smaug
This patch adds WebIDL bindings for the `scripting` namespace.
Note that `scripting.executeScript()` is excluded for now.

Differential Revision: https://phabricator.services.mozilla.com/D141463
2022-08-02 14:22:39 +00:00
William Durand
fec0f36b65 Bug 1748315 - Part 0 - Slightly improve GenerateWebIDLBindings.py UI. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D141749
2022-08-01 06:31:55 +00:00
Kagami Sascha Rosylight
72fd693b02 Bug 1769290 - Part 17: Apply mozilla-js-handle-rooted-typedef against toolkit/components/extensions r=andi,extension-reviewers,rpl
Differential Revision: https://phabricator.services.mozilla.com/D151784
2022-07-14 17:00:22 +00:00
Luca Greco
764901d1cf Bug 1762592 - Support mapping to AsyncAmbiguous through GenerateWebIDLBindings.py config file. r=willdurand
Differential Revision: https://phabricator.services.mozilla.com/D142682
2022-07-14 11:34:27 +00:00
Luca Greco
143979a345 Bug 1750161 - ExtensionListenerCallWorkerRunnable::WorkerRun should explicitly check for uncatchale exception. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D148950
2022-07-05 15:15:55 +00:00
Peter Van der Beken
c1f8f93c43 Bug 1688585 - extensions::RequestWorkerRunnable::Init should propagate failure of dom::PromiseWorkerProxy::Create. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D145066
2022-05-02 07:36:53 +00:00
Jan de Mooij
70e925044f Bug 1760844 part 2 - Tidy up InstanceofOperator and HasInstance. r=iain
* `js::HasInstance` now always forwards to `JS::InstanceofOperator` so call the latter directly.
* Move `InstanceofOperator` to the js namespace and remove it from the API (`JS_HasInstance` already exists).

Differential Revision: https://phabricator.services.mozilla.com/D142062
2022-04-04 15:09:29 +00:00
Luca Greco
c59415e74a Bug 1749064 - Add WebExtensions Python Subsuite to TC config. r=taskgraph-reviewers,robwu,jmaher
Depends on D135549

Differential Revision: https://phabricator.services.mozilla.com/D141725
2022-03-28 19:00:17 +00:00
Luca Greco
0fbd4fd8c9 Bug 1749064 - Add pytest suite to cover JSONSchema to WebIDL python scripts GenerateWebIDLBindings.py. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D135549
2022-03-28 19:00:16 +00:00
Shane Caraveo
b5e3280bfd Bug 1759308 make getBackgroundPage load the event page if necessary r=robwu,rpl
Differential Revision: https://phabricator.services.mozilla.com/D140919
2022-03-17 14:54:04 +00:00
Randell Jesup
855202c183 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli
16f5f5f2b9 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup
a98b1f8218 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila
01197944a0 Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup
fe15f2115d Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00
Luca Greco
d12ad5e521 Bug 1757727 - Regenerated ExtensionTest API webidl definitions and update implementation accordingly. r=mixedpuppy,peterv
Differential Revision: https://phabricator.services.mozilla.com/D140047
2022-03-14 13:27:21 +00:00
Luca Greco
41d4b2e386 Bug 1748714 - Add configuration to hide API methods in WebIDL ExtensionAPI definitions GenerateWebIDLBindings creates based on the JSONSchema data. r=robwu
Currently only used to hide browser.runtime.getFrameID, which isn't going to be usable
in a background service worker anyway and it is not deprecated in MV3.

Differential Revision: https://phabricator.services.mozilla.com/D136951
2022-03-14 13:27:21 +00:00
Luca Greco
2523d549bb Bug 1748714 - Generate multiple webidl method signatures on JSONSchema optional parameters followed by a mandatory one. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D135419
2022-03-14 13:27:20 +00:00
Eden Chuang
16e72604f2 Bug 1744025: Use CheckedUnsafePtr<WorkerPrivate> in WorkerGlobalScopeBase. r=dom-worker-reviewers,asuth
Depends on D132708

Differential Revision: https://phabricator.services.mozilla.com/D132709
2022-01-25 08:53:00 +00:00
Jan Varga
f2d7aded38 Bug 1750730 - Add WebIDL bindings for OPFS; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D136226
2022-01-24 12:11:29 +00:00
Matthew Gaudet
108063d593 Bug 1748888 - Add ErrorResult parameter to PromiseNativeHandler callbacks r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D136423
2022-01-20 19:11:39 +00:00
Luca Greco
0f502c6318 Bug 1724026 - Support running existing Extension API mochitests with a background service worker. r=mixedpuppy
Provide a way to use service workers as the background script in existing tests, possibly by only
requiring minimal changes to the existing test cases.

This patch includes:

- changes needed to detect when a test extension is being created for a test running in
  the "background service worker mode" and automatically turn the background script into
  a background service worker (instead of a background page) when not explicitly listed
  in the test extension manifest

- a new mochitest-serviceworker.ini manifest where new or existing test files meant to be run on a
  background service worker can be added to run them automatically in the "background service worker mode"

- a new test_verify_sw_mode.html smoke test that make sure the mochitest-serviceworker.ini manifest
  is running in the expected mode.

- a new `sw-webextension` tag, which can be used locally to run a test file only in the
  "background service worker mode"

- changes to test_ext_test.html to make it able to run in both background pages and background workers

- small tweaks to `test` API (both the WebIDL binding and the current bindings injected from privileged
  js code, to better match each other behavior)

Differential Revision: https://phabricator.services.mozilla.com/D122536
2022-01-12 11:33:13 +00:00
Norisz Fay
9c9c80ed50 Backed out 3 changesets (bug 1724026) for causing python3 failures
Backed out changeset 461db77b2f1f (bug 1724026)
Backed out changeset a14c7fb88490 (bug 1724026)
Backed out changeset dfac5955ed61 (bug 1724026)
2022-01-11 22:57:09 +02:00
Luca Greco
c5a5cc3615 Bug 1724026 - Support running existing Extension API mochitests with a background service worker. r=mixedpuppy
Provide a way to use service workers as the background script in existing tests, possibly by only
requiring minimal changes to the existing test cases.

This patch includes:

- changes needed to detect when a test extension is being created for a test running in
  the "background service worker mode" and automatically turn the background script into
  a background service worker (instead of a background page) when not explicitly listed
  in the test extension manifest

- a new mochitest-serviceworker.ini manifest where new or existing test files meant to be run on a
  background service worker can be added to run them automatically in the "background service worker mode"

- a new test_verify_sw_mode.html smoke test that make sure the mochitest-serviceworker.ini manifest
  is running in the expected mode.

- a new `sw-webextension` tag, which can be used locally to run a test file only in the
  "background service worker mode"

- changes to test_ext_test.html to make it able to run in both background pages and background workers

- small tweaks to `test` API (both the WebIDL binding and the current bindings injected from privileged
  js code, to better match each other behavior)

Differential Revision: https://phabricator.services.mozilla.com/D122536
2022-01-11 20:09:33 +00:00
Luca Greco
a5eef525d5 Bug 1728327 - Track ExtensionEventListener a background service worker registered by the time it is fully loaded. r=baku
This patch includes a proposed approach to keep track of the WebExtensions API event listeners
subscribed synchronously while the background service worker script was being loaded and executed,
because this are the listeners that we can assume to be available right after we spawn a worker
and be able to handle the API event that triggered the worker to be spawned.

The information about the "listeners subscribed synchronously while the worker script is being
loaded and executed" is then used by the ExtensionBrowser::HasWakeupEventListener method,
which will be called as part of handling the nsIServiceWorkerManager.wakeForExtensionAPIEvent
call.

Differential Revision: https://phabricator.services.mozilla.com/D130758
2021-12-15 18:29:37 +00:00
Luca Greco
12744fa9aa Bug 1728327 - Introduce a new nsIServiceWorkerManager.wakeForExtensionAPIEvent method. r=asuth
This patch includes a set of changes to the ServiceWorker internals to introduce a new
nsIServiceWorkerManager.wakeForExtensionAPIEvent method, to be used by the WebExtensions internals
to request an active background service worker to be spawned (if it is not yet) in response to
a WebExtension API event.

The new method gets as parameters:

- the scope URL for the extension background service worker to spawn
- WebExtensions API namespace and API event name which we are going to spawn an active worker for

and return a promise which would be:
- rejected if the worker could not be spawned
- resolved to a boolean if the worker was spawned successfully (or already running)

The value of the boolean value resolved is meant to represent if the worker did actually
have any listener subscribed for the given WebExtensions API event listener
(which the WebExtensions internals may then use to decide if it is worth to send that event
to be handled by the worker script or not).

In this patch the ExtensionBrowser::HasWakeupEventListener used to determine if an WebExtensions
API event was subscribed syncronously when the worker was being loaded is not implemented yet
and it is always returning false (a proposed implementation for that method is going to be
added in a separate patch part of this same bugzilla issue).

A unit test for the new proposed nsIServiceWorkerManager method is also part of a separate patch
(attached to this bugzilla issue as the child revision for this one).

Differential Revision: https://phabricator.services.mozilla.com/D130756
2021-12-15 18:29:36 +00:00
Norisz Fay
20994191cc Backed out 9 changesets (bug 1744025) for causing wpt failures on CheckedUnsafePtr.h CLOSED TREE
Backed out changeset 89dca4fc5940 (bug 1744025)
Backed out changeset 7aa395dcdbe4 (bug 1744025)
Backed out changeset 1580a4ea1a85 (bug 1744025)
Backed out changeset af171636a87f (bug 1744025)
Backed out changeset a5edfa1c9cd6 (bug 1744025)
Backed out changeset 8abd6ba69815 (bug 1744025)
Backed out changeset cfb822df5b3f (bug 1744025)
Backed out changeset 5598943a94fd (bug 1744025)
Backed out changeset 43186fbbf8b4 (bug 1744025)
2021-12-15 18:46:01 +02:00
Eden Chuang
fefd97f831 Bug 1744025: Use CheckedUnsafePtr<WorkerPrivate> in WorkerGlobalScopeBase. r=dom-worker-reviewers,asuth
Depends on D132708

Differential Revision: https://phabricator.services.mozilla.com/D132709
2021-12-15 13:48:17 +00:00
Sandor Molnar
f526e5603d Backed out 8 changesets (bug 1744025) for causing bp-hybrid bustages in dom/clients/api/Clients.cpp. CLOSED TREE
Backed out changeset b6452430763d (bug 1744025)
Backed out changeset 46e9f06636da (bug 1744025)
Backed out changeset 913cdee4824f (bug 1744025)
Backed out changeset e1bc4e2066c7 (bug 1744025)
Backed out changeset e6b99af4b7ca (bug 1744025)
Backed out changeset e9b749f80ec2 (bug 1744025)
Backed out changeset 26d3176a00ef (bug 1744025)
Backed out changeset 2c8941fdcee5 (bug 1744025)
2021-12-08 01:30:06 +02:00
Jens Stutte
8028b0d94e Bug 1744025: Use CheckedUnsafePtr<WorkerPrivate> in WorkerGlobalScopeBase. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D132709
2021-12-07 16:47:15 +00:00
Luca Greco
3e6b12b305 Bug 1728326 - Notify WebExtensions internals when a background service worker scripts has been executed. r=asuth
This patch includes changes needed to notify the WebExtensions internals
when a background service worker script has been fully loaded, through a
NotifyWorkerLoadedRunnable (dispatched as low priority) that calls a new
mozIExtensionAPIRequestHandler.onExtensionWorkerLoaded method.

Differential Revision: https://phabricator.services.mozilla.com/D124701
2021-11-05 21:27:03 +00:00
Luca Greco
86985beefc Bug 1728326 - Add a new RequestInitWorkerRunnable to call mozIExtensionAPIRequestHandler initExtensionWorker. r=baku
This patch introduce a new RequestInitWorkerRunnable that calls a new mozIExtensionAPIRequestHandler.initExtensionWorker
method, and a CreateAndDispatchInitWorkerRunnable helper function which will be used to send
this mozIExtensionAPIRequest from the worker thread to the main thread when the background
service worker is ready for being executed (but before its main scripts has been evaluated
in the newly created service worker global scope).

Differential Revision: https://phabricator.services.mozilla.com/D124699
2021-11-05 21:27:02 +00:00
Luca Greco
6296982c50 Bug 1728326 - Add ServiceWorkerInfo descriptor id to mozIExtensionServiceWorkerInfo. r=baku
This patch adds the ServiceWorkerInfo descriptor id to the property available in the
mozIExtensionServiceWorkerInfo.

The descriptor ID is an integer assigned on the main process to each ServiceWorkerPrivate instance,
which will allow us to verify in the main process that the worker running in the child process is
part of the expected service worker registration, and it is also still available when the worker
is already being destroyed, which makes it useful as the key used in the map of the extension
service worker context that we keep in the child extension process.

Differential Revision: https://phabricator.services.mozilla.com/D124698
2021-11-05 21:27:02 +00:00
Luca Greco
e6755d7206 Bug 1728326 - Notify WebExtensions internals when a WebExtensions background service worker is destroyed. r=asuth
This patch introduces the following changes:
- In WorkerPrivate::ExtensionAPIAllowed: removed assertion on StaticPrefs::extensions_backgroundServiceWorker_enabled_AtStartup,
  replaced with just ignoring mExtensionAPIAllowed if the feature is turned out by prefs
- Added a new CreateAndDispatchWorkerDestroyedRunnable helper function to create and dispatch
  a runnable (as a low priority one) to call a new mozIExtensionAPIRequestHandler.onExtensionWorkerDestroyed
  method.

The service worker that has been destroyed is identified by its descriptor ID (the descriptor ID is an integer,
assigned on the main process to each ServiceWorkerPrivate instance, and still available when the worker is
already being destroyed).

Differential Revision: https://phabricator.services.mozilla.com/D124697
2021-11-05 21:27:02 +00:00
Marian-Vasile Laza
f89640f067 Backed out 10 changesets (bug 1728326) for causing build bustages. CLOSED TREE
Backed out changeset 39267f23ee63 (bug 1728326)
Backed out changeset 070f187c2005 (bug 1728326)
Backed out changeset f06e0af1bf81 (bug 1728326)
Backed out changeset d21475767077 (bug 1728326)
Backed out changeset 4ca5e36e3c71 (bug 1728326)
Backed out changeset fd700124d69b (bug 1728326)
Backed out changeset 5c8d87c04ac6 (bug 1728326)
Backed out changeset 247504b7ea84 (bug 1728326)
Backed out changeset de8879fc8126 (bug 1728326)
Backed out changeset ebf25d0924d6 (bug 1728326)
2021-11-05 22:48:14 +02:00
Luca Greco
bc6e193efd Bug 1728326 - Notify WebExtensions internals when a background service worker scripts has been executed. r=asuth
This patch includes changes needed to notify the WebExtensions internals
when a background service worker script has been fully loaded, through a
NotifyWorkerLoadedRunnable (dispatched as low priority) that calls a new
mozIExtensionAPIRequestHandler.onExtensionWorkerLoaded method.

Differential Revision: https://phabricator.services.mozilla.com/D124701
2021-11-05 20:27:01 +00:00
Luca Greco
baf7fb5176 Bug 1728326 - Add a new RequestInitWorkerRunnable to call mozIExtensionAPIRequestHandler initExtensionWorker. r=baku
This patch introduce a new RequestInitWorkerRunnable that calls a new mozIExtensionAPIRequestHandler.initExtensionWorker
method, and a CreateAndDispatchInitWorkerRunnable helper function which will be used to send
this mozIExtensionAPIRequest from the worker thread to the main thread when the background
service worker is ready for being executed (but before its main scripts has been evaluated
in the newly created service worker global scope).

Differential Revision: https://phabricator.services.mozilla.com/D124699
2021-11-05 20:27:00 +00:00
Luca Greco
27a3e5f897 Bug 1728326 - Add ServiceWorkerInfo descriptor id to mozIExtensionServiceWorkerInfo. r=baku
This patch adds the ServiceWorkerInfo descriptor id to the property available in the
mozIExtensionServiceWorkerInfo.

The descriptor ID is an integer assigned on the main process to each ServiceWorkerPrivate instance,
which will allow us to verify in the main process that the worker running in the child process is
part of the expected service worker registration, and it is also still available when the worker
is already being destroyed, which makes it useful as the key used in the map of the extension
service worker context that we keep in the child extension process.

Differential Revision: https://phabricator.services.mozilla.com/D124698
2021-11-05 20:26:59 +00:00
Luca Greco
cf17619139 Bug 1728326 - Notify WebExtensions internals when a WebExtensions background service worker is destroyed. r=asuth
This patch introduces the following changes:
- In WorkerPrivate::ExtensionAPIAllowed: removed assertion on StaticPrefs::extensions_backgroundServiceWorker_enabled_AtStartup,
  replaced with just ignoring mExtensionAPIAllowed if the feature is turned out by prefs
- Added a new CreateAndDispatchWorkerDestroyedRunnable helper function to create and dispatch
  a runnable (as a low priority one) to call a new mozIExtensionAPIRequestHandler.onExtensionWorkerDestroyed
  method.

The service worker that has been destroyed is identified by its descriptor ID (the descriptor ID is an integer,
assigned on the main process to each ServiceWorkerPrivate instance, and still available when the worker is
already being destroyed).

Differential Revision: https://phabricator.services.mozilla.com/D124697
2021-11-05 20:26:59 +00:00
Valentin Gosu
abbfd98a39 Bug 1735299 - Remove last use of unnammed NS_ReleaseOnMainThread r=extension-reviewers,rpl,nhnt11
Differential Revision: https://phabricator.services.mozilla.com/D128177
2021-10-19 13:44:25 +00:00
Luca Greco
27f08310ac Bug 1724183 - Add test.assertRejects WebExtensions API implementation to ExtensionTest webidl bindings. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D122035
2021-10-12 18:32:28 +00:00
Luca Greco
88b441791f Bug 1724183 - Add test.assertThrows WebExtensions API implementation to ExtensionTest webidl bindings. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D122034
2021-10-12 18:32:27 +00:00
Luca Greco
4900365b51 Bug 1724183 - Add ExtensionTest::AssertMatchInternal to provide the logic to be shared between AssertThrows and AssertRejects. r=baku,sfink
This patch introduce a new AssertMatchInternal to ExtensionTest, this method isn't exposed to
js callers through the webidl definition, it is meant to be used internally by the
AssertThrows and AssertRejects methods (which are instead both methods part of the ExtensionTest
webidl).

This patch also introduces small changes to ExtensionAPIRequestForwarder and RequestWorkerRunnable,
to allow AssertMatchInternal to accept as an optional parameter a serialized caller stack trace
(to be sent as part of the APIRequest forwarded from the worker thread to the main thread),
which is needed for AssertRejects (to include the strack trace retrieved when AssertRejects is
called, and then after the promise parameter has been rejected or resolved to send it as part
of the forwarded aPI request).

Differential Revision: https://phabricator.services.mozilla.com/D122033
2021-10-12 18:32:27 +00:00
Luca Greco
c21668f9ad Bug 1724183 - Add test.assertEq WebExtensions API implementation to ExtensionTest webidl bindings. r=baku,mixedpuppy
This patch introduce a new method to ExtensionTest.h/.cpp that implements the parts of
browser.test.assertEq that needs to happen on the background service worker thread
(because the first two parameters are expected to not be always of types that can be structure cloned).

The C++ method is meant to follow closely enough what the current implementation is doing
in privileged JS code (See https://searchfox.org/mozilla-central/rev/00977c4e37865a92f1c15572ae4aea90e934b25b/toolkit/components/extensions/child/ext-test.js#169-186)
after that the C++ method calls the existing assertEq implementation, which will be actually be getting
the first 2 parameters already converted as strings (which will be already different if `expected` and
`actual` js values were different despite their stringified value may be looking the same, because the
method will add " (different)" to the stringified `actual` value if the two parameter were not strictly
equal).

The existing test.assertEq implementation will also take care to send the result of the assertion
to the parent process (which will make sure that the test case being executed will fail as expected),
as it happens for all other test API methods that are just forwarding their parameters to the
main thread through the pre-existing stub methods.

Differential Revision: https://phabricator.services.mozilla.com/D121890
2021-10-12 18:32:27 +00:00
Luca Greco
d0c0d2fc7e Bug 1688040 - part11: Fix dom::Promise leaked by RequestWorkerRunnable::ProcessHandlerResult when handling the result of an async method call. r=baku
This patch fixes a leak that I spotted while investigating a separate shutdown leak triggered by D121683

(This one is not strictly related to D121683, but apparently none of the xpcshell tests part of this
stack of patches reported it at a shutdown leak, nevertheless it was detected as a shutdown leak
while running the test_ext_identity.html mochitest on the background service worker, after
the other leak specific to D121683 was fixed, and after investigating it using cc logs and heapgraph's
find_roots.py I confirmed that it's a shutdown leak introduced here in RequestWorkerRunnable::ProcessHandlerResult).

Differential Revision: https://phabricator.services.mozilla.com/D122968
2021-10-06 12:28:25 +00:00
Luca Greco
5052a49b6b Bug 1688040 - part10.3: Store weakptr in the ports lookup map and clear the entry when released. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D107555
2021-10-06 12:28:24 +00:00
Luca Greco
1c908a6177 Bug 1688040 - part10.2: Return existing ExtensionPort instance based on the ExtensionPortDescriptor portId. r=baku
The extensions expect that ExtensionPort instances they get in the calls to the
port event listeners to always be the same, and to be also strictly equal to the
object port got from browser.runtime.connect or browser.runtime.onConnect:

```
const port = browser.runtime.connect();
port.onDisconnect.addListener(disconnectedPort => {
  // port === disconnectedPort => true
});
```

This patch does add an extension port lookup map in the ExtensionBrowser
class and a new ExtensionBrowser::GetPort method which is responsible of
providing the expected behavior (returning an existing istance if one is
found in the lookup map).

Differential Revision: https://phabricator.services.mozilla.com/D107554
2021-10-06 12:28:24 +00:00