8000 Add some JavaScript inheritance tests. by greggman · Pull Request #4388 · gpuweb/cts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

greggman
Copy link
Contributor

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.

@greggman greggman requested a review from kainino0x May 12, 2025 09:07

const kClassInheritanceTests: { [key: string]: (device: GPUDevice) => [boolean, string] } = {
GPUDevice(device: GPUDevice) {
return [device instanceof EventTarget, 'GPDevice extends EventTarget'];
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator
@kainino0x kainino0x May 12, 2025

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

Copy link
Collaborator

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.

Copy link
Contributor Author
@greggman greggman May 13, 2025

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)

@greggman greggman force-pushed the inheritance-tests branch from 429fb18 to 780987f Compare May 12, 2025 23:39
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.
@greggman greggman force-pushed the inheritance-tests branch from 780987f to f1ab17f Compare May 13, 2025 01:02
@greggman greggman enabled auto-merge (squash) May 13, 2025 01:05
@greggman greggman merged commit f5816ba into gpuweb:main May 13, 2025
1 check passed
@greggman greggman deleted the inheritance-tests branch May 13, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0