tor-browser

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

test_compilation_message_pos.html (1951B)


      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 
     19        device.pushErrorScope("validation");
     20        const shaderModule = device.createShaderModule({
     21          // `?` is invalid, and we want to see if the offset will be right with the kitten emoji
     22          // before it.
     23          code: "/*🐈🐈🐈🐈🐈🐈🐈*/?",
     24        });
     25 
     26        const error = await device.popErrorScope();
     27        ok(error, "expected error from invalid shader");
     28        is(error.message, "Shader module creation failed: Parsing error");
     29 
     30        const compilationInfo = await shaderModule.getCompilationInfo();
     31        is(compilationInfo.messages.length, 1);
     32 
     33        const { length, lineNum, linePos, message, offset } =
     34          compilationInfo.messages[0];
     35        is(length, 1);
     36        is(lineNum, 1);
     37        is(linePos, 19);
     38        is(
     39          message,
     40          `
     41 Shader '' parsing error: expected global item (\`struct\`, \`const\`, \`var\`, \`alias\`, \`fn\`, \`diagnostic\`, \`enable\`, \`requires\`, \`;\`) or the end of the file, found "?"
     42  ┌─ wgsl:1:12
     43 
     44 1 │ /*🐈🐈🐈🐈🐈🐈🐈*/?
     45  │                   ^ expected global item (\`struct\`, \`const\`, \`var\`, \`alias\`, \`fn\`, \`diagnostic\`, \`enable\`, \`requires\`, \`;\`) or the end of the file
     46 
     47 `
     48        );
     49        is(offset, 18);
     50      }
     51 
     52      SimpleTest.waitForExplicitFinish();
     53      testBody()
     54        .catch(e => ok(false, "Unhandled exception " + e))
     55        .finally(() => SimpleTest.finish());
     56    </script>
     57  </body>
     58 </html>