1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
content / test / data / gpu / webgpu-domain-not-blocked.html [blame]
<script type="text/javascript">
function reportProgress(msg) {
if (window.domAutomationController) {
window.domAutomationController.send(msg);
}
console.log(msg);
}
async function requestDevice() {
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
reportProgress('FAILED');
console.log('TEST FAILED - Could not get a GPUAdapter');
return null;
}
try {
return await adapter.requestDevice();
} catch {
reportProgress('FAILED');
console.log('TEST FAILED - Could not get a GPUDevice');
return null;
}
}
async function init() {
const device = await requestDevice();
if (device == null) {
return;
}
reportProgress('LOADED');
// The test runner forces the GPU process to terminate normally. This should
// NOT result in the domain being blocked.
console.log('Waiting for GPU termination to cause device loss');
const lost = await device.lost;
if (lost.reason !== 'unknown') {
console.log('TEST FAILED - Expected device lost reason "unknown"');
reportProgress('FAILED');
return;
}
try {
// Check that we can acquire a new device successfully.
const newDevice = await requestDevice();
if (newDevice) {
reportProgress('SUCCESS');
return;
}
} catch {
}
}
init();
</script>