зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1649442 [wpt PR 24395] - [CSP] Add WPT tests for inheritance with window.open., a=testonly
Automatic update from web-platform-tests [CSP] Add WPT tests for inheritance with window.open. There are WPT tests about CSP inheritance when opening local-scheme. This is tested for iframe. Testing for iframes is good, testing for both iframes and opened window is better. Initially, I wanted to reproduce bug 1073126, but failed to do so. I still want to keep the tests. Bug: chromium:1073126 Change-Id: I4c363037d556bf93f37d43dd5b84a1da608d5e44 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274602 Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#785017} -- wpt-commits: 51f124152f8d1771382f4b2a8e4d386dd573755d wpt-pr: 24395
This commit is contained in:
Родитель
cef6e1029a
Коммит
e75698a477
|
@ -17,6 +17,16 @@
|
|||
}));
|
||||
}
|
||||
|
||||
function wait_for_error_from_window(opened_window, test) {
|
||||
window.addEventListener('message', test.step_func(e => {
|
||||
if (e.source != opened_window)
|
||||
return;
|
||||
assert_equals(e.data, "error");
|
||||
opened_window.close();
|
||||
test.done();
|
||||
}));
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
var i = document.createElement('iframe');
|
||||
document.body.appendChild(i);
|
||||
|
@ -28,6 +38,29 @@
|
|||
img.src = "{{location[server]}}/images/red-16x16.png";
|
||||
}, "<iframe>'s about:blank inherits policy.");
|
||||
|
||||
async_test(t => {
|
||||
var w = window.open("about:blank");
|
||||
|
||||
let then = t.step_func(() => {
|
||||
then = () => {};
|
||||
var img = w.document.createElement('img');
|
||||
img.onerror = t.step_func_done(_ => w.close());
|
||||
img.onload = t.unreached_func();
|
||||
w.document.body.appendChild(img);
|
||||
img.src = "{{location[server]}}/images/red-16x16.png";
|
||||
});
|
||||
|
||||
// There are now interoperable way to wait for the initial about:blank
|
||||
// document to load. Chrome loads it synchronously, hence we can't wait for
|
||||
// w.onload. On the other side Firefox loads the initial empty document
|
||||
// later and we can wait for the onload event.
|
||||
w.onload = then;
|
||||
setTimeout(then, 200);
|
||||
|
||||
// Navigations to about:blank happens synchronously. There is no need to
|
||||
// wait for the document to load.
|
||||
}, "window about:blank inherits policy.");
|
||||
|
||||
async_test(t => {
|
||||
var i = document.createElement('iframe');
|
||||
i.srcdoc = `
|
||||
|
@ -58,6 +91,19 @@
|
|||
document.body.appendChild(i);
|
||||
}, "<iframe src='blob:...'>'s inherits policy.");
|
||||
|
||||
async_test(t => {
|
||||
var b = new Blob(
|
||||
[`
|
||||
<img src='{{location[server]}}/images/red-16x16.png'
|
||||
onload='window.opener.postMessage("load", "*");'
|
||||
onerror='window.opener.postMessage("error", "*");'
|
||||
>
|
||||
`], {type:"text/html"});
|
||||
let url = URL.createObjectURL(b);
|
||||
var w = window.open(url);
|
||||
wait_for_error_from_window(w, t);
|
||||
}, "window url='blob:...' inherits policy.");
|
||||
|
||||
async_test(t => {
|
||||
var i = document.createElement('iframe');
|
||||
i.src = `data:text/html,<img src='{{location[server]}}/images/red-16x16.png'
|
||||
|
@ -70,6 +116,9 @@
|
|||
document.body.appendChild(i);
|
||||
}, "<iframe src='data:...'>'s inherits policy.");
|
||||
|
||||
// Opening a window toward a data-url isn't allowed anymore. Hence, it can't
|
||||
// be tested.
|
||||
|
||||
async_test(t => {
|
||||
var i = document.createElement('iframe');
|
||||
i.src = `javascript:"<img src='{{location[server]}}/images/red-16x16.png'
|
||||
|
@ -82,6 +131,16 @@
|
|||
document.body.appendChild(i);
|
||||
}, "<iframe src='javascript:...'>'s inherits policy (static <img> is blocked)");
|
||||
|
||||
async_test(t => {
|
||||
let url = `javascript:"<img src='{{location[server]}}/images/red-16x16.png'
|
||||
onload='window.opener.postMessage(\\"load\\", \\"*\\");'
|
||||
onerror='window.opener.postMessage(\\"error\\", \\"*\\");'
|
||||
>"`;
|
||||
|
||||
let w = window.open(url);
|
||||
wait_for_error_from_window(w, t);
|
||||
}, "window url='javascript:...'>'s inherits policy (static <img> is blocked)");
|
||||
|
||||
// Same as the previous javascript-URL test, but instead of loading the <img>
|
||||
// from the new document, this one is created from the initial empty document,
|
||||
// while evaluating the javascript-url.
|
||||
|
|
Загрузка…
Ссылка в новой задаче