Fix conversion to WebIDL for API methods with a JSONSchema definition that includes an optional parameters followed by non optional ones
Categories
(WebExtensions :: General, task, P1)
Tracking
(firefox100 fixed)
Tracking | Status | |
---|---|---|
firefox100 | --- | fixed |
People
(Reporter: rpl, Assigned: rpl)
References
(Blocks 1 open bug)
Details
(Whiteboard: [addons-jira])
Attachments
(4 files)
As part of Bug 1724026 we are going to run alarms
API xpcshell tests also on the background service worker and Extensions WebIDL API bindings and one of the test was failure because the type signature of the alarms.create
method as defined in ExtensionAlarms.webidl did not allow to call the method with a single parameter, while the current implementation of the Extensions APIs allows that.
The JSONSchema related to the alarms.create
API method is:
{
"name": "create",
"type": "function",
...
"parameters": [
{ "name": "name", "optional": true, ... },
{ "type": "object", "name": "alarmInfo", ... }
]
},
and the toolkit/components/extensions/webidl-api/GenerateWebIDLBindings.py converted that into a function part of the ExtensionAlarms.webidl
file with the following type signature:
[Throws, WebExtensionStub="NoReturn"]
void create(optional DOMString name, any alarmInfo);
At a first glance the two definitions may look the same, but they actually behave differently because the WebIDL one does not actually allow to pass only a single parameter.
On the contrary generating two create
methods (one with only the second parameter and one with both) would make browser.alarms.create
to behave has the current bindings implementation (and without any additional change, the same NoReturn
stub can be used for both and ext-alarms.js will be handling the two cases exactly as in the current bindings implementation):
[Throws, WebExtensionStub="NoReturn"]
void create(DOMString name, any alarmInfo);
[Throws, WebExtensionStub="NoReturn"]
void create(any alarmInfo);
This will likely be the case also for other API methods, we should update the python script to detect this kind of JSONSchema and generate multiple definitions of the same method as the snippet above.
Updated•3 years ago
|
Assignee | ||
Comment 1•3 years ago
|
||
Assignee | ||
Comment 2•3 years ago
|
||
Depends on D135419
Assignee | ||
Comment 3•3 years ago
•
|
||
While looking into this and also took the opportunity to use the python script to print a list of the other API methods which will need similar multiple type signatures:
notifications.create
alarms.create
theme.update
tabs.update
tabs.executeScript
tabs.insertCSS
tabs.removeCSS
tabs.setZoom
tabs.setZoomSettings
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 4•3 years ago
|
||
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.
Depends on D135420
Assignee | ||
Comment 5•3 years ago
|
||
ExtensionRuntime does also include some APIs that would need multiple signatures for the WebIDL methods
with optional parameters to match the behavior of the current Extensions API bindings.
Depends on D136951
Comment 7•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4896da925e83
https://hg.mozilla.org/mozilla-central/rev/d29943b5e5fd
https://hg.mozilla.org/mozilla-central/rev/a94f5b8ebdaa
https://hg.mozilla.org/mozilla-central/rev/55e7751e8395
Description
•