tor-browser

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

test_queue_write.html (1531B)


      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      const func = async function () {
     16        const adapter = await navigator.gpu.requestAdapter();
     17        const device = await adapter.requestDevice();
     18        const buffer = device.createBuffer({
     19          size: 16,
     20          usage:
     21            GPUBufferUsage.COPY_DST |
     22            GPUBufferUsage.COPY_SRC |
     23            GPUBufferUsage.VERTEX,
     24        });
     25        const arrayBuf = new ArrayBuffer(16);
     26        new Int32Array(arrayBuf).fill(5);
     27        device.queue.writeBuffer(buffer, 0, arrayBuf, 0);
     28        const texture = device.createTexture({
     29          size: [2, 2, 1],
     30          dimension: "2d",
     31          format: "rgba8unorm",
     32          usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
     33        });
     34        device.queue.writeTexture(
     35          { texture },
     36          arrayBuf,
     37          { bytesPerRow: 8 },
     38          [2, 2, 1]
     39        );
     40        // this isn't a process check, we need to read back the contents and verify the writes happened
     41        ok(device !== undefined, "");
     42      };
     43 
     44      SimpleTest.waitForExplicitFinish();
     45      func()
     46        .catch(e => ok(false, "Unhandled exception " + e))
     47        .finally(() => SimpleTest.finish());
     48    </script>
     49  </body>
     50 </html>