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
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
This patch does:
- add to ExtensionBrowser two new data members to keep track of value for the browser.runtime.lastError and if it was checked while
the chrome compatible callback was being executed
- add to ExtensionBrowser 3 new methods to set, get and clear the lastError value
- add a reference to the ExtensionBrowser to all API namespaces and API objects classes, because it has to be then propagated to the
ChromeCompatCallbackHandler instances that are being attached to the promise result of the async API methods calls if the caller did
pass the optional callback parameter
- tweak the ChromeCompatCallbackHandler class to set the lastError value before calling the callback in ChromeCompatCallbackHAndler::RejectedCallback
and then clear it after the call has been completed and report it to the console if it wasn't checked
- change the ExtensionRuntime::GetLastError methhod to restrieve and return the value from the ExtensionBrowser instance
Differential Revision: https://phabricator.services.mozilla.com/D107327
This makes a couple of changes, including removing the call to
AppendNativeHandler from the constructor, and using the nullable nature of
std::function instead of wrapping them in Maybe.
The main advantage of this change, however, is that it no longer acquires a
reference to `this` during the constructor, which could be unsafe.
Differential Revision: https://phabricator.services.mozilla.com/D124827
This makes a couple of changes, including removing the call to
AppendNativeHandler from the constructor, and using the nullable nature of
std::function instead of wrapping them in Maybe.
The main advantage of this change, however, is that it no longer acquires a
reference to `this` during the constructor, which could be unsafe.
Differential Revision: https://phabricator.services.mozilla.com/D124827
This makes a couple of changes, including removing the call to
AppendNativeHandler from the constructor, and using the nullable nature of
std::function instead of wrapping them in Maybe.
The main advantage of this change, however, is that it no longer acquires a
reference to `this` during the constructor, which could be unsafe.
Differential Revision: https://phabricator.services.mozilla.com/D124827
Automatically generated path that adds flag `REQUIRES_UNIFIED_BUILD = True` to `moz.build`
when the module governed by the build config file is not buildable outside on the unified environment.
This needs to be done in order to have a hybrid build system that adds the possibility of combing
unified build components with ones that are built outside of the unified eco system.
Differential Revision: https://phabricator.services.mozilla.com/D122345
This change is meant to handle the `mach hazards` failure that triggered a backout of this stack of patches,
ExtensionEventManager::AddListener/RemoveListener should use a JS::Rooted object as a key in the GCHashMap.
The GCHashMap has been added into ExtensionEventManager as part of D80610 ("part2.2: ExtensionEventListener xpcom interface
base implementation"), this patch adds the necessary changes on top of that patch.
(I've also double-checked locally that these changes should not be triggering the `mach hazards` failure anymore
and confirmed that all the unit tests part of this stack of patches are completing successfully).
Differential Revision: https://phabricator.services.mozilla.com/D117538
ExtensionMockAPI is a fake WebExtensions API, locked behind a pref and
used in unit tests related to the API requests handling and WebExtensionStub
methods without relying on a specific WebExtension API.
Depends on D84687
Differential Revision: https://phabricator.services.mozilla.com/D99886
The ExtensionPort represents the webidl definitions of the runtime.Port WebExtensions API object.
A webidl dictionary will represent the serializable definition of the port properties, sent from
the API request handler to provide all the internal properties needed to create an instance
of the ExtensionPort webidl interface on the worker thread (which will be returned to the
extension code as the return value of the runtime.connect/connectNative methods and as a
parameter of the calls to the runtime.onConnect API event listeners).
Depends on D84684
Differential Revision: https://phabricator.services.mozilla.com/D84685
An ExtensionEventListener xpcom interface that wraps an API event callback
and included in the API requests forwarded to the API request handler.
The ExtensionEventListener xpcom interface provides a method to forward
to the worker thread the calls to the wrapped API event callpack originated
from the WebExtensions framework running on the main thread.
Depends on D75311
Differential Revision: https://phabricator.services.mozilla.com/D80609
New XPCOM idl interfaces to define the components used to:
- represent an API request (call to API methods, add/remove API event listener,
get the value of an API property getter)
- define the API request handler defined by privileged JS code running on the
main thread
New ExtensionAPIBase shared stub methods and helper methods to create and forward
the API requests from the worker to the main thread and translate the results
got from the API request handler in the value to return or resolve (or the errors
to be raised) to the extension code running on the worker thread.
Depends on D80604
Differential Revision: https://phabricator.services.mozilla.com/D75311
WebIDL interface and c++ class to be used by all WebExtension API webidl bindings
to expose the expected WebExtensions API events (e.g. browser.tabs.onUpdated etc.)
Depends on D84682
Differential Revision: https://phabricator.services.mozilla.com/D80604
An ExtensionAPIBase class which provides a collection of shared stub methods and
shared helpers and used as a base class for the actual WebExtensions API webidl classes.
Depends on D84681
Differential Revision: https://phabricator.services.mozilla.com/D84682
- Extension API WebIDL to be part of a new dom/extensions-webidl directory
(and all webidl in this directory associated with WebExtensions::General
bugzilla component)
- Extension API C++ implementation in a new toolkit/components/extensions/webidl-api
directory
- Lock Extensions API WebIDL bindings provided to extensions workers global on:
- the preference "extensions.backgroundServiceWorker.enabled" being set to true
- checking explicitly that the worker is an extension service worker declared
in the extension manifest.json file.
- Changes to WorkerPrivate, WorkerScope.h/.cpp to expose the WebIDL
bindings to the extension service workers (if the service worker has been
detected as the background service worker specified in the manifest),
plus small changes to RemoteWorkerChild.cpp to detect if the worker
is the background service worker (and mark it as so in the WorkerPrivate
instance associated to it)
Differential Revision: https://phabricator.services.mozilla.com/D70372
ExtensionMockAPI is a fake WebExtensions API, locked behind a pref and
used in unit tests related to the API requests handling and WebExtensionStub
methods without relying on a specific WebExtension API.
Depends on D84687
Differential Revision: https://phabricator.services.mozilla.com/D99886
The ExtensionPort represents the webidl definitions of the runtime.Port WebExtensions API object.
A webidl dictionary will represent the serializable definition of the port properties, sent from
the API request handler to provide all the internal properties needed to create an instance
of the ExtensionPort webidl interface on the worker thread (which will be returned to the
extension code as the return value of the runtime.connect/connectNative methods and as a
parameter of the calls to the runtime.onConnect API event listeners).
Depends on D84684
Differential Revision: https://phabricator.services.mozilla.com/D84685