summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html')
-rw-r--r--testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html b/testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
new file mode 100644
index 0000000000..61f54af359
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<script>
+ let cache = window;
+ // "foo" needs to be a var so it's a property on the global.
+ var foo = 'Reachable 1';
+ // "bar" needs to be a var so it's a property on the global.
+ var bar = { foo: 'Reachable 2' };
+ location.foo = 'Reachable 3';
+ document.foo = 'Reachable 4';
+ window.addEventListener('message', e => {
+ if (e.data.domain !== undefined) {
+ try {
+ document.domain = e.data.domain;
+ e.ports[0].postMessage('Done');
+ } catch(error) {
+ e.ports[0].postMessage(error.name);
+ }
+ } else if (e.data['poke-at-sibling'] !== undefined) {
+ try {
+ var sekrit = parent[e.data['poke-at-sibling']].document.body.querySelector('#sekrit').value;
+ e.ports[0].postMessage(sekrit);
+ } catch(error) {
+ e.ports[0].postMessage(error.name);
+ }
+ } else if (e.data.cache != undefined) {
+ let path = e.data.cache;
+ try {
+ while (path.length != 0) {
+ cache = cache[path.shift()];
+ }
+ e.ports[0].postMessage('cached');
+ } catch (error) {
+ e.ports[0].postMessage(error.name);
+ }
+ } else if (e.data == 'touch-cached') {
+ try {
+ e.ports[0].postMessage(cache.foo);
+ } catch (error) {
+ e.ports[0].postMessage(error.name);
+ }
+ } else if (e.data == 'poke-at-parent') {
+ try {
+ var sekrit = window.parent.document.body.querySelector('#sekrit').value;
+ e.ports[0].postMessage(sekrit);
+ } catch(error) {
+ e.ports[0].postMessage(error.name);
+ }
+ }
+ });
+ window.parent.postMessage('Hi!', '*');
+</script>
+<input id="sekrit" value="omg!">