Skip to content

Commit

Permalink
Merge pull request #5150 from lyzadanger/browsing-context-names-parent
Browse files Browse the repository at this point in the history
HTML: Extend Test Coverage for _parent named browsing context (7.1.5)
  • Loading branch information
lyzadanger authored Mar 27, 2017
2 parents 0508311 + 070a1f4 commit e27e750
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - '_parent'</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(t => {
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'parentWin');
}));
}, 'The parent browsing context must be chosen if the given name is `_parent`');
</script>
<iframe id="embedded" src="resources/parent-iframe-1.html" name="parentWin" style="display:none"></iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - '_parent' (nested contexts)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(t => {
var topWindow;
t.add_cleanup(() => topWindow.close());
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'iframeParent');
assert_false(e.data.isTop, 'window.parent is not top');
}));
topWindow = window.open('resources/parent-top.html', '_blank');
}, 'choosing _parent context: multiple nested contexts');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - '_parent' (via window.open)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(t => {
var topWindow;
t.add_cleanup(() => topWindow.close());
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'parentTopReplace');
assert_equals(e.data.isTop, true);
}));
topWindow = window.open('resources/parent-top-replace.html', 'parentTopReplace');
}, '_parent should reuse window.parent context');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - '_parent' (case-sensitivity)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="resources/parent-iframe-insensitive-1.html" name="parentWin" style="display:none"></iframe>

<script>
async_test(t => {
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'parentWin', "The browsing context name should be 'parentWin'.");
assert_equals(e.data.isTop, false);
}));
}, 'choosing _parent context should be case-insensitive');
</script>

This file was deleted.

2 changes: 1 addition & 1 deletion html/browsers/windows/browsing-context-names/existing.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>

function do_test() {
window.open("message.html", "existWin");
window.open("resources/post-to-top.html", "existWin");
}

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<iframe src="parent2.html"></iframe>
<iframe src="parent-iframe-2.html"></iframe>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>

window.open("message.html", "_parent");
window.open("post-to-top.html", "_parent");

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent</title>
<script>
window.open("post-to-opener.html", "_parent");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent</title>
<iframe src="parent-iframe-insensitive-2.html"></iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent (case-insensitive)</title>
<script>

window.open("post-to-top-or-close.html", "_pARent");

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent: nested context</title>
<iframe name="iframeChild" src="parent-iframe-2.html"></iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent: top-level context (gets replaced)</title>
<iframe name="iframeOpener" src="parent-iframe-3.html"></iframe>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent: top-level context</title>
<iframe name="iframeParent" src="parent-top-nested.html"></iframe>
<script>
// Relay a message from child context to opener context
window.addEventListener('message', e => {
if (window.opener) {
window.opener.postMessage(e.data, '*');
}
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: post window's name to top browsing context</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>
if (window.opener) {
window.opener.postMessage({
name: window.name,
isTop: (window.top === window)
}, "*");
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: post window's name to top browsing context</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>
if (window.top === window) {
// This is an implicit failure; go ahead and close now
// so that this window isn't left hanging around
window.close();
} else {
top.postMessage({
name: window.name,
isTop: (window.top === window)
}, "*");
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<title>HTML Test: post window's name to top browsing context</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>

top.postMessage({name: window.name}, "*");

top.postMessage({
name: window.name,
isTop: (window.top === window)
}, "*");
</script>
2 changes: 1 addition & 1 deletion html/browsers/windows/browsing-context-names/self1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>

window.name = "selfWin1";
var win = window.open("message.html", "_self");
var win = window.open("resources/post-to-top.html", "_self");
win.close();

</script>
2 changes: 1 addition & 1 deletion html/browsers/windows/browsing-context-names/self2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>

window.name = "selfWin2";
var win = window.open("message.html", "");
var win = window.open("resources/post-to-top.html", "");
win.close();

</script>

0 comments on commit e27e750

Please sign in to comment.