Bug 1601594 - P2 - Changes on window-domain-success.https; r=annevk

This test was used to verify that postMessaging to a same-origin-domain (but
not same-origin) iframe allows them to see each others' modification.

However, we now only allow same-origin to postMessage SharedArrayBuffer. And,
that means same-origin-domain are not allowed to do that. Therefore, this test
is rewrited to verify that postMessage SharedArrayBuffer from a
same-origin-domain iframe would result the receiver (parent) to get a message
error event.

Github issue: https://github.com/whatwg/html/pull/4734

Differential Revision: https://phabricator.services.mozilla.com/D70348
This commit is contained in:
Tom Tung 2020-05-18 09:41:31 +00:00
Родитель ed2823830e
Коммит 9eebac82a6
6 изменённых файлов: 33 добавлений и 37 удалений

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that postMessage a SharedArrayBuffer to the parent and also sets document.domain</title>
<script>
"use strict";
document.domain = "{{host}}";
parent.postMessage(new SharedArrayBuffer(10), "*");
</script>

Просмотреть файл

@ -1,11 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>A test page that messes with a given SharedArrayBuffer and also sets document.domain</title>
<script src="test-incrementer.js"></script>
<script>
"use strict";
document.domain = "{{host}}";
setupDestinationIncrementer(self, parent, "*");
</script>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Structured cloning of SharedArrayBuffers into same-origin-domain windows</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#structuredserialize">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
"use strict";
document.domain = "{{host}}";
async_test(t => {
const iframe = document.createElement("iframe");
t.add_cleanup(() => iframe.remove());
iframe.src = "//{{domains[www1]}}:{{location[port]}}/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/iframe-domain-failure.sub.html";
window.onmessage = t.unreached_func("Got a message event, expected a messageerror event");
window.onmessageerror = t.step_func_done();
document.body.append(iframe);
}, "SharedArrayBuffer and a same-origin-domain (but not same-origin) iframe");
</script>

Просмотреть файл

@ -1,26 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Structured cloning of SharedArrayBuffers into same-origin-domain windows</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#structuredserialize">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-incrementer.js"></script>
<div id="log"></div>
<script>
"use strict";
document.domain = "{{host}}";
promise_test(t => {
return new Promise(resolve => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
});
iframe.src = "//{{domains[www1]}}:{{location[port]}}/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/incrementer-iframe-domain.sub.html";
document.body.appendChild(iframe);
});
}, "postMessaging to a same-origin-domain (but not same-origin) iframe allows them to see each others' modifications");
</script>