Commit Graph

118 Commits

Author SHA1 Message Date
Luca Greco
5600239e95 Bug 1688040 - part8.1: Add stub method for string and jsvalue properties. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D106704
2021-10-06 12:28:22 +00:00
Luca Greco
719e76077f Bug 1688040 - part7.1: Added WebIDL-based binding for the browser.runtime WebExtensions API. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D106700
2021-10-06 12:28:21 +00:00
Luca Greco
96fa826604 Bug 1688040 - part5: Added WebIDL-based binding for the browser.alarms WebExtensions API. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102928
2021-10-06 12:28:20 +00:00
Luca Greco
ef913afd1e Bug 1688040 - part4.2: Hook up browser.test API webidl binding to ExtensionBrowser. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102643
2021-10-06 12:28:19 +00:00
Luca Greco
1bf8d834fa Bug 1688040 - part4.1: Initial WebIDL-based bindings for browser.test API namespace r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102642
2021-10-06 12:28:19 +00:00
Luca Greco
4c9878d7e7 Bug 1688040 - part3: python script to generate webidl definitions from WebExtension API JSON schema files. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D87717
2021-10-06 12:28:18 +00:00
Luca Greco
054efeaee3 Bug 1688040 - part2.1: Allow storing normalized arguments in the mozIExtensionAPIRequest object. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102641
2021-10-06 12:28:17 +00:00
Iulian Moraru
7e43871db1 Backed out 27 changesets (bug 1688040) for causing multiple failures. CLOSED TREE
Backed out changeset 85ba163b6423 (bug 1688040)
Backed out changeset 36cdc1600e66 (bug 1688040)
Backed out changeset 88395ab5a5b5 (bug 1688040)
Backed out changeset 8d33bdd8d0b8 (bug 1688040)
Backed out changeset fdbced7a94f3 (bug 1688040)
Backed out changeset 922ca2f20fa1 (bug 1688040)
Backed out changeset 7fc233bf144c (bug 1688040)
Backed out changeset 64221db54d98 (bug 1688040)
Backed out changeset 4d9b2a9dd247 (bug 1688040)
Backed out changeset c8d890f1a8e2 (bug 1688040)
Backed out changeset 81e957717eb1 (bug 1688040)
Backed out changeset b7dcade29dab (bug 1688040)
Backed out changeset 20e38838aa89 (bug 1688040)
Backed out changeset 08737e7ea047 (bug 1688040)
Backed out changeset b82645d5b7c7 (bug 1688040)
Backed out changeset db374d34839a (bug 1688040)
Backed out changeset 6a2ebb56325d (bug 1688040)
Backed out changeset 7d0ce555263f (bug 1688040)
Backed out changeset 15e0689a57f0 (bug 1688040)
Backed out changeset d7d6b1bec92a (bug 1688040)
Backed out changeset 615b683acb00 (bug 1688040)
Backed out changeset 49d3e1baf577 (bug 1688040)
Backed out changeset 30cc613912ce (bug 1688040)
Backed out changeset d413ec19bded (bug 1688040)
Backed out changeset cfdf6e87d820 (bug 1688040)
Backed out changeset f719b9d0bc25 (bug 1688040)
Backed out changeset 925f23a58da6 (bug 1688040)
2021-10-05 22:49:40 +03:00
Luca Greco
24f3486757 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-05 17:05:46 +00:00
Luca Greco
e4f53db056 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-05 17:05:45 +00:00
Luca Greco
39fbad36fe 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-05 17:05:44 +00:00
Luca Greco
2e7c690f0d Bug 1688040 - part10.1: Support prepending or appending api object instance to the listener call arguments. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D107553
2021-10-05 17:05:44 +00:00
Luca Greco
f1b879eebe Bug 1688040 - part9: Implement setting/clearing and reporting browser.runtime.lastError from ChromeCompatCallbackHandler::RejectedCallback. r=baku
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
2021-10-05 17:05:44 +00:00
Luca Greco
2ea083d29e Bug 1688040 - part8.1: Add stub method for string and jsvalue properties. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D106704
2021-10-05 17:05:42 +00:00
Luca Greco
bd6f797973 Bug 1688040 - part7.1: Added WebIDL-based binding for the browser.runtime WebExtensions API. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D106700
2021-10-05 17:05:41 +00:00
Luca Greco
4767147224 Bug 1688040 - part5: Added WebIDL-based binding for the browser.alarms WebExtensions API. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102928
2021-10-05 17:05:40 +00:00
Luca Greco
9b342ccc8d Bug 1688040 - part4.2: Hook up browser.test API webidl binding to ExtensionBrowser. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102643
2021-10-05 17:05:39 +00:00
Luca Greco
4d06d6a32d Bug 1688040 - part4.1: Initial WebIDL-based bindings for browser.test API namespace r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102642
2021-10-05 17:05:39 +00:00
Luca Greco
3fc858da10 Bug 1688040 - part3: python script to generate webidl definitions from WebExtension API JSON schema files. r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D87717
2021-10-05 17:05:38 +00:00
Luca Greco
38b5efafa7 Bug 1688040 - part2.1: Allow storing normalized arguments in the mozIExtensionAPIRequest object. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D102641
2021-10-05 17:05:38 +00:00
Nika Layzell
d72db5a172 Bug 1729458 - Part 1: Simplify DomPromiseListener, r=smaug,rpl
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
2021-09-14 15:02:58 +00:00
Sandor Molnar
4643c284c0 Backed out 3 changesets (bug 1729458) for causing multiple dt failures. CLOSED TREE
Backed out changeset 16b385e15fad (bug 1729458)
Backed out changeset 72b7a9c7bf30 (bug 1729458)
Backed out changeset 704dd03288b1 (bug 1729458)
2021-09-13 21:08:44 +03:00
Nika Layzell
8491e801c3 Bug 1729458 - Part 1: Simplify DomPromiseListener, r=smaug,rpl
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
2021-09-13 15:23:31 +00:00
Alexandru Michis
b47a6b01a6 Backed out 2 changesets (bug 1729458) for causing leaks in ClientManagerService.
CLOSED TREE

