Skip to content

Commit

Permalink
Bug 1865921 Part 2: Add a test that awaits the device.lost promise. r…
Browse files Browse the repository at this point in the history
…=ErichDonGubler

Differential Revision: https://phabricator.services.mozilla.com/D194311
  • Loading branch information
bradwerth committed Dec 5, 2023
1 parent baa0ba8 commit 1d7f4f9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dom/webgpu/mochitest/mochitest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ fail-if = [
"os == 'mac'",
]

["test_device_lost.html"]
fail-if = [
"os == 'linux' && os_version == '18.04'",
]

["test_double_encoder_finish.html"]
fail-if = [
"os == 'linux' && os_version == '18.04'",
Expand Down
40 changes: 40 additions & 0 deletions dom/webgpu/mochitest/test_device_lost.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
ok(
SpecialPowers.getBoolPref("dom.webgpu.enabled"),
"Pref should be enabled."
);

const func = async function () {
const adapter = await navigator.gpu.requestAdapter();
const limits = adapter.limits;
const features = adapter.features;
const device = await adapter.requestDevice();
ok(device !== undefined, "device !== undefined");

const lostPromise = device.lost;
device.destroy();
const deviceLostReason = await lostPromise;

is(
deviceLostReason.reason,
"destroyed",
"Reason should correspond to GPUDeviceLostReason.destroyed"
);
is(deviceLostReason.message, "", "Message should be blank");
};

SimpleTest.waitForExplicitFinish();
func()
.catch(e => ok(false, "Unhandled exception " + e))
.finally(() => SimpleTest.finish());
</script>
</body>
</html>

0 comments on commit 1d7f4f9

Please sign in to comment.