Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up"Named constructor without 'new'" WPT failures #25394
Comments
|
The test is here: servo/tests/wpt/web-platform-tests/resources/idlharness.js Lines 1877 to 1890 in 8002c6b https://heycam.github.io/webidl/#named-constructors 1.1 seems to be the verbiage referred to; the substeps of 1 here are the steps for the constructor function itself. |
|
We're missing the equivalent code for https://searchfox.org/mozilla-central/rev/c79fc6e32a5b561205a71fcfef9112d34b4037ae/dom/bindings/Codegen.py#1875-1895 in servo/components/script/dom/bindings/codegen/CodegenRust.py Lines 5741 to 5746 in 8002c6b |
|
That's https://doc.servo.org/mozjs/jsapi/struct.CallArgs.html#method.constructing_ from the |
|
servo/components/script/dom/bindings/codegen/CodegenRust.py Lines 5678 to 5682 in 8002c6b |
|
That code only runs in HTML element constructors, though: . That will be more clear when #25395 is fixed. |
Servo's implementations of named constructors, for Audio and Image (and Option after #25393), aren't throwing an exception when they're called like normal functions; for comparison try typing just Image() without 'new' into the Firefox console. https://html.spec.whatwg.org/#dom-image specifies "When invoked, the constructor must perform the following steps"; what it seems to actually mean here is when invoked /as a constructor/, via new, not just with a regular function call. Within Javascript itself this distinction is detectable via the special expression "new.target", as described in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target ; I don't know what the mozjs equivalent is.