Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / webgpu / mochitest / test_buffer_mapping_overlapping_views.html
blobc6c6a1c8d1afece951bc83497a1efbe125f76c51
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."
15 async function testBody() {
16 const adapter = await navigator.gpu.requestAdapter();
17 const device = await adapter.requestDevice();
19 let buffer = device.createBuffer({
20 size: 48,
21 usage: GPUBufferUsage.MAP_READ,
22 mappedAtCreation: true,
23 });
24 let view1 = buffer.getMappedRange(16, 24);
26 function bad_overlap(start, size, complaint) {
27 SimpleTest.doesThrow(() => {
28 buffer.getMappedRange(start, size);
29 }, complaint);
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");
43 // should be fine
44 ok(
45 typeof buffer.getMappedRange(0, 16) == "object",
46 "no overlap before"
48 ok(typeof buffer.getMappedRange(40, 8) == "object", "no overlap after");
51 SimpleTest.waitForExplicitFinish();
52 testBody()
53 .catch(e => ok(false, "Unhandled exception " + e))
54 .finally(() => SimpleTest.finish());
55 </script>
56 </body>
57 </html>