blob: 63902c302b7ce6cb5a3f0fb126be2a56a830f42b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
</head>
<body>
<script>
const host = get_host_info();
const remoteBaseURL = host.HTTP_REMOTE_ORIGIN + window.location.pathname.replace(/\/[^\/]*$/, '/') ;
const localBaseURL = host.HTTP_ORIGIN + window.location.pathname.replace(/\/[^\/]*$/, '/') ;
function with_iframe(url) {
return new Promise(function(resolve) {
var frame = document.createElement('iframe');
frame.src = url;
frame.onload = function() { resolve(frame); };
document.body.appendChild(frame);
});
}
promise_test(async() => {
const url = remoteBaseURL + "resources/iframe.py?corp=same-origin";
await new Promise((resolve, reject) => {
return fetch(url, { mode: "no-cors" }).then(reject, resolve);
});
const iframe = await with_iframe(url);
return new Promise((resolve, reject) => {
window.addEventListener("message", (event) => {
if (event.data !== "pong") {
reject(event.data);
return;
}
resolve();
}, false);
iframe.contentWindow.postMessage("ping", "*");
}).finally(() => {
iframe.remove();
});
}, "Load an iframe that has Cross-Origin-Resource-Policy header");
</script>
</body>
</html>
|