WebIDL compiler should permit `[SecureContext]` on namespaces
Categories
(Core :: DOM: Bindings (WebIDL), enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox129 | --- | fixed |
People
(Reporter: jimb, Assigned: edgar)
References
Details
Attachments
(4 files)
Mozilla's WebIDL compiler should be extended to implement marking WebIDL namespaces for exposure only in secure contexts. Right now that's an error.
The WebIDL for the WebGPU specification places the [SecureContext] extended attribute on namespaces, but Mozilla's WebIDL compiler doesn't implement this at the moment.
The WebGPU spec says things like:
[Exposed=(Window, DedicatedWorker), SecureContext]
namespace GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
const GPUFlagsConstant COMPUTE = 0x4;
};
but if we try to put this in dom/webidl/WebGPU.webidl, we get an error from the WebIDL compiler:
0:02.97 Traceback (most recent call last):
0:02.97 File "<frozen runpy>", line 198, in _run_module_as_main
0:02.97 File "<frozen runpy>", line 88, in _run_code
0:02.97 File "/home/jimb/moz/central/python/mozbuild/mozbuild/action/webidl.py", line 19, in <module>
0:02.97 sys.exit(log_build_task(main, sys.argv[1:]))
0:02.97 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0:02.97 File "/home/jimb/moz/central/python/mozbuild/mozbuild/action/util.py", line 16, in log_build_task
0:02.97 return f(*args, **kwargs)
0:02.97 ^^^^^^^^^^^^^^^^^^
0:02.97 File "/home/jimb/moz/central/python/mozbuild/mozbuild/action/webidl.py", line 15, in main
0:02.97 manager.generate_build_files()
0:02.97 File "/home/jimb/moz/central/dom/bindings/mozwebidlcodegen/__init__.py", line 288, in generate_build_files
0:02.97 self._parse_webidl()
0:02.97 File "/home/jimb/moz/central/dom/bindings/mozwebidlcodegen/__init__.py", line 384, in _parse_webidl
0:02.97 parser.parse(data, path)
0:02.97 File "/home/jimb/moz/central/dom/bindings/parser/WebIDL.py", line 8881, in parse
0:02.97 self._productions.extend(self.parser.parse(lexer=self.lexer, tracking=True))
0:02.97 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0:02.97 File "/home/jimb/moz/central/third_party/python/ply/ply/yacc.py", line 329, in parse
0:02.98 return self.parseopt(input, lexer, debug, tracking, tokenfunc)
0:02.98 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0:02.98 File "/home/jimb/moz/central/third_party/python/ply/ply/yacc.py", line 821, in parseopt
0:02.98 p.callable(pslice)
0:02.98 File "/home/jimb/moz/central/dom/bindings/parser/WebIDL.py", line 7059, in p_Definitions
0:02.98 p[2].addExtendedAttributes(p[1])
0:02.98 File "/home/jimb/moz/central/dom/bindings/parser/WebIDL.py", line 2099, in addExtendedAttributes
0:02.98 raise WebIDLError(
0:02.98 WebIDL.WebIDLError: error: Unknown extended attribute SecureContext on namespace, /home/jimb/moz/central/dom/webidl/WebGPU.webidl line 421:42
0:02.98 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
0:02.98 ^
0:03.19 gmake[4]: *** [Makefile:54: webidl.stub] Error 1
0:03.19 gmake[3]: *** [/home/jimb/moz/central/config/recurse.mk:99: dom/bindings/export] Error 2
| Reporter | ||
Comment 1•3 years ago
|
||
The WebIDL for the WebGPU specification places the [SecureContext] extended attribute on namespaces
... or rather, it will once gpuweb#4002 is merged.
| Assignee | ||
Comment 2•3 years ago
|
||
| Assignee | ||
Comment 3•3 years ago
|
||
Hi Jim, could you help to try if this WIP patch works for WebGPU, though I have not yet checking the generated code.
| Assignee | ||
Updated•2 years ago
|
Comment 4•2 years ago
|
||
Hi, so I just hit that problem.
Without this patch we need to annotate all individual functions with Secure context.
I tried to apply this patch and to annotate the namespace instead of each function, and this works as expected with my code.
I tested building and running the MLS dom tests locally and on try.
https://treeherder.mozilla.org/jobs?repo=try&revision=5ce2c9706c80892112aa6d85eda6deae8ff4736b
I can also confirm that the namespace was not available outside secure contexts by testing on http://example.com.
It would be very helpful if we can land this :)
| Assignee | ||
Comment 5•2 years ago
|
||
Thanks for your help in testing and verifying. I am working on getting this landed.
| Assignee | ||
Comment 6•2 years ago
|
||
| Assignee | ||
Comment 7•2 years ago
|
||
| Assignee | ||
Comment 8•2 years ago
|
||
Updated•2 years ago
|
Comment 10•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/09996ad35c95
https://hg.mozilla.org/mozilla-central/rev/a839f895afed
https://hg.mozilla.org/mozilla-central/rev/70b2d1903a2c
https://hg.mozilla.org/mozilla-central/rev/5e8fc5c0a1d7
Description
•