Backed out changeset 42b3a9930fe0 (bug 1729458)
Backed out changeset b8db01010657 (bug 1729458)
2021-09-08 21:32:20 +03:00
Nika Layzell
3b7b026716 Bug 1729458 - Part 1: Simplify DomPromiseListener, r=smaug,rpl
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
2021-09-08 17:06:15 +00:00
Andi-Bogdan Postelnicu
f221c438ca Bug 1725145 - Preparation for the hybrid build env. r=necko-reviewers,firefox-build-system-reviewers,valentin,glandium
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
2021-08-25 10:46:17 +00:00
Tooru Fujisawa
bdb56d8e6b Bug 1708450 - Move call and construct functions into js/public/CallAndConstruct.h. r=nbp
Depends on D119619

Differential Revision: https://phabricator.services.mozilla.com/D119620
2021-07-13 11:52:43 +00:00
Tooru Fujisawa
0986662ce6 Bug 1708448 - Move property and element functions into js/public/PropertyAndElement.h. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D119619
2021-07-13 11:52:42 +00:00
Andi-Bogdan Postelnicu
45c2f471e5 Bug 1519636 - Reformat recent changes to the Google coding style. r=necko-reviewers,emilio
Updated with clang-format version 12.0.0 (taskcluster-FZRqPXamQIOU_i4hF0cAcg)

Differential Revision: https://phabricator.services.mozilla.com/D117905
2021-06-17 11:00:22 +00:00
Luca Greco
b721d2f4a9 Bug 1682632 - ExtensionEventManager should use a JS::Rooted<JSObject*> as key in the mListeners JS::GCHashMap. r=sfink,baku
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
2021-06-11 18:58:12 +00:00
Luca Greco
4dc81bea74 Bug 1682632 - part3: Restrict Extension API webidl bindings to nightly builds. r=baku,mixedpuppy
Depends on D99887

Differential Revision: https://phabricator.services.mozilla.com/D104707
2021-06-11 18:58:11 +00:00
Luca Greco
0339eab3c7 Bug 1682632 - part2.7: ExtensionMockAPI. r=baku
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
2021-06-11 18:58:10 +00:00
Luca Greco
4893761ac0 Bug 1682632 - part2.6: ExtensionEventListener callListener sendResponse callback parameter. r=baku,sfink
Depends on D84686

Differential Revision: https://phabricator.services.mozilla.com/D84687
2021-06-11 18:58:10 +00:00
Luca Greco
be1b531bbd Bug 1682632 - part2.5: ExtensionPort passed as a ExtensionEventListener callListener parameter. r=baku
Depends on D84685

