| 1 |
<!-- |
| 2 |
Any copyright is dedicated to the Public Domain. |
| 3 |
http://creativecommons.org/publicdomain/zero/1.0/ |
| 4 |
--> |
| 5 |
<html> |
| 6 |
<head> |
| 7 |
<meta charset="utf-8" /> |
| 8 |
<meta name="timeout" content="long" /> |
| 9 |
<iframe |
| 10 |
id="read-frame-window" |
| 11 |
src="https://{{hosts[alt][www1]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify.https.html" |
| 12 |
></iframe> |
| 13 |
<iframe |
| 14 |
id="read-frame-worker" |
| 15 |
src="https://{{hosts[alt][www1]}}:{{ports[https][0]}}/_mozilla/dom/quota/support/test-read-and-notify-worker.https.html" |
| 16 |
></iframe> |
| 17 |
<script src="/resources/testharness.js"></script> |
| 18 |
<script src="/resources/testharnessreport.js"></script> |
| 19 |
<script> |
| 20 |
const params = new URL(window.location.href).searchParams; |
| 21 |
const id = params.get("id"); |
| 22 |
|
| 23 |
async_test(t => { |
| 24 |
let testId; |
| 25 |
let outcome; |
| 26 |
|
| 27 |
window.addEventListener( |
| 28 |
"message", |
| 29 |
t.step_func(e => { |
| 30 |
try { |
| 31 |
console.log("Read wrapper received " + JSON.stringify(e.data)); |
| 32 |
assert_true(!!e.data.message); |
| 33 |
if (e.data.message == "read loaded") { |
| 34 |
return; |
| 35 |
} |
| 36 |
if (!testId) { |
| 37 |
testId = e.data.message; |
| 38 |
assert_true(!!e.data.outcome); |
| 39 |
outcome = e.data.outcome; |
| 40 |
assert_true(!!e.data.expected); |
| 41 |
assert_true(!!e.data.frame); |
| 42 |
assert_true(!!e.data.type); |
| 43 |
const frameId = e.data.frame; |
| 44 |
|
| 45 |
// Send test data to window or worker iframe |
| 46 |
const readFrame = document.getElementById(frameId); |
| 47 |
readFrame.contentWindow.postMessage(e.data, "*"); |
| 48 |
} else { |
| 49 |
assert_equals(e.data.message, outcome); |
| 50 |
console.log("Read wrapper sends up " + JSON.stringify(e.data)); |
| 51 |
parent.opener.postMessage(e.data, document.referrer); |
| 52 |
t.done(); |
| 53 |
} |
| 54 |
} catch (err) { |
| 55 |
console.log("Error in read wrapper " + JSON.stringify(err)); |
| 56 |
parent.opener.postMessage(e.data, document.referrer); |
| 57 |
throw err; |
| 58 |
} |
| 59 |
}) |
| 60 |
); |
| 61 |
|
| 62 |
parent.opener.postMessage( |
| 63 |
{ id, message: "read loaded" }, |
| 64 |
document.referrer |
| 65 |
); |
| 66 |
}, "Read wrapper"); |
| 67 |
</script> |
| 68 |
</head> |
| 69 |
<body></body> |
| 70 |
</html> |