summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
commit0b6210cd37b68b94252cb798598b12974a20e1c1 (patch)
treee371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html
parentInitial commit. (diff)
downloadnode-undici-upstream.tar.xz
node-undici-upstream.zip
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html')
-rw-r--r--test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html b/test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html
new file mode 100644
index 0000000..ca5ee1c
--- /dev/null
+++ b/test/wpt/tests/fetch/security/embedded-credentials.tentative.sub.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+ async_test(t => {
+ var i = document.createElement('img');
+ i.onerror = t.step_func_done();
+ i.onload = t.unreached_func("'onload' should not fire.");
+ i.src = "http://user:pass@{{domains[www]}}:{{ports[http][0]}}/images/red.png";
+ }, "Embedded credentials are treated as network errors.");
+
+ async_test(t => {
+ var i = document.createElement('iframe');
+ i.src = "./support/embedded-credential-window.sub.html";
+ i.onload = t.step_func(_ => {
+ var c = new MessageChannel();
+ c.port1.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, "Error", "The image should not load.");
+ i.remove();
+ });
+ i.contentWindow.postMessage("Hi!", "*", [c.port2]);
+ });
+ document.body.appendChild(i);
+ }, "Embedded credentials are treated as network errors in frames.");
+
+ async_test(t => {
+ var w = window.open("./support/embedded-credential-window.sub.html");
+ window.addEventListener("message", t.step_func(message => {
+ if (message.source != w)
+ return;
+
+ var c = new MessageChannel();
+ c.port1.onmessage = t.step_func_done(e => {
+ w.close();
+ assert_equals(e.data, "Error", "The image should not load.");
+ });
+ w.postMessage("absolute", "*", [c.port2]);
+ }));
+ }, "Embedded credentials are treated as network errors in new windows.");
+
+ async_test(t => {
+ var w = window.open();
+ w.location.href = "http://user:pass@{{domains[www]}}:{{ports[http][0]}}/fetch/security/support/embedded-credential-window.sub.html";
+ window.addEventListener("message", t.step_func(message => {
+ if (message.source != w)
+ return;
+
+ var c = new MessageChannel();
+ c.port1.onmessage = t.step_func_done(e => {
+ w.close();
+ assert_equals(e.data, "Load", "The image should load.");
+ });
+ w.postMessage("relative", "*", [c.port2]);
+ }));
+ }, "Embedded credentials matching the top-level are not treated as network errors for relative URLs.");
+
+ async_test(t => {
+ var w = window.open();
+ w.location.href = "http://user:pass@{{domains[www]}}:{{ports[http][0]}}/fetch/security/support/embedded-credential-window.sub.html";
+ window.addEventListener("message", t.step_func(message => {
+ if (message.source != w)
+ return;
+
+ var c = new MessageChannel();
+ c.port1.onmessage = t.step_func_done(e => {
+ w.close();
+ assert_equals(e.data, "Load", "The image should load.");
+ });
+ w.postMessage("same-origin-matching", "*", [c.port2]);
+ }));
+ }, "Embedded credentials matching the top-level are not treated as network errors for same-origin URLs.");
+
+ async_test(t => {
+ var w = window.open();
+ w.location.href = "http://user:pass@{{domains[www]}}:{{ports[http][0]}}/fetch/security/support/embedded-credential-window.sub.html";
+ window.addEventListener("message", t.step_func(message => {
+ if (message.source != w)
+ return;
+
+ var c = new MessageChannel();
+ c.port1.onmessage = t.step_func_done(e => {
+ w.close();
+ assert_equals(e.data, "Error", "The image should load.");
+ });
+ w.postMessage("cross-origin-matching", "*", [c.port2]);
+ }));
+ }, "Embedded credentials matching the top-level are treated as network errors for cross-origin URLs.");
+</script>