Skip to content

Commit

Permalink
Refactor, clean up, validate browsing context names tests
Browse files Browse the repository at this point in the history
- Refactor _self tests
- Rename test files for consistency
- Refactor _blank tests
- Refactor default-002 test to be a valid test
- Refactor choose-existing test
  • Loading branch information
lyzadanger committed Apr 5, 2017
1 parent 1df4318 commit afa8f8e
Show file tree
Hide file tree
Showing 31 changed files with 126 additions and 163 deletions.
8 changes: 0 additions & 8 deletions html/browsers/windows/browsing-context-names/001-1.html

This file was deleted.

22 changes: 0 additions & 22 deletions html/browsers/windows/browsing-context-names/001.html

This file was deleted.

8 changes: 0 additions & 8 deletions html/browsers/windows/browsing-context-names/002-1.html

This file was deleted.

25 changes: 0 additions & 25 deletions html/browsers/windows/browsing-context-names/002.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,21 @@
<!doctype html>
<title>Link with target=_blank, rel=noreferrer</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedLocalStorage.js"></script>
<div id="log"></div>
<a href="resources/report-has-opener.html" rel="noreferrer" target="_blank">Link</a>
<script>
var prefixedStorage;
setup (() => prefixedStorage = new PrefixedLocalStorageTest());

async_test(t => {
t.add_cleanup(() => prefixedStorage.cleanup());
var a = document.getElementsByTagName('a')[0];
a.href = prefixedStorage.url(a.href);
prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
assert_equals(e.newValue, 'false');
}));
a.click();
}, 'Context for opened noreferrer link targeted to "_blank" should not have opener reference');
</script>
@@ -0,0 +1,20 @@
<!doctype html>
<title>Link with target=_blank, no rel</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedLocalStorage.js"></script>
<div id="log"></div>
<a href="resources/report-has-opener.html" target="_blank">Link</a>
<script>
var prefixedStorage;
setup(() => prefixedStorage = new PrefixedLocalStorageTest());
async_test(t => {
t.add_cleanup(() => prefixedStorage.cleanup());
prefixedStorage.onSet('hasOpener', t.step_func_done(e => {
assert_equals(e.newValue, 'true');
}));
var a = document.getElementsByTagName('a')[0];
a.href = prefixedStorage.url(a.href);
a.click();
}, 'Context created by link targeting "_blank" should retain opener reference');
</script>
Expand Up @@ -12,4 +12,4 @@
}));
}, '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>
<iframe id="embedded" src="resources/choose-_parent-001-iframe-1.html" name="parentWin" style="display:none"></iframe>
Expand Up @@ -12,6 +12,6 @@
assert_equals(e.data.name, 'iframeParent');
assert_false(e.data.isTop, 'window.parent is not top');
}));
topWindow = window.open('resources/parent-top.html', '_blank');
topWindow = window.open('resources/choose-_parent-002-window.html', '_blank');
}, 'choosing _parent context: multiple nested contexts');
</script>
Expand Up @@ -12,6 +12,6 @@
assert_equals(e.data.name, 'parentTopReplace');
assert_equals(e.data.isTop, true);
}));
topWindow = window.open('resources/parent-top-replace.html', 'parentTopReplace');
topWindow = window.open('resources/choose-_parent-003-window.html', 'parentTopReplace');
}, '_parent should reuse window.parent context');
</script>
Expand Up @@ -4,7 +4,7 @@
<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>
<iframe src="resources/choose-_parent-004-iframe-1.html" name="parentWin" style="display:none"></iframe>

<script>
async_test(t => {
Expand Down
15 changes: 15 additions & 0 deletions html/browsers/windows/browsing-context-names/choose-_self-001.html
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - the given name is '_self'</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>
<iframe src="resources/choose-_self-001-iframe.html" style="display:none"></iframe>
<script>
async_test(t => {
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'myownself');
}), false);
}, 'The current browsing context must be chosen if the given name is "_self"');
</script>
Expand Up @@ -20,10 +20,4 @@
assert_equals(win.name, "");
win.close();
}, "A browsing context which is opened by window.open() method with '_blank' parameter has empty-string default name");

//This test must be run when the current browsing context's name is not set
test(t => {
assert_equals(window.name, "");
}, "A browsing context has an empty-string default name");

</script>
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Browsing context names - empty string</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.isTop, false);
assert_equals(e.data.name, 'hellothere', 'Empty-string browsing context should choose current context');
}), false);
}, 'The current browsing context must be chosen if the given name is empty string');
</script>
<iframe name="hellothere" src="resources/choose-default-002-iframe.html"></iframe>
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Choose browsing context - the given name is same as an existing browsing context's name</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>
<iframe src="resources/choose-existing-001-iframe.html" style="display:none"></iframe>
<iframe name="iExist" style="display:none"></iframe>
<script>
async_test(t => {
window.addEventListener('message', t.step_func_done(e => {
assert_equals(e.data.name, 'iExist');
}), false);

}, 'An existing browsing context must be chosen if the given name is the same as its name');
</script>
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="parent-iframe-2.html"></iframe>
<iframe src="open-in-_parent.html"></iframe>
@@ -1,4 +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>
<iframe name="iframeChild" src="open-in-_parent.html"></iframe>
@@ -1,7 +1,7 @@
<!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>
<iframe name="iframeParent" src="choose-_parent-002-iframe.html"></iframe>
<script>
// Relay a message from child context to opener context
window.addEventListener('message', e => {
Expand Down
@@ -1,4 +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>
<iframe name="iframeOpener" src="choose-_parent-003-iframe.html"></iframe>
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - parent</title>
<iframe src="parent-iframe-insensitive-2.html"></iframe>
<iframe src="choose-_parent-004-iframe-2.html"></iframe>
Expand Up @@ -3,9 +3,7 @@
<title>HTML Test: browsing context name - self</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>

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

</script>
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>HTML Test: browsing context name - Empty string</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<body onload="followLink()">
</body>
<script>
function followLink() {
var a = document.createElement('a');
a.href = 'post-to-top.html';
a.target = ''; // Target is empty string
document.body.appendChild(a);
a.click();
}
</script>
</html>
Expand Up @@ -3,9 +3,5 @@
<title>This is a test page</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script>

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

window.open("post-to-top.html", "iExist");
</script>
@@ -0,0 +1,8 @@
<!doctype html>
<script src="/common/PrefixedLocalStorage.js"></script>
<script>
var prefixedStorage = new PrefixedLocalStorageResource({
close_on_cleanup: true
});
prefixedStorage.setItem('hasOpener', window.opener !== null);
</script>
11 changes: 0 additions & 11 deletions html/browsers/windows/browsing-context-names/self1.html

This file was deleted.

0 comments on commit afa8f8e

Please sign in to comment.