diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/secure-contexts/support | |
parent | Initial commit. (diff) | |
download | firefox-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 'testing/web-platform/tests/secure-contexts/support')
7 files changed, 108 insertions, 0 deletions
diff --git a/testing/web-platform/tests/secure-contexts/support/dedicated-worker-script.js b/testing/web-platform/tests/secure-contexts/support/dedicated-worker-script.js new file mode 100644 index 0000000000..69ffdf3442 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/dedicated-worker-script.js @@ -0,0 +1 @@ +postMessage(isSecureContext); diff --git a/testing/web-platform/tests/secure-contexts/support/https-subframe-dedicated.html b/testing/web-platform/tests/secure-contexts/support/https-subframe-dedicated.html new file mode 100644 index 0000000000..bcf27879e8 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/https-subframe-dedicated.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<script src="../server-locations.sub.js"></script> +<script> + try { + var w1 = new Worker(http_dir + "support/dedicated-worker-script.js"); + w1.onmessage = function(e) { + parent.postMessage({ type: "http", error: false, + isSecureContext: e.data }, "*"); + }; + w1.onerror = function(e) { + parent.postMessage({ type: "http", error: true }, "*"); + }; + } catch (e) { + // Some browsers throw for cross-origin URLs. This violates the Worker spec, + // but isn't actually relevant to what we're testing here. + parent.postMessage({ type: "http", error: true }, "*"); + } + + try { + var w2 = new Worker(https_dir + "support/dedicated-worker-script.js"); + w2.onmessage = function(e) { + parent.postMessage({ type: "https", error: false, + isSecureContext: e.data }, "*"); + }; + w2.onerror = function(e) { + parent.postMessage({ type: "https", error: true }, "*"); + } + } catch (e) { + // Some browsers throw for cross-origin URLs. This violates the Worker spec, + // but isn't actually relevant to what we're testing here. + parent.postMessage({ type: "https", error: true }, "*"); + } +</script> diff --git a/testing/web-platform/tests/secure-contexts/support/https-subframe-shared.html b/testing/web-platform/tests/secure-contexts/support/https-subframe-shared.html new file mode 100644 index 0000000000..5ae7cde5b0 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/https-subframe-shared.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<script> + try { + var w = new SharedWorker("shared-worker-script.js"); + w.port.onmessage = function(e) { + parent.postMessage({ type: "shared", error: false, exception: false, + isSecureContext: e.data }, "*"); + }; + w.onerror = function(e) { + parent.postMessage({ type: "shared", error: true, exception: false }, + "*"); + } + w.port.start(); + } catch (e) { + parent.postMessage({ type: "shared", exception: true }, "*"); + } + + try { + var w = new SharedWorker("parent-shared-worker-script.js"); + w.port.onmessage = function(e) { + parent.postMessage({ type: "nested", error: false, exception: false, + isSecureContext: e.data }, "*"); + }; + w.onerror = function(e) { + parent.postMessage({ type: "nested", error: true, exception: false }, + "*"); + } + w.port.start(); + } catch (e) { + parent.postMessage({ type: "nested", exception: true }, "*"); + } +</script> diff --git a/testing/web-platform/tests/secure-contexts/support/parent-dedicated-worker-script.js b/testing/web-platform/tests/secure-contexts/support/parent-dedicated-worker-script.js new file mode 100644 index 0000000000..2b67432384 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/parent-dedicated-worker-script.js @@ -0,0 +1,9 @@ +// If nested workers aren't supported, punt: +if (typeof Worker != "undefined") { + var w = new Worker("dedicated-worker-script.js"); + w.onmessage = function (e) { + postMessage(e.data); + } +} else { + postMessage("Nested workers not supported."); +} diff --git a/testing/web-platform/tests/secure-contexts/support/parent-shared-worker-script.js b/testing/web-platform/tests/secure-contexts/support/parent-shared-worker-script.js new file mode 100644 index 0000000000..083564a054 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/parent-shared-worker-script.js @@ -0,0 +1,13 @@ +addEventListener("connect", function (e) { + var port = e.ports[0]; + port.start(); + // If nested workers aren't supported, punt: + if (typeof Worker != "undefined") { + var w = new Worker("dedicated-worker-script.js"); + w.onmessage = function (e) { + port.postMessage(e.data); + } + } else { + port.postMessage("Nested workers not supported."); + } +}); diff --git a/testing/web-platform/tests/secure-contexts/support/shared-worker-insecure-popup.html b/testing/web-platform/tests/secure-contexts/support/shared-worker-insecure-popup.html new file mode 100644 index 0000000000..740679dc4f --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/shared-worker-insecure-popup.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<script src="../server-locations.sub.js"></script> +<body> + <script> + var url = self[location.search.substr(1)] + "support/https-subframe-shared.html"; + onmessage = function(e) { + var data = e.data; + data.fromPopup = true; + opener.postMessage(data, "*"); + } + var ifr = document.createElement("iframe"); + ifr.src = url; + document.body.appendChild(ifr); + </script> +</body> diff --git a/testing/web-platform/tests/secure-contexts/support/shared-worker-script.js b/testing/web-platform/tests/secure-contexts/support/shared-worker-script.js new file mode 100644 index 0000000000..faed70a5c8 --- /dev/null +++ b/testing/web-platform/tests/secure-contexts/support/shared-worker-script.js @@ -0,0 +1,5 @@ +addEventListener("connect", function (e) { + var port = e.ports[0]; + port.start(); + port.postMessage(isSecureContext); +}); |