Open mbrodesser-Igalia opened 7 months ago
When debugging this, be aware that https://github.com/web-platform-tests/wpt/issues/44352 will prevent the above error log.
Adding
console.log(
"(e.constructor === constructor)=" + (e.constructor === constructor)
);
console.log("(e instanceof TypeError)=" + (e instanceof TypeError));
console.log("e.constructor.name=" + e.constructor.name);
"(e.constructor === constructor)=true", source: http://web-platform.test:8000/resources/testharness.js (2408)
"(e instanceof TypeError)=true", source: http://web-platform.test:8000/resources/testharness.js (2411)
"e.constructor.name=TypeError", source: http://web-platform.test:8000/resources/testharness.js (2412)
"(e.constructor === constructor)=false", source: http://web-platform.test:8000/resources/testharness.js (2408)
"(e instanceof TypeError)=false", source: http://web-platform.test:8000/resources/testharness.js (2411)
"e.constructor.name=TypeError", source: http://web-platform.test:8000/resources/testharness.js (2412)
It may be relevant for you, test262 takes this case into account in its assert.throws()
function with a specific error message: https://github.com/tc39/test262/blob/837def66ac1700ce398df4a3b4eaeea915aa1df5/harness/assert.js#L87-L94
This is unsurprising, yeah. Use otherIframe.contentWindow.TypeError
or something like that
This is unsurprising, yeah. Use
otherIframe.contentWindow.TypeError
or something like that
@Ms2ger: please explain why it's unsurprising. It's not obvious.
Using
assert_throws_js(otherIframe.contentWindow.TypeError, () => {
// This should throw because trusted types are enabled.
sourceElement.setAttributeNode(sourceAttr);
}); // fails
still fails.
assert_throws_js(sourceFrame.contentWindow.TypeError
works.
Admittedly, I still don't understand why so would be happy to learn about it.
Every realm has its own set of intrinsics, including TypeError
, and JavaScript does not go behind the scenes to match those up when you do instanceof
. So if you have
error from page A → TypeError from page A
error from page B → TypeError from page B
you should by default not assume there's a connection between error from page A
and TypeError from page B
. I hope that clarifies a bit.
Every realm has its own set of intrinsics, including
TypeError
, and JavaScript does not go behind the scenes to match those up when you doinstanceof
. So if you haveerror from page A → TypeError from page A error from page B → TypeError from page B
you should by default not assume there's a connection between
error from page A
andTypeError from page B
. I hope that clarifies a bit.
@Ms2ger: a bit. None of the documentation I read implied that, or I was unable to deduce those implications.
Example:
Error log:
Reproducible with Chrome; Firefox doesn't support Trusted Types yet.
The failure stems from https://searchfox.org/mozilla-central/rev/b4860b54810539f0e4ab1fc46a3246daf2428439/testing/web-platform/tests/resources/testharness.js#2122.
CC @lukewarlow