tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_buffer_mapping_invalid_device.html (1827B)


      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."
     13      );
     14 
     15      async function testBody() {
     16        const adapter = await navigator.gpu.requestAdapter({});
     17        const device = await adapter.requestDevice({});
     18        const bindGroupLayout = device.createBindGroupLayout({
     19          entries: [
     20            {
     21              binding: 256,
     22              storageTexture: { format: "bc1-rgba-unorm-srgb" },
     23              visibility: GPUShaderStage.FRAGMENT,
     24            },
     25          ],
     26        });
     27        const buffer1 = device.createBuffer({
     28          size: 32,
     29          usage: GPUBufferUsage.MAP_READ,
     30        });
     31 
     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();
     35 
     36        // Create an invalid buffer2.
     37        const buffer2 = device.createBuffer({
     38          size: 32,
     39          usage: GPUBufferUsage.MAP_WRITE,
     40        });
     41 
     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 } },
     48          ],
     49        });
     50 
     51        ok(bindGroup, "Created a bind group referencing an invalid buffer.");
     52      }
     53 
     54      SimpleTest.waitForExplicitFinish();
     55      testBody()
     56        .catch(e => ok(false, "Unhandled exception " + e))
     57        .finally(() => SimpleTest.finish());
     58    </script>
     59  </body>
     60 </html>