-
Notifications
You must be signed in to change notification settings - Fork 92
Add some JavaScript inheritance tests. #4388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/webgpu/idl/javascript.spec.ts
Outdated
|
||
const kClassInheritanceTests: { [key: string]: (device: GPUDevice) => [boolean, string] } = { | ||
GPUDevice(device: GPUDevice) { | ||
return [device instanceof EventTarget, 'GPDevice extends EventTarget']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional nit: Could be GPUDevice.prototype instanceof EventTarget
, then you don't need to pass a device to test this.
Actually if you did this for all of them then you wouldn't even need custom constructor code for each one, since you wouldn't need to construct them.
I'm not sure if this would result in less complete test coverage though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want to require that the next parent be specific. We just want to require that a specific parent is somewhere higher in the prototype chain. I could walk the chain but that's what instanceof
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this still walk the chain? It still uses instanceof
. It just uses the prototype object instead of real one so you don't need to have a real one.
> class A {}
> class B extends A {}
> class C extends B {}
> C.prototype instanceof A
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think it actually would be fine to require the parent be specific. That's what the spec says, and inserting an extra thing in the chain can break code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched it to Derived.prototype instanceof Base
as you suggested. I didn't require direct parent inheritance though we can add that if important.
This is appearing to be problematic for node plugins. Also, while here, there is no DOMException
in node which means we have to make one but that may or may not match anything the user creates (like if they use the jsdom library)
429fb18
to
780987f
Compare
This is mostly for non-browser implementations to pass. dawn.node passes none of these. Working on getting it pass all of them. This is related to it correctly handling events.
780987f
to
f1ab17f
Compare
This is mostly for non-browser implementations to pass. dawn.node passes none of these. Working on getting it pass all of them. This is related to it correctly handling events.