fixup merge with ToT + cleanup navigation tests.
diff --git a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_navigation.sub.html b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_navigation.sub.html
index b3a6c59..9c24bc9 100644
--- a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_navigation.sub.html
+++ b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_navigation.sub.html
@@ -16,7 +16,7 @@
function createFrame(origin) {
return new Promise(resolve => {
var i = document.createElement('iframe');
- i.src = origin + "/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_iframe.html";
+ i.src = origin + "/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html";
window.addEventListener('message', m => {
if (m.source == i.contentWindow)
resolve(i);
@@ -26,6 +26,24 @@
}
promise_test(t => {
+ var f1, f2;
+ return createFrame("http://{{domains[www]}}:{{ports[http][0]}}")
+ .then(f => {
+ f1 = f;
+ return createFrame("http://{{domains[www]}}:{{ports[http][0]}}");
+ })
+ .then(f => {
+ f2 = f;
+ return postMessageToFrame(f, { poke: 1 });
+ })
+ .then(response => {
+ assert_equals(response.data, "navigated");
+ f1.remove();
+ f2.remove();
+ });
+ }, "One frame can navigate a same origin sibling.");
+
+ promise_test(t => {
var f1, f2;
return createFrame("http://{{domains[www]}}:{{ports[http][0]}}")
.then(f => {
@@ -40,7 +58,29 @@
return postMessageToFrame(f1, { poke: 1 });
})
.then(response => {
- assert_equals(response.data, "navigated");
+ assert_equals(response.data, "SecurityError");
+ f1.remove();
+ f2.remove();
});
- }, "One frame can navigate the other.");
+ }, "One frame cannot navigate a same origin but not same origin-domain sibling.");
+
+ promise_test(t => {
+ var f1, f2;
+ return createFrame("http://{{domains[www]}}:{{ports[http][0]}}")
+ .then(f => {
+ f1 = f;
+ return createFrame("http://{{domains[www]}}:{{ports[http][0]}}");
+ })
+ .then(f => {
+ f2 = f;
+ return postMessageToFrame(f1, { domain: '{{domains[]}}' });
+ })
+ .then(_ => postMessageToFrame(f1, { domain: '{{domains[]}}' }))
+ .then(_ => postMessageToFrame(f1, { poke: 1 }))
+ .then(response => {
+ assert_equals(response.data, "SecurityError");
+ f1.remove();
+ f2.remove();
+ });
+ }, "One frame can navigate a same origin-domain sibling.");
</script>
diff --git a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_null.tentative.html b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_null.tentative.html
index 314a703..f01c7e1 100644
--- a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_null.tentative.html
+++ b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_null.tentative.html
@@ -30,7 +30,7 @@
promise_test(t => {
return createFrame()
- .then(f => postMessageToFrame(f, 'poke-at-parent'))
+ .then(f => postMessageToFrame(f, { 'poke': 'parent' }))
.then(result => {
assert_equals(result.data, document.querySelector('#sekrit').value);
result.frame.remove();
@@ -42,7 +42,7 @@
.then(f => postMessageToFrame(f, { domain: null }))
.then(result => {
assert_equals(result.data, 'Done');
- return postMessageToFrame(result.frame, 'poke-at-parent')
+ return postMessageToFrame(result.frame, { 'poke': 'parent' })
.then(result => {
assert_equals(result.data, 'SecurityError');
result.frame.remove();
@@ -55,7 +55,7 @@
.then(f => {
document.domain = null;
assert_equals(document.domain, "null");
- return postMessageToFrame(f, 'poke-at-parent');
+ return postMessageToFrame(f, { 'poke': 'parent' });
})
.then(result => {
assert_equals(result.data, 'SecurityError');
@@ -72,7 +72,7 @@
})
.then(result => {
assert_equals(result.data, 'Done');
- return postMessageToFrame(result.frame, 'poke-at-parent')
+ return postMessageToFrame(result.frame, { 'poke': 'parent' })
.then(result => {
assert_equals(result.data, 'SecurityError');
result.frame.remove();
diff --git a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_srcdoc.html b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_srcdoc.html
index 65a7f5c..89027f43 100644
--- a/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_srcdoc.html
+++ b/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter_srcdoc.html
@@ -29,7 +29,7 @@
} catch(error) {
e.ports[0].postMessage(error.name);
}
- } else if (e.data == 'poke-at-parent') {
+ } else if (e.data.poke == 'parent') {
try {
var sekrit = window.parent.document.body.querySelector('#sekrit').value;
e.ports[0].postMessage(sekrit);
@@ -50,7 +50,7 @@
promise_test(t => {
return createFrame()
- .then(f => postMessageToFrame(f, 'poke-at-parent'))
+ .then(f => postMessageToFrame(f, { 'poke': 'parent' }))
.then(result => {
assert_equals(result.data, document.querySelector('#sekrit').value);
result.frame.remove();
@@ -62,7 +62,7 @@
.then(f => postMessageToFrame(f, { domain: window.location.hostname }))
.then(result => {
assert_equals(result.data, 'Done');
- return postMessageToFrame(result.frame, 'poke-at-parent')
+ return postMessageToFrame(result.frame, { 'poke': 'parent' })
.then(result => {
assert_equals(result.data, document.querySelector('#sekrit').value);
result.frame.remove();
@@ -74,7 +74,7 @@
return createFrame()
.then(f => {
document.domain = window.location.hostname;
- return postMessageToFrame(f, 'poke-at-parent');
+ return postMessageToFrame(f, { 'poke': 'parent' });
})
.then(result => {
assert_equals(result.data, document.querySelector('#sekrit').value);
diff --git a/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html b/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
index 42e8137..62c2d65 100644
--- a/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
+++ b/html/browsers/origin/relaxing-the-same-origin-restriction/support/document_domain_frame.html
@@ -8,14 +8,22 @@
} catch(error) {
e.ports[0].postMessage(error.name);
}
- } else if (e.data == 'poke-at-parent') {
+ } else if (e.data.poke == "parent") {
try {
var sekrit = window.parent.document.body.querySelector('#sekrit').value;
e.ports[0].postMessage(sekrit);
} catch(error) {
e.ports[0].postMessage(error.name);
}
- }
+ } else if (e.data.poke) {
+ try {
+ window.parent.frames[e.data.poke].location.href = "http://example.com/";
+ e.ports[0].postMessage("navigated");
+ } catch(error) {
+ e.ports[0].postMessage(error.name);
+ }
+ }
});
window.parent.postMessage('Hi!', '*');
</script>
+