Bug 1945965 – remove new tab April Fools logo. r=home-newtab-reviewers,reemhamz
[gecko.git] / dom / webgpu / mochitest / test_buffer_mapping_invalid_device.html
blob49d3d9ec2c729db00e8986a562dbeb7d885b661c
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
7 </head>
8 <body>
9 <script>
10 ok(
11 SpecialPowers.getBoolPref("dom.webgpu.enabled"),
12 "Pref should be enabled."
15 async function testBody() {
16 const adapter = await navigator.gpu.requestAdapter({});
17 const device = await adapter.requestDevice({});
18 const bindGroupLayout = device.createBindGroupLayout({
19 entries: [
21 binding: 256,
22 storageTexture: { format: "bc1-rgba-unorm-srgb" },
23 visibility: GPUShaderStage.FRAGMENT,
26 });
27 const buffer1 = device.createBuffer({
28 size: 32,
29 usage: GPUBufferUsage.MAP_READ,
30 });
32 // Call device.destroy, which makes the device invalid. Further object creation
33 // on device will create objects that are also invalid.
34 device.destroy();
36 // Create an invalid buffer2.
37 const buffer2 = device.createBuffer({
38 size: 32,
39 usage: GPUBufferUsage.MAP_WRITE,
40 });
42 // Create an invalid bind group, referencing invalid buffer2.
43 const bindGroup = device.createBindGroup({
44 layout: bindGroupLayout,
45 entries: [
46 { binding: 1, resource: { buffer: buffer1 } },
47 { binding: 2, resource: { buffer: buffer2 } },
49 });
51 ok(bindGroup, "Created a bind group referencing an invalid buffer.");
54 SimpleTest.waitForExplicitFinish();
55 testBody()
56 .catch(e => ok(false, "Unhandled exception " + e))
57 .finally(() => SimpleTest.finish());
58 </script>
59 </body>
60 </html>