Differential Revision: https://phabricator.services.mozilla.com/D84686
2021-06-11 18:58:09 +00:00
Luca Greco
aed6e24884 Bug 1682632 - part2.4: ExtensionPort. r=baku
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
2021-06-11 18:58:09 +00:00
Luca Greco
11524fa93b Bug 1682632 - part2.3: ExtensionEventListener callListener promised return value. r=baku
Depends on D80610

Differential Revision: https://phabricator.services.mozilla.com/D84684
2021-06-11 18:58:09 +00:00
Luca Greco
279b00dfe2 Bug 1682632 - part2.2: ExtensionEventListener xpcom interface base implementation. r=baku,sfink
Depends on D80609

Differential Revision: https://phabricator.services.mozilla.com/D80610
2021-06-11 18:58:08 +00:00
Luca Greco
514836a5d1 Bug 1682632 - part2.1: ExtensionEventListener. r=baku,mixedpuppy
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
2021-06-11 18:58:08 +00:00
Luca Greco
112e5fad7c Bug 1682632 - part2: Extension API request handling. r=baku,mixedpuppy
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
2021-06-11 18:58:08 +00:00
Luca Greco
349caac603 Bug 1682632 - part1.3: ExtensionEventManager webidl interface. r=baku,mixedpuppy
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
2021-06-11 18:58:07 +00:00
Luca Greco
3ae42cd36f Bug 1682632 - part1.2: ExtensionAPIBase class. r=baku,mixedpuppy
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
2021-06-11 18:58:07 +00:00
Luca Greco
fd3b2d983a Bug 1682632 - part1: add ExtensionBrowser webidl API skeleton to Extension Background Service Worker. r=baku,mixedpuppy,asuth
- 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
2021-06-11 18:58:06 +00:00
Alexandru Michis
02d099c20c Backed out 14 changesets (bug 1682632) for causing hazard bustages in ExtensionEventManager.cpp
Backed out changeset c5acc19db606 (bug 1682632)
Backed out changeset 61380029a38b (bug 1682632)
Backed out changeset d3a153070b38 (bug 1682632)
Backed out changeset 8b8bd2385503 (bug 1682632)
Backed out changeset 7fa45afd83a0 (bug 1682632)
Backed out changeset 57652a2152ac (bug 1682632)
Backed out changeset 9195b13525d0 (bug 1682632)
Backed out changeset a647c0cb85e4 (bug 1682632)
Backed out changeset 55553e0dc6ca (bug 1682632)
Backed out changeset c85363089c29 (bug 1682632)
Backed out changeset 6c1f4efb4975 (bug 1682632)
Backed out changeset 9452456d249f (bug 1682632)
Backed out changeset 7b8016e5f3fb (bug 1682632)
Backed out changeset ba742f7e256f (bug 1682632)
2021-06-10 17:28:23 +03:00
Luca Greco
6044ed7443 Bug 1682632 - part3: Restrict Extension API webidl bindings to nightly builds. r=baku,mixedpuppy
Depends on D99887

Differential Revision: https://phabricator.services.mozilla.com/D104707
2021-06-10 09:34:57 +00:00
Luca Greco
93f6c8671b Bug 1682632 - part2.7: ExtensionMockAPI. r=baku
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
2021-06-10 09:34:56 +00:00
Luca Greco
3c26d36ac7 Bug 1682632 - part2.6: ExtensionEventListener callListener sendResponse callback parameter. r=baku,sfink
Depends on D84686

Differential Revision: https://phabricator.services.mozilla.com/D84687
2021-06-10 09:34:55 +00:00
Luca Greco
98ecdeb63c Bug 1682632 - part2.5: ExtensionPort passed as a ExtensionEventListener callListener parameter. r=baku
Depends on D84685

Differential Revision: https://phabricator.services.mozilla.com/D84686
2021-06-10 09:34:55 +00:00
Luca Greco
0320b8de1b Bug 1682632 - part2.4: ExtensionPort. r=baku
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
2021-06-10 09:34:55 +00:00
Luca Greco
9ed95049d2 Bug 1682632 - part2.3: ExtensionEventListener callListener promised return value. r=baku
Depends on D80610

Differential Revision: https://phabricator.services.mozilla.com/D84684
2021-06-10 09:34:54 +00:00
Luca Greco
02cb8a1473 Bug 1682632 - part2.2: ExtensionEventListener xpcom interface base implementation. r=baku,sfink
Depends on D80609

Differential Revision: https://phabricator.services.mozilla.com/D80610
2021-06-10 09:34:54 +00:00