forked from mirrors/gecko-dev
Bug 1865921 Part 2: Add a test that awaits the device.lost promise. r=ErichDonGubler
This also drive-by marks all WebGPU mochitests as failing on macos, to honor the current status of the blocklist. Differential Revision: https://phabricator.services.mozilla.com/D194311
This commit is contained in:
parent
7c0d0c224a
commit
4b3e64252c
2 changed files with 83 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ fail-if = [
|
|||
["test_buffer_mapping_invalid_device.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_command_buffer_creation.html"]
|
||||
|
|
@ -43,6 +44,7 @@ fail-if = [
|
|||
["test_context_configure.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_device_creation.html"]
|
||||
|
|
@ -51,9 +53,16 @@ fail-if = [
|
|||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_device_lost.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_double_encoder_finish.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_enabled.html"]
|
||||
|
|
@ -85,6 +94,7 @@ fail-if = [
|
|||
["test_queue_write_invalid_device.html"]
|
||||
fail-if = [
|
||||
"os == 'linux' && os_version == '18.04'",
|
||||
"os == 'mac'",
|
||||
]
|
||||
|
||||
["test_submit_compute_empty.html"]
|
||||
|
|
|
|||
73
dom/webgpu/mochitest/test_device_lost.html
Normal file
73
dom/webgpu/mochitest/test_device_lost.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!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 destroy_causes_lost = async function () {
|
||||
const adapter = await navigator.gpu.requestAdapter();
|
||||
ok(adapter !== undefined, "adapter !== undefined");
|
||||
const device = await adapter.requestDevice();
|
||||
ok(device !== undefined, "device !== undefined");
|
||||
|
||||
const lostPromise = device.lost;
|
||||
device.destroy();
|
||||
const deviceLostReason = await lostPromise;
|
||||
|
||||
is(
|
||||
deviceLostReason.reason,
|
||||
"destroyed",
|
||||
"Destroy reason should correspond to GPUDeviceLostReason.destroyed"
|
||||
);
|
||||
is(deviceLostReason.message, "", "Destroy message should be blank");
|
||||
};
|
||||
|
||||
const drop_causes_lost_is_unobservable = async function () {
|
||||
const adapter = await navigator.gpu.requestAdapter();
|
||||
ok(adapter !== undefined, "adapter !== undefined");
|
||||
|
||||
let lostPromise;
|
||||
// Create a scope with a device that will go out of scope
|
||||
// and then be dropped.
|
||||
{
|
||||
const device = await adapter.requestDevice();
|
||||
ok(device !== undefined, "device !== undefined");
|
||||
|
||||
lostPromise = device.lost;
|
||||
}
|
||||
|
||||
SimpleTest.requestFlakyTimeout(
|
||||
"Racing against promise that should never resolve."
|
||||
);
|
||||
const TIMEOUT_MS = 5000;
|
||||
let timeoutPromise = new Promise(resolve => {
|
||||
let timeoutValue = { reason: "timeout" };
|
||||
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||
setTimeout(() => resolve(timeoutValue), TIMEOUT_MS);
|
||||
});
|
||||
|
||||
const firstPromise = await Promise.race([lostPromise, timeoutPromise]);
|
||||
is(
|
||||
firstPromise.reason,
|
||||
"timeout",
|
||||
"timeoutPromise should return before lostPromise."
|
||||
);
|
||||
};
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
destroy_causes_lost()
|
||||
.then(() => drop_causes_lost_is_unobservable())
|
||||
.catch(e => ok(false, `Unhandled exception ${e}`))
|
||||
.finally(() => SimpleTest.finish());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue