forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1865921 Part 2: Add a test that awaits the device.lost promise. r…
…=ErichDonGubler Differential Revision: https://phabricator.services.mozilla.com/D194311
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |