Skip to content

Commit f5816ba

Browse files
authored
Add some JavaScript inheritance tests. (#4388)
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.
1 parent 71e9fad commit f5816ba

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/webgpu/idl/javascript.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,27 @@ g.test('sameObject')
538538
assert(origValue2.foo === undefined);
539539
}
540540
});
541+
542+
const kClassInheritanceTests: { [key: string]: () => boolean } = {
543+
GPUDevice: () => GPUDevice.prototype instanceof EventTarget,
544+
GPUPipelineError: () => GPUPipelineError.prototype instanceof DOMException,
545+
GPUValidationError: () => GPUValidationError.prototype instanceof GPUError,
546+
GPUOutOfMemoryError: () => GPUOutOfMemoryError.prototype instanceof GPUError,
547+
GPUInternalError: () => GPUInternalError.prototype instanceof GPUError,
548+
GPUUncapturedErrorEvent: () => GPUUncapturedErrorEvent.prototype instanceof Event,
549+
} as const;
550+
551+
g.test('inheritance')
552+
.desc(
553+
`
554+
Test that objects inherit from the correct base class
555+
556+
This is important because apps might patch the base class
557+
and expect instances of these classes to respond correctly.
558+
`
559+
)
560+
.params(u => u.combine('type', keysOf(kClassInheritanceTests)))
561+
.fn(t => {
562+
const fn = kClassInheritanceTests[t.params.type];
563+
t.expect(fn(), fn.toString());
564+
});

0 commit comments

Comments
 (0)