4 <meta charset=
"utf-8" />
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css" />
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();
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
26 const error
= await device
.popErrorScope();
27 ok(error
, "expected error from invalid shader");
28 is(error
.message
, "Shader module creation failed: Parsing error");
30 const compilationInfo
= await shaderModule
.getCompilationInfo();
31 is(compilationInfo
.messages
.length
, 1);
33 const { length
, lineNum
, linePos
, message
, offset
} =
34 compilationInfo
.messages
[0];
41 Shader '' parsing error: expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file, found '?'
45 │ ^ expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file
52 SimpleTest
.waitForExplicitFinish();
54 .catch(e
=> ok(false, "Unhandled exception " + e
))
55 .finally(() => SimpleTest
.finish());