summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-locks/crashtests
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/web-locks/crashtests')
-rw-r--r--testing/web-platform/tests/web-locks/crashtests/after-worker-termination.https.html20
-rw-r--r--testing/web-platform/tests/web-locks/crashtests/iframe-append-2.https.html18
-rw-r--r--testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html21
-rw-r--r--testing/web-platform/tests/web-locks/crashtests/settle-after-steal.https.html10
-rw-r--r--testing/web-platform/tests/web-locks/crashtests/worker-termination.https.html16
5 files changed, 85 insertions, 0 deletions
diff --git a/testing/web-platform/tests/web-locks/crashtests/after-worker-termination.https.html b/testing/web-platform/tests/web-locks/crashtests/after-worker-termination.https.html
new file mode 100644
index 0000000000..e113cbdf6a
--- /dev/null
+++ b/testing/web-platform/tests/web-locks/crashtests/after-worker-termination.https.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<meta charset="utf-8">
+<script>
+ const script = `
+ postMessage("hi");
+ // This line runs until worker.terminate() happens, which terminates this function too.
+ self.reportError(new Int16Array(2147483648))
+ // And thus this line runs after the termination.
+ navigator.locks.request("weblock_0", () => {});
+ `;
+ const worker = new Worker(URL.createObjectURL(new Blob([script])));
+ worker.onmessage = () => {
+ worker.terminate();
+
+ // We want to wait for the full termination but there is no API for that
+ // So, just wait for a random time
+ setTimeout(() => document.documentElement.classList.remove("test-wait"), 100);
+ }
+</script>
diff --git a/testing/web-platform/tests/web-locks/crashtests/iframe-append-2.https.html b/testing/web-platform/tests/web-locks/crashtests/iframe-append-2.https.html
new file mode 100644
index 0000000000..06aee518fe
--- /dev/null
+++ b/testing/web-platform/tests/web-locks/crashtests/iframe-append-2.https.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<iframe id="id_0"></iframe>
+<script>
+ window.addEventListener("load", () => {
+ const iframe = document.getElementById("id_0")
+ // Discards the previous document
+ document.documentElement.appendChild(iframe)
+ const xhr = new XMLHttpRequest()
+ // LockManager is created after discarding
+ // At this point the new document is not there yet
+ iframe.contentWindow.navigator.locks.request("weblock_0", () => {
+ xhr.open("GET", "FOOBAR", false)
+ xhr.send()
+ // Now there is a new document
+ })
+ })
+</script>
diff --git a/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html b/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html
new file mode 100644
index 0000000000..507a40d272
--- /dev/null
+++ b/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<meta charset="utf-8">
+<iframe id="id_0"></iframe>
+<script>
+ /** @param {HTMLIFrameElement} iframe */
+ function waitForLoad(iframe) {
+ // iframe is initialized immediately on Chrome while it needs some time on Firefox
+ if (iframe.contentDocument.readyState === "complete") {
+ return;
+ }
+ return new Promise(r => iframe.onload = r);
+ }
+
+ const iframe = document.getElementById("id_0");
+ iframe.contentWindow.navigator.locks.request("weblock_0", async () => {
+ await waitForLoad(iframe);
+ document.body.append(iframe); // discards the document and destroys locks
+ document.documentElement.classList.remove("test-wait");
+ });
+</script>
diff --git a/testing/web-platform/tests/web-locks/crashtests/settle-after-steal.https.html b/testing/web-platform/tests/web-locks/crashtests/settle-after-steal.https.html
new file mode 100644
index 0000000000..6b337e72e9
--- /dev/null
+++ b/testing/web-platform/tests/web-locks/crashtests/settle-after-steal.https.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<html class="test-wait">
+<script>
+ navigator.locks.request("foo", async () => {
+ await new Promise(queueMicrotask);
+ document.documentElement.classList.remove("test-wait");
+ });
+ navigator.locks.request("foo", { steal: true }, () => {});
+</script>
diff --git a/testing/web-platform/tests/web-locks/crashtests/worker-termination.https.html b/testing/web-platform/tests/web-locks/crashtests/worker-termination.https.html
new file mode 100644
index 0000000000..b9b988b36c
--- /dev/null
+++ b/testing/web-platform/tests/web-locks/crashtests/worker-termination.https.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<meta charset="utf-8">
+<script>
+ var worker = new Worker(URL.createObjectURL(new Blob([`
+ postMessage("hi");
+ (async () => {
+ const abort = new AbortController()
+ await navigator.locks.request("weblock_0", { signal: abort.signal }, () => {})
+ })()
+ `])));
+ worker.onmessage = () => {
+ worker.terminate();
+ document.documentElement.classList.remove("test-wait");
+ };
+</script>