Update web-platform-tests to revision 936827a6527f1c53051d3bc5bc79304c88c0737f

This commit is contained in:
WPT Sync Bot 2019-08-16 10:23:22 +00:00
parent c585f4fff5
commit 02a68a38f0
338 changed files with 14862 additions and 2933 deletions

View file

@ -11,57 +11,63 @@
}
</style>
<div id="log"></div>
<iframe></iframe>
<script>
'use strict';
// The test does the following navigation steps for iframe
// 1. load page-with-fragment.html#fragment
// 2. load blank1
// 3. go back to page-with-fragment.html
async_test(function(t) {
var iframe = document.querySelector('iframe');
var hostInfo = get_host_info();
var basePath = location.pathname.substring(0, location.pathname.lastIndexOf('/'));
var localURL = hostInfo.HTTP_ORIGIN + basePath + '/resources/page-with-fragment.html#fragment';
var remoteURL = hostInfo.HTTP_REMOTE_ORIGIN + basePath + "/resources/blank1.html"
var next;
function frameOnload() {
if (next) {
next();
dump("next \n");
} else {
dump("no next \n");
// The test does the following navigation steps for iframe
// 1. load page-with-fragment.html#fragment
// 2. load blank1
// 3. go back to page-with-fragment.html
async_test(function(t) {
var iframe = document.querySelector('iframe');
var hostInfo = get_host_info();
var basePath = location.pathname.substring(0, location.pathname.lastIndexOf('/'));
var localURL = hostInfo.HTTP_ORIGIN + basePath + '/resources/page-with-fragment.html#fragment';
var remoteURL = hostInfo.HTTP_REMOTE_ORIGIN + basePath + "/resources/blank1.html"
var steps = [
function() {
iframe.src = 'resources/page-with-fragment.html#fragment';
}, function() {
assert_equals(iframe.contentWindow.location.href, localURL, 'should be on page-with-fragment page');
// wait one animation frame to ensure layout is run and fragment scrolling is complete
iframe.contentWindow.requestAnimationFrame(function() {
assert_equals(iframe.contentWindow.scrollY, 800, 'should scroll to fragment');
var steps = [
function() {
assert_equals(iframe.contentWindow.location.href, localURL, 'should be on page-with-fragment page');
// wait one animation frame to ensure layout is run and fragment scrolling is complete
iframe.contentWindow.requestAnimationFrame(function() {
assert_approx_equals(iframe.contentWindow.scrollY, 800, 5, 'should scroll to fragment');
iframe.contentWindow.history.scrollRestoration = 'manual';
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
setTimeout(next, 0);
iframe.contentWindow.history.scrollRestoration = 'manual';
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
setTimeout(next, 0);
});
}, function() {
// navigate to a new page from a different origin
iframe.src = remoteURL;
}, function() {
// going back causes the iframe to traverse back
history.back();
}, function() {
// coming back from history, scrollRestoration should be set to manual and respected
assert_equals(iframe.contentWindow.location.href, localURL, 'should be back on page-with-fragment page');
iframe.contentWindow.requestAnimationFrame(t.step_func_done(function() {
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll to fragment');
assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll to fragment');
}));
}
];
var stepCount = 0;
next = t.step_func(function() {
steps[stepCount++]();
});
}, function() {
// navigate to a new page from a different origin
iframe.src = remoteURL;
}, function() {
// going back causes the iframe to traverse back
history.back();
}, function() {
// coming back from history, scrollRestoration should be set to manual and respected
assert_equals(iframe.contentWindow.location.href, localURL, 'should be back on page-with-fragment page');
iframe.contentWindow.requestAnimationFrame(t.step_func_done(function() {
assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll to fragment');
assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll to fragment');
}));
}
];
var stepCount = 0;
var next = t.step_func(function() {
steps[stepCount++]();
});
iframe.onload = next;
next();
}, 'Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation');
next();
}, 'Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation');
}
}
</script>
<iframe src="resources/page-with-fragment.html#fragment" onload="frameOnload()"></iframe>

View file

@ -0,0 +1 @@
See `../cross-origin-opener-policy/README.md`.

View file

@ -0,0 +1,44 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<div id=log></div>
<script>
const origins = get_host_info();
[
{
"origin": origins.HTTPS_ORIGIN,
"crossOrigin": origins.HTTPS_REMOTE_ORIGIN
},
{
"origin": origins.HTTPS_REMOTE_ORIGIN,
"crossOrigin": origins.HTTPS_NOTSAMESITE_ORIGIN
},
{
"origin": origins.HTTPS_NOTSAMESITE_ORIGIN,
"crossOrigin": origins.HTTPS_ORIGIN
}
].forEach(({ origin, crossOrigin }) => {
["subframe", "navigate"].forEach(variant => {
async_test(t => {
const id = token();
const frame = document.createElement("iframe");
t.add_cleanup(() => { frame.remove(); });
const path = new URL("resources/blob-url-factory.html", window.location).pathname;
frame.src = `${origin}${path}?id=${id}&variant=${variant}&crossOrigin=${crossOrigin}`;
window.addEventListener("message", t.step_func(({ data }) => {
if (data.id !== id) {
return;
}
assert_equals(data.origin, origin);
assert_true(data.sameOriginNoCORPSuccess, "Same-origin without CORP did not succeed");
assert_true(data.crossOriginNoCORPFailure, "Cross-origin without CORP did not fail");
t.done();
}));
document.body.append(frame);
}, `Cross-Origin-Embedder-Policy and blob: URL from ${origin} in subframe via ${variant}`);
});
});
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,20 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/script-factory.js"></script>
<div id=log></div>
<script>
async_test(t => {
window.addEventListener("message", t.step_func_done(({ data }) => {
assert_equals(data.id, "");
assert_equals(data.origin, "null");
assert_false(data.sameOriginNoCORPSuccess); // This is effectively a no-op for this test
assert_true(data.crossOriginNoCORPFailure, "Cross-origin without CORP did not fail");
}));
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
frame.src = `data:text/html,${createScript("null", window.origin)}`;
document.body.append(frame);
}, "Cross-Origin-Embedder-Policy and data: URLs");
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,21 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
let i = 0;
frame.onload = t.step_func(() => {
i++;
assert_equals(frame.contentDocument.URL, "about:blank");
frame.src = "about:blank";
if (i == 2) {
t.done();
}
});
document.body.append(frame);
}, "Cross-Origin-Embedder-Policy and about:blank");
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,79 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin-Embedder-Policy header and nested navigable resource without such header</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/utils.js></script> <!-- Use token() to allow running tests in parallel -->
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
frame.onload = t.step_func_done(() => {
assert_not_equals(frame.contentDocument, null);
});
frame.src = "/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, `"none" top-level: navigating a frame to "none" should succeed`);
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
const blank = "/common/blank.html";
let firstNavOk = false;
frame.onload = t.step_func(() => {
if (!firstNavOk) {
assert_not_equals(frame.contentDocument, null);
firstNavOk = true;
} else {
assert_not_equals(frame.contentDocument, null);
assert_equals(frame.contentWindow.location.pathname, blank);
t.done();
}
});
frame.src = `resources/navigate-require-corp.sub.html?to=${blank}`;
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, `"none" top-level: navigating a frame from "require-corp" to "none" should succeed`);
async_test(t => {
const w = window.open(`resources/navigate-none.sub.html?to=navigate-require-corp.sub.html`, "window_name");
t.add_cleanup(() => w.close());
t.step_timeout(() => {
w.history.back();
t.step_timeout(() => {
assert_not_equals(w.document, null);
t.done();
}, 500);
}, 500);
}, `"none" top-level: navigating a frame back from "require-corp" should succeed`);
async_test(t => {
let pageLoaded = false;
const bc = new BroadcastChannel(token());
let finished = false;
bc.onmessage = t.step_func((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const bc2 = new BroadcastChannel(token());
bc2.onmessage = t.step_func((event) => {
finished = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const win = window.open(`resources/navigate-require-corp.sub.html?channelName=${bc.name}&to=navigate-none.sub.html?channelName=${bc2.name}`, "_blank", "noopener");
assert_equals(win, null);
t.step_timeout(() => {
assert_true(pageLoaded);
assert_true(finished);
t.done();
}, 500);
}, `"require-corp" top-level noopener popup: navigating to "none" should succeed`);
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: unknown-should-be-parsed-as-null

View file

@ -0,0 +1,138 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin-Embedder-Policy header and nested navigable resource without such header</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
t.step_timeout(() => {
// Make sure the iframe didn't load. See https://github.com/whatwg/html/issues/125 for why a
// timeout is used here. Long term all network error handling should be similar and have a
// reliable event.
assert_equals(frame.contentDocument, null);
t.done();
}, 500);
frame.src = "/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, `"require-corp" top-level: navigating a frame to "none" should fail`);
async_test(t => {
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
const bc = new BroadcastChannel(token());
bc.onmessage = t.step_func((event) => {
assert_not_equals(frame.contentDocument, null);
let payload = event.data;
assert_equals(payload, "loaded");
t.step_timeout(() => {
assert_equals(frame.contentDocument, null);
t.done();
}, 500);
});
frame.src = `resources/navigate-require-corp.sub.html?channelName=${bc.name}&to=/common/blank.html`;
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, `"require-corp" top-level: navigating a frame from "require-corp" to "none" should fail`);
async_test(t => {
let pageLoaded = false;
const bc = new BroadcastChannel(token());
let finished = false;
bc.onmessage = t.step_func((event) => {
let payload = event.data;
assert_equals(payload, "loaded");
pageLoaded = true;
});
const bc2 = new BroadcastChannel(token());
bc2.onmessage = t.step_func_done((event) => {
let payload = event.data;
assert_equals(payload, "loaded");
assert_equals(pageLoaded, true);
});
const win = window.open(`resources/navigate-none.sub.html?channelName=${bc.name}&to=navigate-none.sub.html?channelName=${bc2.name}`, "_blank", "noopener");
assert_equals(win, null);
}, `"require-corp" top-level: creating a noopener "none" popup should succeed`);
async_test(t => {
let pageLoaded = false;
const bc = new BroadcastChannel(token());
bc.onmessage = t.step_func_done((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const win = window.open(`resources/navigate-none.sub.html?channelName=${bc.name}&to=/common/blank.html`, "_blank");
t.add_cleanup(() => win.close());
t.step_timeout(() => {
assert_equals(pageLoaded, true);
t.done();
}, 500);
}, `"require-corp" top-level: creating a "none" popup should succeed.`);
[
{
"name": "",
"title": "as popup"
},
{
"name": "noopener",
"title": "as noopener popup"
},
{
"name": "clear opener",
"title": "as popup with opener set to null"
}
].forEach(({name, title}) => {
async_test(t => {
let pageLoaded = false;
const bc = new BroadcastChannel(token());
bc.onmessage = t.step_func(event => {
pageLoaded = true;
const payload = event.data;
assert_equals(payload, "loaded");
});
const bc2 = new BroadcastChannel(token());
bc2.onmessage = t.step_func_done(event => {
const payload = event.data;
assert_equals(payload, "loaded");
assert_equals(pageLoaded, true);
});
let clearOpener = "";
if (name === "clear opener") {
clearOpener = "&clearOpener=true"
}
let noopener = undefined;
if (name === "noopener") {
noopener = "noopener"
}
const win = window.open(`resources/navigate-require-corp.sub.html?channelName=${bc.name}${clearOpener}&to=navigate-none.sub.html?channelName=${bc2.name}`, "_blank", noopener);
if (name === "noopener") {
assert_equals(win, null);
} else {
t.add_cleanup(() => win.close());
}
}, `"require-corp" top-level (${title}): navigating to "none" should succeed`);
});
promise_test(async t => {
const response = await fetch(get_host_info().HTTPS_REMOTE_ORIGIN+"/html/cross-origin-embedder-policy/resources/nothing-cross-origin-corp.txt", {mode: "no-cors"});
assert_equals(response.type, "opaque");
}, `"require-corp" top-level: fetch() to CORP: cross-origin response should succeed`);
promise_test(t => {
return promise_rejects(t, new TypeError(), fetch(get_host_info().HTTPS_REMOTE_ORIGIN+"/common/blank.html", {mode: "no-cors"}));
}, `"require-corp" top-level: fetch() to response without CORP should fail`);
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,17 @@
<body>
<script src="script-factory.js"></script>
<script>
const query = new URLSearchParams(window.location.search);
const id = query.get("id");
const variant = query.get("variant");
const parent = (variant === "subframe") ? "parent.parent" : "parent";
const blob = new Blob([createScript(window.origin, query.get("crossOrigin"), parent, id)], { type: "text/html" });
const blobURL = URL.createObjectURL(blob);
if (variant === "subframe") {
const frame = document.createElement("iframe");
frame.src = blobURL;
document.body.append(frame);
} else {
window.location = blobURL;
}
</script>

View file

@ -0,0 +1,2 @@
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-Policy: cross-origin

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1 @@
nothing with cross-origin CORP

View file

@ -0,0 +1 @@
Cross-Origin-Resource-Policy: cross-origin

View file

@ -0,0 +1 @@
nothing with same-origin CORP

View file

@ -0,0 +1 @@
Cross-Origin-Resource-Policy: same-origin

View file

@ -0,0 +1,23 @@
// This creates a serialized <script> element that is useful for blob/data/srcdoc-style tests.
function createScript(sameOrigin, crossOrigin, parent="parent", id="") {
return `<script>
const data = { id: "${id}",
origin: window.origin,
sameOriginNoCORPSuccess: false,
crossOriginNoCORPFailure: false };
function record(promise, token, expectation) {
return promise.then(() => data[token] = expectation, () => data[token] = !expectation);
}
const records = [
record(fetch("${crossOrigin}/common/blank.html", { mode: "no-cors" }), "crossOriginNoCORPFailure", false)
];
if ("${sameOrigin}" !== "null") {
records.push(record(fetch("${sameOrigin}/common/blank.html", { mode: "no-cors" }), "sameOriginNoCORPSuccess", true));
}
Promise.all(records).then(() => window.${parent}.postMessage(data, "*"));
<\/script>`;
}

View file

@ -0,0 +1,40 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<div id=log></div>
<script>
async_test(t => {
window.addEventListener("message", t.step_func_done(({ data }) => {
assert_equals(data.origin, "null");
assert_true(data.sameOriginWithoutCORP, "Request to same-origin resource without CORP did not fail");
assert_true(data.sameOriginWithSameOriginCORP, "Request to same-origin resource with same-origin CORP did not fail");
assert_true(data.sameOriginWithCrossOriginCORP, "Request to same-origin resource with cross-origin CORP did not succeed");
assert_true(data.crossOriginWithCrossOriginCORP, "Request to cross-origin resource with cross-origin CORP did not succeed");
}));
const origins = get_host_info();
const frame = document.createElement("iframe");
const nothingCrossOriginCORP = new URL("resources/nothing-cross-origin-corp.txt", window.location).pathname;
const nothingSameOriginCORP = new URL("resources/nothing-same-origin-corp.txt", window.location).pathname;
frame.sandbox = "allow-scripts";
frame.srcdoc = `<script>
const data = { sameOriginWithoutCORP: false,
sameOriginWithSameOriginCORP: false,
sameOriginWithCrossOriginCORP: false,
crossOriginWithCrossOriginCORP: false,
origin: self.origin };
function record(promise, token, expectation) {
return promise.then(() => data[token] = expectation, () => data[token] = !expectation);
}
Promise.all([
record(fetch("/common/blank.html", { mode: "no-cors" }), "sameOriginWithoutCORP", false),
record(fetch("${nothingSameOriginCORP}", { mode: "no-cors" }), "sameOriginWithSameOriginCORP", false),
record(fetch("${nothingCrossOriginCORP}", { mode: "no-cors" }), "sameOriginWithCrossOriginCORP", true),
record(fetch("${origins.HTTPS_NOTSAMESITE_ORIGIN}${nothingCrossOriginCORP}", { mode: "no-cors" }), "crossOriginWithCrossOriginCORP", true)
]).then(() => parent.postMessage(data, "*"));
<\/script>`;
document.body.append(frame);
}, "Cross-Origin-Embedder-Policy and sandbox");
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,21 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/script-factory.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<div id=log></div>
<script>
async_test(t => {
window.addEventListener("message", t.step_func_done(({ data }) => {
assert_equals(data.id, "");
assert_equals(data.origin, window.origin);
assert_true(data.sameOriginNoCORPSuccess, "Same-origin without CORP did not succeed");
assert_true(data.crossOriginNoCORPFailure, "Cross-origin without CORP did not fail");
}));
const frame = document.createElement("iframe");
t.add_cleanup(() => frame.remove());
frame.srcdoc = createScript(window.origin, get_host_info().HTTPS_NOTSAMESITE_ORIGIN);
document.body.append(frame);
}, "Cross-Origin-Embedder-Policy and srcdoc");
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,11 @@
This directory as well as `../cross-origin-embedder-policy/` contains tests for `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy`. Some light background reading:
* [COOP and COEP explained](https://docs.google.com/document/d/1zDlfvfTJ_9e8Jdc8ehuV4zMEu9ySMCiTGMS9y0GU92k/edit)
* [COOP processing model](https://gist.github.com/annevk/6f2dd8c79c77123f39797f6bdac43f3e) (also defines interaction with COEP)
* [COEP processing model](https://mikewest.github.io/corpp/)
* [Open COOP issues](https://github.com/whatwg/html/labels/topic%3A%20cross-origin-opener-policy)
* [Open COEP issues](https://github.com/whatwg/html/labels/topic%3A%20cross-origin-embedder-policy)
Notes:
* Top-level navigation to a `data:` URL does not work in Chrome and Firefox and is therefore not tested. (This should probably be standardized.)

View file

@ -0,0 +1,62 @@
<!doctype html>
<title>Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy: a navigating popup</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/common.js"></script>
<script>
[
{
"title": "coop/coep",
"coop": "same-origin",
"coep": "require-corp",
"opener": true
},
{
"title": "no coop/coep",
"coop": "",
"coep": "require-corp",
"opener": false
},
{
"title": "coop/no coep",
"coop": "same-origin",
"coep": "",
"opener": false
},
{
"title": "no coop/no coep",
"coop": "",
"coep": "",
"opener": false
},
{
"title": "coop unsafe-inherit/coep",
"coop": "unsafe-inherit",
"coep": "require-corp",
"opener": true
},
{
"title": "coop unsafe-inherit/no coep",
"coop": "unsafe-inherit",
"coep": "",
"opener": false
}
].forEach(variant => {
["same-origin", "same-site"].forEach(site => {
const title = `Popup navigating to ${site} with ${variant.title}`;
const channel = title.replace(/ /g,"-");
const navigateHost = site === "same-origin" ? SAME_ORIGIN : SAME_SITE;
const navigateURL = `${navigateHost.origin}/html/cross-origin-opener-policy/resources/coop-coep.py?coop=${variant.coop}&coep=${variant.coep}&channel=${channel}`;
const opener = site === "same-origin" ? variant.opener : false;
async_test(t => {
// For each test we open a COOP: same-origin/COEP: require-corp document in a popup and then
// navigate that to either a same-origin or same-site document whose COOP and COEP are set as
// per the top-most array. We then verify that this document has the correct opener for its
// specific setup.
url_test(t, `${SAME_ORIGIN.origin}/html/cross-origin-opener-policy/resources/coop-coep.py?coop=same-origin&coep=require-corp&navigate=${encodeURIComponent(navigateURL)}`, channel, opener);
}, title);
});
});
</script>

View file

@ -0,0 +1,2 @@
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,67 @@
<!doctype html>
<title>Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy: redirects</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/common.js"></script>
<script>
const coopCOEPPath = new URL("resources/coop-coep.py", window.location).pathname;
[
{
"title": "coop/coep to coop/coep",
"redirectCOOP": "same-origin",
"redirectCOEP": "require-corp",
"coop": "same-origin",
"coep": "require-corp",
"opener": true
},
{
"title": "coop/coep to no coop/coep",
"redirectCOOP": "same-origin",
"redirectCOEP": "require-corp",
"coop": "",
"coep": "require-corp",
"opener": false
},
{
"title": "no coop/no coep to coop/coep",
"redirectCOOP": "",
"redirectCOEP": "",
"coop": "same-origin",
"coep": "require-corp",
"opener": false
},
{
"title": "coop/no coep to coop/coep",
"redirectCOOP": "same-origin",
"redirectCOEP": "",
"coop": "same-origin",
"coep": "require-corp",
"opener": false
},
{
"title": "coop unsafe-inherit/coep to coop/coep",
"redirectCOOP": "unsafe-inherit",
"redirectCOEP": "require-corp",
"coop": "same-origin",
"coep": "require-corp",
"opener": true
},
{
"title": "coop unsafe-inherit/coep to coop unsafe-inherit/coep",
"redirectCOOP": "unsafe-inherit",
"redirectCOEP": "require-corp",
"coop": "unsafe-inherit",
"coep": "require-corp",
"opener": true
}
].forEach(variant => {
const title = `Redirect from ${variant.title}`;
async_test(t => {
const channel = title.replace(/ /g,"-");
const redirectLocation = `${SAME_ORIGIN.origin}${coopCOEPPath}?coop=${variant.coop}&coep=${variant.coep}&channel=${channel}`;
url_test(t, `${SAME_ORIGIN.origin}${coopCOEPPath}?coop=${variant.redirectCOOP}&coep=${variant.redirectCOEP}&redirect=${encodeURIComponent(redirectLocation)}`, channel, variant.opener);
}, title);
});
</script>

View file

@ -0,0 +1,2 @@
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,43 @@
<!doctype html>
<title>Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/common.js"></script>
<script>
[
{
"title": "popup with coop/coep",
"coop": "same-origin",
"coep": "require-corp",
"opener": true
},
{
"title": "popup with coop unsafe-inherit/coep",
"coop": "unsafe-inherit",
"coep": "require-corp",
"opener": true
},
{
"title": "popup with coop unsafe-inherit without coep",
"coop": "unsafe-inherit",
"coep": "",
"opener": false
},
{
"title": "popup without coep",
"coop": "same-origin",
"coep": "",
"opener": false
}
].forEach(variant => {
async_test(t => {
coop_coep_test(t, SAME_ORIGIN, variant.coop, variant.coep, variant.title.replace(/ /g,"-"), variant.opener);
}, `Same-origin ${variant.title}`);
// This seems useful to test, CROSS_SITE is probably too redundant though.
async_test(t => {
coop_coep_test(t, SAME_SITE, variant.coop, variant.coep, `same-site-${variant.title.replace(/ /g,"-")}`, false);
}, `Same-site ${variant.title}`);
});
</script>

View file

@ -0,0 +1,2 @@
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>Cross-Origin-Opener-Policy: a navigated popup</title>
<!-- In particular this is different from coep-navigate-popup.https.html as this document initiates
the navigation (and uses unsafe-allow-outgoing and no COEP as without that it cannot be
observed). COOP should work identically, but implementations might have used the wrong
authority. -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
<script>
async_test(t => {
const noCOOP = "/common/blank.html";
const popupName = token();
const popup = window.open(noCOOP, popupName);
t.add_cleanup(() => popup.close());
popup.onload = t.step_func(() => {
assert_equals(popup.name, popupName);
assert_equals(new URL(popup.document.URL).pathname, noCOOP);
const channel = new BroadcastChannel(token());
channel.onmessage = t.step_func_done(event => {
const payload = event.data;
assert_equals(payload.name, "");
assert_false(payload.opener);
});
const coop = `resources/coop-coep.py?coop=same-origin&coep=&channel=${channel.name}`;
popup.location = coop;
});
}, "Open a popup to a document without COOP, then navigate it to a document with");
</script>

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>Sandboxed Cross-Origin-Opener-Policy popup should result in a network error</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
<div id=log>
<script>
async_test(t => {
const frame = document.createElement("iframe");
const channel = new BroadcastChannel(token());
channel.onmessage = t.unreached_func("A COOP popup was created from a sandboxed frame");
t.add_cleanup(() => frame.remove());
frame.sandbox = "allow-popups allow-scripts allow-same-origin";
frame.srcdoc = `<script>
const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&channel=${channel.name}");
<\/script>`;
document.body.append(frame);
t.step_timeout(() => {
t.done()
}, 500);
});
</script>

View file

@ -0,0 +1,18 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin-Opener-Policy requires secure contexts</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
async_test(t => {
const popup = window.open("/common/blank.html");
assert_equals(window, popup.opener);
t.step_timeout(() => {
assert_false(popup.closed);
assert_equals(popup.location.pathname, "/common/blank.html");
popup.close();
t.done();
}, 500);
}, "Cross-Origin-Opener-Policy only works over secure contexts");
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Opener-Policy: same-origin

View file

@ -3,8 +3,7 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="common.sub.js"></script>
<script src="resources/common.js"></script>
<div id=log></div>
<script>
@ -33,6 +32,6 @@ let tests = [
[CROSS_ORIGIN, "same-origin unsafe-allow-outgoing", false],
];
run_coop_tests("null", tests);
run_coop_tests("none", tests);
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<title>Cross-Origin-Opener-Policy: about:blank</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
async_test(t => {
const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&navigate=about:blank");
assert_equals(window, popup.opener);
t.step_timeout(() => {
assert_equals(popup.location.href, "about:blank");
popup.close();
t.done();
}, 500);
}, "Navigating a popup to about:blank");
</script>

View file

@ -3,8 +3,7 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="common.sub.js"></script>
<script src="resources/common.js"></script>
<div id=log></div>
<script>

View file

@ -0,0 +1 @@
Cross-Origin-Opener-Policy: same-origin unsafe-allow-outgoing

View file

@ -3,8 +3,7 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="common.sub.js"></script>
<script src="resources/common.js"></script>
<div id=log></div>
<script>

View file

@ -0,0 +1 @@
Cross-Origin-Opener-Policy: same-origin

View file

@ -3,8 +3,7 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="common.sub.js"></script>
<script src="resources/common.js"></script>
<div id=log></div>
<script>

View file

@ -3,8 +3,7 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="common.sub.js"></script>
<script src="resources/common.js"></script>
<div id=log></div>
<script>

View file

@ -0,0 +1,36 @@
const SAME_ORIGIN = {origin: get_host_info().HTTPS_ORIGIN, name: "SAME_ORIGIN"};
const SAME_SITE = {origin: get_host_info().HTTPS_REMOTE_ORIGIN, name: "SAME_SITE"};
const CROSS_ORIGIN = {origin: get_host_info().HTTPS_NOTSAMESITE_ORIGIN, name: "CROSS_ORIGIN"}
function url_test(t, url, channelName, hasOpener) {
const bc = new BroadcastChannel(channelName);
bc.onmessage = t.step_func_done(event => {
const payload = event.data;
assert_equals(payload.name, hasOpener ? channelName : "");
assert_equals(payload.opener, hasOpener);
});
const w = window.open(url, channelName);
// w will be closed by its postback iframe. When out of process,
// window.close() does not work.
t.add_cleanup(() => w.close());
}
function coop_coep_test(t, host, coop, coep, channelName, hasOpener) {
url_test(t, `${host.origin}/html/cross-origin-opener-policy/resources/coop-coep.py?coop=${encodeURIComponent(coop)}&coep=${coep}&channel=${channelName}`, channelName, hasOpener);
}
function coop_test(t, host, coop, channelName, hasOpener) {
coop_coep_test(t, host, coop, "", channelName, hasOpener);
}
function run_coop_tests(documentCOOPValueTitle, testArray) {
for (const test of tests) {
async_test(t => {
coop_test(t, test[0], test[1],
`${mainTest}_to_${test[0].name}_${test[1].replace(/ /g,"-")}`,
test[2]);
}, `${documentCOOPValueTitle} document opening popup to ${test[0].origin} with COOP: "${test[1]}"`);
}
}

View file

@ -0,0 +1,35 @@
def main(request, response):
coop = request.GET.first("coop")
coep = request.GET.first("coep")
redirect = request.GET.first("redirect", None)
if coop != "":
response.headers.set("Cross-Origin-Opener-Policy", coop)
if coep != "":
response.headers.set("Cross-Origin-Embedder-Policy", coep)
if redirect != None:
response.status = 302
response.headers.set("Location", redirect)
return
# This uses an <iframe> as BroadcastChannel is same-origin bound.
response.content = """
<!doctype html>
<meta charset=utf-8>
<script src="/common/get-host-info.sub.js"></script>
<iframe></iframe>
<script>
const navigate = new URL(location).searchParams.get("navigate");
if (navigate !== null) {
self.location = navigate;
} else {
const iframe = document.querySelector("iframe");
iframe.onload = () => {
const payload = { name: self.name, opener: !!self.opener };
iframe.contentWindow.postMessage(payload, "*");
};
const channelName = new URL(location).searchParams.get("channel");
iframe.src = `${get_host_info().HTTPS_ORIGIN}/html/cross-origin-opener-policy/resources/postback.html?channel=${channelName}`;
}
</script>
"""

View file

@ -0,0 +1,10 @@
<!doctype html>
<meta charset=utf-8>
<script>
const channelName = new URL(location).searchParams.get("channel");
const bc = new BroadcastChannel(channelName);
window.addEventListener("message", event => {
bc.postMessage(event.data);
window.parent.close();
});
</script>

View file

@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

View file

@ -1,28 +0,0 @@
const SAME_ORIGIN = {origin: get_host_info().HTTP_ORIGIN, name: "SAME_ORIGIN"};
const SAME_SITE = {origin: get_host_info().HTTP_REMOTE_ORIGIN, name: "SAME_SITE"};
const CROSS_ORIGIN = {origin: get_host_info().HTTP_NOTSAMESITE_ORIGIN, name: "CROSS_ORIGIN"}
function coop_test(t, host, coop, channelName, hasOpener) {
let bc = new BroadcastChannel(channelName);
bc.onmessage = t.step_func_done((event) => {
let payload = event.data;
assert_equals(payload.name, hasOpener ? channelName : "");
assert_equals(payload.opener, hasOpener);
});
let w = window.open(`${host.origin}/html/cross-origin-opener/resources/coop_window.py?path=window.sub.html&coop=${escape(coop)}&channel=${channelName}`, channelName);
// w will be closed by its postback iframe. When out of process,
// window.close() does not work.
t.add_cleanup(() => w.close());
}
function run_coop_tests(mainTest, testArray) {
for (let test of tests) {
async_test(t => {
coop_test(t, test[0], test[1],
`${mainTest}_to_${test[0].name}_${test[1].replace(/ /g,"-")}`,
test[2]);
}, `${mainTest} document opening popup to ${test[0].origin} with COOP: "${test[1]}"`);
}
}

View file

@ -1,10 +0,0 @@
import urllib
import os.path
def main(request, response):
coop = request.GET.first('coop')
if coop:
response.headers.set('Cross-Origin-Opener-Policy', urllib.unquote(coop))
path = os.path.join(os.path.dirname(__file__), request.GET.first('path'))
response.content = open(path, mode='rb').read()

View file

@ -1,13 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<script>
let channelName = new URL(location).searchParams.get("channel");
let bc = new BroadcastChannel(channelName);
window.addEventListener("message", (event) => {
bc.postMessage(event.data);
window.parent.close();
}, false);
</script>

View file

@ -1,18 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<script src="/common/get-host-info.sub.js"></script>
<script type="text/javascript">
window.addEventListener('load', function() {
let iframe = document.createElement("iframe");
iframe.onload = () => {
let payload = { name: self.name, opener: !!self.opener };
iframe.contentWindow.postMessage(payload, "*");
};
let channelName = new URL(location).searchParams.get("channel");
iframe.src = `${get_host_info().HTTP_ORIGIN}/html/cross-origin-opener/resources/postback.sub.html?channel=${channelName}`;
document.body.appendChild(iframe);
});
</script>

View file

@ -1 +0,0 @@
Cross-Origin-Opener-Policy: same-site

View file

@ -1,219 +0,0 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin header and nested navigable resource without such header</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
t.step_timeout(() => {
// Make sure the iframe didn't load.
assert_equals(frame.contentDocument, null);
t.done();
}, 500);
frame.src = "/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with anonymous policy: navigating a frame to a null policy should fail.");
async_test(t => {
const frame = document.createElement("iframe");
const CHANNEL_NAME = "frame-anon-to-blank";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func((event) => {
assert_not_equals(frame.contentDocument, null);
let payload = event.data;
assert_equals(payload, "loaded");
t.step_timeout(() => {
assert_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 1500);
});
frame.src = `resources/navigate_anonymous.sub.html?channelName=${CHANNEL_NAME}&to=/common/blank.html`;
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with anonymous policy: navigating a frame from an anonymous policy to a null policy should fail.");
async_test(t => {
const frame = document.createElement("iframe");
const CHANNEL_NAME = "frame-usecredentials-to-blank";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func((event) => {
assert_not_equals(frame.contentDocument, null);
let payload = event.data;
assert_equals(payload, "loaded");
t.step_timeout(() => {
assert_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 1500);
});
frame.src = `resources/navigate_usecredentials.sub.html?channelName=${CHANNEL_NAME}&to=/common/blank.html`;
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with anonymous policy: navigating a frame from a use-credentials policy to a null policy should fail.");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "anon-null-window-noopener";
let bc = new BroadcastChannel(CHANNEL_NAME);
let finished = false;
bc.onmessage = t.step_func((event) => {
let payload = event.data;
assert_equals(payload, "loaded");
pageLoaded = true;
});
const SECOND_CHANNEL = "anon-null-window-noopener-second";
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func_done((event) => {
let payload = event.data;
assert_equals(payload, "loaded");
assert_equals(pageLoaded, true, "Opening a null window (noopener) from anon window should work");
});
let win = window.open(`resources/navigate_null.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
}, "Top-level with anonymous policy: creating a noopener popup with null policy should work.");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "anon-null-window";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func_done((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
let win = window.open(`resources/navigate_null.sub.html?channelName=${CHANNEL_NAME}&to=/common/blank.html`, "_blank");
t.add_cleanup(() => win.close());
t.step_timeout(() => {
assert_equals(pageLoaded, false, "Opening a null window from anon window should fail");
t.done();
}, 500);
}, "Top-level with anonymous policy: creating a popup with null policy should fail.");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "anon-null-top-navigation";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const SECOND_CHANNEL = "anon-null-top-navigation-final";
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func_done((event) => {
let payload = event.data;
assert_equals(payload, "loaded");
assert_equals(pageLoaded, true, "Opening a null window (noopener) from anon window should work");
});
let win = window.open(`resources/navigate_anonymous.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
}, "Top-level noopener with anonymous policy: navigating to a different policy should work");
promise_test(t => {
let host_info = get_host_info();
return fetch(host_info.HTTP_REMOTE_ORIGIN+"/html/cross-origin/resources/nothing.txt",
{"mode": "no-cors", "method": "GET", "headers":{}}).then(r => {
assert_equals(r.type, "cors", "type should have been changed to cors");
});
}, "Fetch policy: anonymous policy no-cors fetches should be changed to cors");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "anon-null-window";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func_done((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const SECOND_CHANNEL = "anon-null-window-second";
let navigated = false;
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func((event) => {
navigated = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
let win = window.open(`resources/navigate_anonymous.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank");
t.add_cleanup(() => win.close());
t.step_timeout(() => {
assert_equals(pageLoaded, true, "Opening the popup window from anon window should work");
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
t.done();
}, 500);
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail.");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "anon-null-window";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func_done((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const SECOND_CHANNEL = "anon-null-window-second";
let navigated = false;
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func((event) => {
navigated = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
let win = window.open(`resources/navigate_anonymous.sub.html?clearOpener=true&channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank");
t.add_cleanup(() => win.close());
t.step_timeout(() => {
assert_equals(pageLoaded, true, "Opening the popup window from anon window should work");
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
t.done();
}, 500);
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail. (even when we clear the opener)");
async_test(t => {
let popupLoaded = false;
const CHANNEL_NAME = "anon-null-window-no-opener";
let bc = new BroadcastChannel(CHANNEL_NAME);
bc.onmessage = t.step_func_done((event) => {
let payload = event.data;
if (payload == "loaded") {
t.step_timeout(() => {
assert_equals(popupLoaded, true, "Opening the popup window (noopener) from anon window should work");
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
t.done();
}, 500);
} else if (payload == "popup-loaded") {
popupLoaded = true;
} else {
assert_unreached(`unexpected payload ${payload}`);
}
});
const SECOND_CHANNEL = "anon-null-window-second-popup";
let navigated = false;
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func((event) => {
navigated = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
let win = window.open(`resources/popup_and_close.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail. (even opener window is closed)");
</script>

View file

@ -1,103 +0,0 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin header and nested navigable resource without such header</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
frame.onload = t.step_func_done(() => {
assert_not_equals(frame.contentDocument, null, "The frame should actually load");
});
frame.src = "/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with null policy: navigating a frame to a null policy should work.");
async_test(t => {
const frame = document.createElement("iframe");
let firstNavOk = false;
frame.onload = t.step_func(() => {
assert_not_equals(frame.contentDocument, null);
firstNavOk = true;
});
t.step_timeout(() => {
assert_equals(firstNavOk, true, "The initial load should work");
assert_not_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 500);
frame.src = "resources/navigate_anonymous.sub.html?to=/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with null policy: parent policy should apply to frame navigation from use-credentials policy to a null. Should succeed.");
async_test(t => {
const frame = document.createElement("iframe");
let firstNavOk = false;
frame.onload = t.step_func(() => {
assert_not_equals(frame.contentDocument, null);
firstNavOk = true;
});
t.step_timeout(() => {
assert_equals(firstNavOk, true, "The initial load should work");
assert_not_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 500);
frame.src = "resources/navigate_anonymous.sub.html?to=/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with null policy: parent policy should apply to frame navigation from anonymous policy to a null. Should succeed.");
async_test(t => {
let w = window.open(`resources/navigate_null.sub.html?to=navigate_anonymous.sub.html`, "window_name");
t.add_cleanup(() => w.close());
t.step_timeout(() => {
w.history.back();
t.step_timeout(() => {
assert_not_equals(w.document, null);
t.done();
}, 500);
}, 500);
}, "Top-level with null policy: navigating a frame back from a blocked page should work.");
async_test(t => {
let pageLoaded = false;
const CHANNEL_NAME = "usecredentials-null-top-navigation";
let bc = new BroadcastChannel(CHANNEL_NAME);
let finished = false;
bc.onmessage = t.step_func((event) => {
pageLoaded = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
const SECOND_CHANNEL = "usecredentials-null-top-navigation-final";
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
bc2.onmessage = t.step_func((event) => {
finished = true;
let payload = event.data;
assert_equals(payload, "loaded");
});
let win = window.open(`resources/navigate_usecredentials.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
t.step_timeout(() => {
assert_equals(pageLoaded, true, "Opening a null window (noopener) from usecredentials window should work");
assert_equals(finished, true, "Navigating a top level window out of an usecredentials policy should work");
t.done();
}, 500);
}, "Top-level noopener popup with use-credentials policy: navigating to a different (null) policy should work");
promise_test(t => {
let host_info = get_host_info();
return fetch(host_info.HTTP_REMOTE_ORIGIN+"/html/cross-origin/resources/nothing.txt",
{"mode": "no-cors", "method": "GET", "headers":{}}).then(r => {
assert_equals(r.type, "opaque", "type should be opaque for cross origin fetch");
});
}, "Fetch policy: null policy should not affect the no-cors mode");
</script>

View file

@ -1 +0,0 @@
Cross-Origin: unknown-should-be-parsed-as-null

View file

@ -1,18 +0,0 @@
<!doctype html>
<script>
let current = new URL(window.location.href);
let navigateTo = current.searchParams.get("to");
let channelName = current.searchParams.get("channelName");
current.search = "";
if (navigateTo) {
let next = new URL(navigateTo, current);
setTimeout(() => {
window.location = next.href;
}, 50);
}
if (channelName) {
let bc = new BroadcastChannel(channelName);
bc.postMessage("loaded");
}
</script>

View file

@ -1 +0,0 @@
Access-Control-Allow-Origin: *

View file

@ -1,18 +0,0 @@
<!doctype html>
<script>
let current = new URL(window.location.href);
let navigateTo = current.searchParams.get("to");
let channelName = current.searchParams.get("channelName");
let secondChannel = current.searchParams.get("secondChannel");
if (channelName) {
let bc = new BroadcastChannel(channelName);
bc.postMessage("popup-loaded");
}
let win = window.open(`navigate_anonymous.sub.html?channelName=${channelName}&to=navigate_null.sub.html?channelName=${secondChannel}`, "_blank");
setTimeout(() => {
window.close();
}, 10);
</script>

View file

@ -1,54 +0,0 @@
<!doctype html>
<meta name="timeout" content="long">
<title>Cross-Origin header and nested navigable resource without such header</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
async_test(t => {
const frame = document.createElement("iframe");
t.step_timeout(() => {
// Make sure the iframe didn't load.
assert_equals(frame.contentDocument, null);
t.done();
}, 500);
frame.src = "/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with use-credentials policy: navigating a frame to a null policy should fail.");
async_test(t => {
const frame = document.createElement("iframe");
let firstNavOk = false;
frame.onload = t.step_func(() => {
assert_not_equals(frame.contentDocument, null);
firstNavOk = true;
});
t.step_timeout(() => {
assert_equals(firstNavOk, true, "The initial load should work");
assert_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 500);
frame.src = "resources/navigate_usecredentials.sub.html?to=/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with use-credentials policy: navigating a frame from a use-credentials policy to a null policy should fail");
async_test(t => {
const frame = document.createElement("iframe");
let firstNavOk = false;
frame.onload = t.step_func(() => {
assert_not_equals(frame.contentDocument, null);
firstNavOk = true;
});
t.step_timeout(() => {
assert_equals(firstNavOk, true, "The initial load should work");
assert_equals(frame.contentDocument, null, "Navigation to null policy should fail");
t.done();
}, 500);
frame.src = "resources/navigate_anonymous.sub.html?to=/common/blank.html";
document.body.append(frame);
assert_equals(frame.contentDocument.body.localName, "body");
}, "Top-level with use-credentials policy: navigating a frame from an anonymous policy to a null policy should fail.");
</script>

View file

@ -1 +0,0 @@
Cross-Origin: use-credentials

View file

@ -223,6 +223,7 @@ idl_test(
HTMLFrameElement: ['document.createElement("frame")'],
HTMLDirectoryElement: ['document.createElement("dir")'],
HTMLFontElement: ['document.createElement("font")'],
DOMStringList: ['location.ancestorOrigins'],
});
idlArray.prevent_multiple_testing('HTMLElement');
await waitForLoad;

View file

@ -1,32 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>DOMStringList IDL tests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<h1>DOMStringList IDL tests</h1>
<div id=log></div>
<script>
"use strict";
async_test(function(t) {
var request = new XMLHttpRequest();
request.open("GET", "/interfaces/html.idl");
request.send();
request.onload = t.step_func(function() {
var idlArray = new IdlArray();
var idls = request.responseText;
idlArray.add_idls(idls, { only: ["DOMStringList"] });
idlArray.add_objects({
DOMStringList: ['location.ancestorOrigins'],
});
idlArray.test();
t.done();
});
});
</script>

View file

@ -1,24 +0,0 @@
"use strict";
importScripts("/resources/testharness.js");
importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js");
async_test(function(t) {
var request = new XMLHttpRequest();
request.open("GET", "/interfaces/html.idl");
request.send();
request.onload = t.step_func(function() {
var idlArray = new IdlArray();
var idls = request.responseText;
idlArray.add_idls(idls, { only: ["DOMStringList"] });
idlArray.add_objects({
DOMStringList: [],
});
idlArray.test();
t.done();
});
});
done();

View file

@ -0,0 +1,74 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: tabIndex getter return value</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<input>
<input type="hidden">
<button>button</button>
<button disabled>button</button>
<button hidden>button</button>
<a>a</a>
<a href="#">a</a>
<svg><a>svg a</a></svg>
<svg><a>svg a</a></svg>
<link id="nohref">
<textarea></textarea>
<select><optgroup><option>option</option></optgroup></select>
<select multiple></select>
<iframe width="10" height="10"></iframe>
<embed width="10" height="10"></embed>
<object width="10" height="10"></object>
<span></span>
<div></div>
<details><summary>summary</summary><summary id="secondsummary">second summary</summary>details</details>
<div id="hostDelegatesFocus"></div>
<div id="hostNonDelegatesFocus"></div>
<script>
document.getElementById("hostDelegatesFocus").attachShadow({ mode: "open", delegatesFocus: true });
document.getElementById("hostNonDelegatesFocus").attachShadow({ mode: "open", delegatesFocus: false });
const defaultList = [
["input", 0],
["input[type='hidden']", 0],
["button", 0],
["button[disabled]", 0],
["button[hidden]", 0],
["a", 0],
["a[href]", 0],
["svg a", 0],
["textarea", 0],
["select", 0],
["select[multiple]", 0],
["option", -1],
["optgroup", -1],
["iframe", 0],
["embed", -1],
["object", 0],
["span", -1],
["div", -1],
["link#nohref", -1],
["link[href]", -1],
["details", -1],
["summary", 0],
["summary#secondsummary", -1],
["#hostDelegatesFocus", -1],
["#hostNonDelegatesFocus", -1],
];
const tabIndexValue = [-1, 0, 1];
for (const entry of defaultList) {
const element = document.querySelector(entry[0]);
test(() => {
assert_equals(element.tabIndex, entry[1]);
}, entry[0] + ".tabIndex should return " + entry[1] + " by default");
for (const setValue of tabIndexValue ) {
test(() => {
element.setAttribute("tabindex", setValue);
assert_equals(element.tabIndex, setValue);
}, entry[0] + ".tabIndex should return " + setValue + " when set to " + setValue);
}
}
</script>
</body>

View file

@ -0,0 +1,29 @@
<!doctype html>
<title>Select block size when line-height is specified</title>
<!--
FIXME: This is just a copy of select-1-block-size-001.html, but if I move the
<link rel="match"> in this file to select-1-block-size-001-ref.html (which is
the "right" way to do this), fuzzy annotations do not work.
-->
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571764">
<link rel="match" href="select-1-block-size-001-ref-2.html">
<style>
select {
-webkit-appearance: none;
appearance: none;
background: black;
color: black;
line-height: 100px;
width: 100px;
border: 0;
border-radius: 0;
padding: 0;
}
</style>
<select></select>
<select><option>A</option></select>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571764">
<style>
div {
-webkit-appearance: none;
appearance: none;
background: black;
color: black;
line-height: 100px;
width: 100px;
border: 0;
padding: 0;
display: inline-block;
}
</style>
<div>A</div>
<div>A</div>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571764">
<style>
button {
-webkit-appearance: none;
appearance: none;
background: black;
color: black;
line-height: 100px;
width: 100px;
border: 0;
border-radius: 0;
padding: 0;
}
</style>
<button>A</button>
<button>A</button>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>Select block size when line-height is specified</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571764">
<link rel="match" href="select-1-block-size-001-ref.html">
<style>
select {
-webkit-appearance: none;
appearance: none;
background: black;
color: black;
line-height: 100px;
width: 100px;
border: 0;
border-radius: 0;
padding: 0;
}
</style>
<select></select>
<select><option>A</option></select>

View file

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>idlharness test</title>
<link rel="author" title="Kensaku Komatsu" href="mailto:kensaku.komatsu@gmail.com" />
<link rel="help" href="http://www.w3.org/TR/animation-timing/#definitions"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<h1>idlharness test</h1>
<p>This test validates the WebIDL included in the Timing control for script-based animations specification.</p>
<pre id='untested_idl' style='display:none'>
[Global=Window, Exposed=Window]
interface Window {
};
</pre>
<pre id='idl'>
partial interface Window {
long requestAnimationFrame(FrameRequestCallback callback);
void cancelAnimationFrame(long handle);
};
callback FrameRequestCallback = void (DOMHighResTimeStamp time);
</pre>
<script>
(function() {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.add_objects({Window: ["window"]});
idl_array.test();
})();
</script>
<div id="log"></div>
</body>
</html>