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 let buffer
= device
.createBuffer({
21 usage
: GPUBufferUsage
.MAP_READ
,
22 mappedAtCreation
: true,
24 let view1
= buffer
.getMappedRange(16, 24);
26 function bad_overlap(start
, size
, complaint
) {
27 SimpleTest
.doesThrow(() => {
28 buffer
.getMappedRange(start
, size
);
32 bad_overlap(8, 16, "overlap start of prior");
33 bad_overlap(32, 16, "overlap end of prior");
34 bad_overlap(8, 40, "enclose prior");
35 bad_overlap(24, 8, "enclosed by prior");
37 // Not really an overlap, but this checks for a mistake in
38 // an early revision of the patch that introduces this test.
39 SimpleTest
.doesThrow(() => {
40 buffer
.getMappedRange(64, 8);
41 }, "offset beyond mapped range");
45 typeof buffer
.getMappedRange(0, 16) == "object",
48 ok(typeof buffer
.getMappedRange(40, 8) == "object", "no overlap after");
51 SimpleTest
.waitForExplicitFinish();
53 .catch(e
=> ok(false, "Unhandled exception " + e
))
54 .finally(() => SimpleTest
.finish());