summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/crashtests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/webgpu/crashtests
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/webgpu/crashtests')
-rw-r--r--dom/webgpu/crashtests/1809567.html72
-rw-r--r--dom/webgpu/crashtests/crashtests.list1
2 files changed, 73 insertions, 0 deletions
diff --git a/dom/webgpu/crashtests/1809567.html b/dom/webgpu/crashtests/1809567.html
new file mode 100644
index 0000000000..7b922182eb
--- /dev/null
+++ b/dom/webgpu/crashtests/1809567.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+ <body>
+ <script>
+ // The bulk of the test is wrapped in an async function because
+ // the WebGPU API returns promises of adapters and devices,
+ // which we would like to conveniently await.
+ async function orphan_webgpu_device() {
+ // Create an iframe in the same origin as this code.
+ let iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+
+ // Define a function in that iframe that creates a WebGPU
+ // `GPUDevice`.
+ let script = iframe.contentDocument.createElement('script');
+ script.type = 'text/javascript';
+ script.text = `
+ async function create_device() {
+ // WebGPU is not yet available in beta or release.
+ if (!navigator.gpu) {
+ return null;
+ }
+
+ let adapter = await navigator.gpu.requestAdapter({ });
+ // Not all GPUs are capable of supporting WebGPU.
+ if (!adapter) {
+ return null;
+ }
+
+ return await adapter.requestDevice({ });
+ }
+ `;
+ iframe.contentDocument.body.appendChild(script);
+
+ // Call that function to create a `GPUDevice` in the iframe.
+ let device = await iframe.contentWindow.create_device();
+
+ // If we can't run WebGPU in this browser, then we can't reach the crash.
+ if (device) {
+ // Remove the iframe from our document. This closes its window.
+ iframe.remove();
+
+ try {
+ // When a Web API JavaScript object has had its parent window
+ // closed, C++ implementations of its WebIDL methods become unable
+ // to create JavaScript objects as usual: calling
+ // `EventTarget::GetParentObject` returns `nullptr`.
+ //
+ // Since we removed `iframe` from this document, the following
+ // call will fail trying to create a `Promise` of the module's
+ // `GPUCompilationInfo`.
+ device.createShaderModule({ code: '' });
+ } catch (error) {
+ // Eating errors indiscriminately wastes later developers' time.
+ if (error.name != "NS_ERROR_UNEXPECTED") {
+ throw error;
+ }
+ }
+ }
+ }
+
+ orphan_webgpu_device()
+ .catch((error) => {
+ console.log(error);
+ })
+ .finally(() => {
+ // End the crashtest.
+ document.documentElement.removeAttribute("class");
+ });
+ </script>
+ </body>
+</html>
diff --git a/dom/webgpu/crashtests/crashtests.list b/dom/webgpu/crashtests/crashtests.list
new file mode 100644
index 0000000000..4f0094f2a3
--- /dev/null
+++ b/dom/webgpu/crashtests/crashtests.list
@@ -0,0 +1 @@
+load 1809567.html