diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/links')
19 files changed, 315 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/links/.gitkeep b/testing/web-platform/tests/html/semantics/links/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/.gitkeep b/testing/web-platform/tests/html/semantics/links/downloading-resources/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/contains.json b/testing/web-platform/tests/html/semantics/links/downloading-resources/contains.json new file mode 100644 index 000000000..b67f855cf --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/contains.json @@ -0,0 +1,6 @@ +[ + { + "id": "hyperlink-auditing", + "original_id": "hyperlink-auditing" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/links/following-hyperlinks/.gitkeep b/testing/web-platform/tests/html/semantics/links/following-hyperlinks/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/following-hyperlinks/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/introduction-3/.gitkeep b/testing/web-platform/tests/html/semantics/links/introduction-3/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/introduction-3/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/.gitkeep b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_attribute-getter-setter.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_attribute-getter-setter.html new file mode 100644 index 000000000..2db3082e2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_attribute-getter-setter.html @@ -0,0 +1,65 @@ +<!doctype html> +<meta charset="utf-8"> +<html> +<head> +<title>HTMLAnchorElement getters and setters</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<a>anchor</a> +<script> +function test_gettersetter(property, oldresult, newval, newresult, oldurl, newurl) { + var a = document.querySelector('a'); + a.href = oldurl; + var r1 = a[property]; + assert_equals(r1, oldresult); + a[property] = newval; + var r2 = a[property]; + assert_equals(r2, newresult); + var r3 = a.href; + assert_equals(r3, newurl); +} + +//Elements for each test: [property, oldresult, newvalue, newresult, oldurl, newurl] +// [0] [1] [2] [3] [4] [5] +tests = [ + ["hash", "#somehash", "someother", "#someother", + "http://google.com/index.html#somehash", + "http://google.com/index.html#someother"], + ["hash", "#somehash", "#someother", "#someother", + "http://google.com/index.html#somehash", + "http://google.com/index.html#someother"], + ["host", "google.com:1234", "github.com:4444", "github.com:4444", + "http://google.com:1234/somedir", + "http://github.com:4444/somedir"], + ["hostname", "google.com", "github.com", "github.com", + "http://google.com:1234/somedir", + "http://github.com:1234/somedir"], + ["href", "http://google.com:1234/somedir", "http://goo-gle.com:1234/other/x.html", "http://goo-gle.com:1234/other/x.html", + "http://google.com:1234/somedir", + "http://goo-gle.com:1234/other/x.html"], + ["password", "flabada", "blubb", "blubb", + "https://anonymous:flabada@developer.mozilla.org/en-US/docs/", + "https://anonymous:blubb@developer.mozilla.org/en-US/docs/"], + ["pathname", "/somedir/someotherdir/index.html", "/newpath/x.txt", "/newpath/x.txt", + "http://google.com:1234/somedir/someotherdir/index.html", + "http://google.com:1234/newpath/x.txt"], + ["port", "1234", "4444", "4444", "http://google.com:1234/somedir", "http://google.com:4444/somedir"], + ["protocol", "http:", "ftp:", "ftp:", "http://google.com/somedir", "ftp://google.com/somedir"], + ["protocol", "http:", "ftp", "ftp:", "http://google.com/somedir", "ftp://google.com/somedir"], + ["search", "?ho", "?hi", "?hi", "http://google.com/q.php?ho", "http://google.com/q.php?hi"], + ["search", "?ho", "hi", "?hi", "http://google.com/q.php?ho", "http://google.com/q.php?hi"], + ["search", "?ho", "?hi", "?hi", "http://google.com/?ho", "http://google.com/?hi"], + ["search", "?ho", "hi", "?hi", "http://google.com/?ho", "http://google.com/?hi"], + ["username", "anonymous", "wellknown", "wellknown", + "https://anonymous:pwd@developer.mozilla.org:1234/en-US/", + "https://wellknown:pwd@developer.mozilla.org:1234/en-US/"] +]; + +for (var i = 0; i < tests.length; i++) { + test(function() { + test_gettersetter(tests[i][0], tests[i][1], tests[i][2], tests[i][3], tests[i][4], tests[i][5]) + }, "Getter and setter for attribute of anchor element(" + i + "):" + tests[i][0] ); +} +</script> +</head> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_getter.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_getter.html new file mode 100644 index 000000000..759eada22 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_getter.html @@ -0,0 +1,48 @@ +<!doctype html> +<meta charset="utf-8"> +<html> +<head> +<title>HTMLAnchorElement getters test</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<a id=a1 href="http://google.com?hi">a1</a> +<a id=a2 href="http://google.com#somehash">a2</a> +<a id=a3 href="http://google.com:1234/somedir">a3</a> +<a id=a4 href="http://google.com:1234/somedir">a4</a> +<a id=a5 href="http://google.com:1234/somedir">a5</a> +<a id=a6 href="https://anonymous:flabada@developer.mozilla.org/en-US/docs/">a6</a> +<a id=a7 href="http://google.com:1234/somedir/someotherdir/index.html">a7</a> +<a id=a8 href="http://google.com:1234/somedir">a8</a> +<a id=a9 href="http://google.com/somedir">a9</a> +<a id=a10 href="https://anonymous:pwd@developer.mozilla.org:1234/en-US/">a10</a> +<script> +function test_getter(property, result, id) { + var a = document.getElementById(id); + var r = a[property]; + assert_equals(r, result); +} + +//Elements for each test: [property, result, id] +// [0] [1] [2] +tests = [ + ["search", "?hi", "a1"], + ["hash", "#somehash", "a2"], + ["host", "google.com:1234", "a3"], + ["hostname", "google.com", "a4"], + ["href", "http://google.com:1234/somedir", "a5"], + ["password", "flabada", "a6"], + ["pathname", "/somedir/someotherdir/index.html", "a7"], + ["port", "1234", "a8"], + ["protocol", "http:", "a9"], + ["username", "anonymous", "a10"] +]; + +for (var i = 0; i < tests.length; i++) { + test(function() { + test_getter(tests[i][0], tests[i][1], tests[i][2]) + }, "Getter for attribute of anchor element(" + i + "):" + tests[i][0]); +} +</script> +</head> +</html> + diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html new file mode 100644 index 000000000..3d22481d2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html @@ -0,0 +1,78 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test behavior of rel="noopener" links</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<iframe name="oursubframe"></iframe> +<a href="support/noopener-target-2.html" rel="noopener" target="ourpopup"></a> +<a href="support/noopener-target-2.html" rel="noopener" target="oursubframe"></a> +<script> +var tests = []; +// First test the special targets +function target1Loaded(win) { + // Find the relevant test + var test = tests.find((t) => t.openedWindow == win); + test.step(function() { + assert_equals(win.opener, window); + win.close(); + test.done(); + }); +} +/** + * Test that <a rel="noopener"> targeted at one of _self, _parent, _top does the + * load in the appropriate existing browsing context instead of opening a new + * one. The test is run in a separate popup window we open and which we can + * navigate without causing the test harness going into conniptions. + */ +for (var target of ["self", "parent", "top"]) { + var t = async_test("Check that rel=noopener with target=_" + target + " does a normal load"); + tests.push(t); + t.openedWindow = window.open("support/noopener-popup.html"); + t.targetName = target; + t.openedWindow.onload = t.step_func(function() { + this.openedWindow.findLink(this.targetName).click(); + }); +} + +/** + * And now check that a noopener load targeted at something other than one of + * the three special targets above in fact ignores existing things with the + * given name. We do this in two ways. First, by opening a window named + * "ourpopup" and then doing a load via <a rel="noopener" target="ourpopup"> and + * verifying that the load happens in a window with a null opener, etc, while + * the opener of the thing we opened is not modified. And second, by targeting + * <a rel="noopener"> at a name that an existing subframe has, and ensuring that + * this subframe is not navigated. + */ +var t1 = async_test("Check that targeting of rel=noopener with a given name ignores an existing window with that name"); +var w; +t1.add_cleanup(function() { w.close(); }); +var channel = new BroadcastChannel("ourpopup"); +channel.onmessage = t1.step_func_done(function(e) { + var data = e.data; + assert_false(data.hasOpener); + assert_false(data.hasParent); + assert_equals(data.name, "ourpopup"); + assert_equals(w.opener, window); + assert_equals(w.location.href, "about:blank"); +}); +t1.step(function() { + w = window.open("", "ourpopup"); + assert_equals(w.opener, window); + document.querySelectorAll("a")[0].click(); +}); + +var t2 = async_test("Check that targeting of rel=noopener with a given name ignores an existing subframe with that name"); +var channel = new BroadcastChannel("oursubframe"); +channel.onmessage = t2.step_func_done(function(e) { + var data = e.data; + assert_false(data.hasOpener); + assert_false(data.hasParent); + assert_equals(data.name, "oursubframe"); + assert_equals(document.querySelector("iframe").contentWindow.location.href, + "about:blank"); +}); +t2.step(function() { + document.querySelectorAll("a")[1].click(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-popup.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-popup.html new file mode 100644 index 000000000..2057dbf0b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-popup.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<script> + function findLink(arg) { + var doc; + if (arg == "self") { + doc = document; + } else { + doc = frames[0].document; + } + return doc.getElementById(arg + "target"); + } +</script> +<a rel="noopener" target="_self" id="selftarget" + href="noopener-target-1.html"></a> +<iframe srcdoc=' + <a rel="noopener" target="_parent" id="parenttarget" + href="noopener-target-1.html"></a> + <a rel="noopener" target="_top" id="toptarget" + href="noopener-target-1.html"></a>'></iframe> diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-1.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-1.html new file mode 100644 index 000000000..0dbd14275 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-1.html @@ -0,0 +1,4 @@ +<!DOCTYPE html> +<script> + opener.target1Loaded(this); +</script> diff --git a/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-2.html b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-2.html new file mode 100644 index 000000000..dd2d71913 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/links-created-by-a-and-area-elements/support/noopener-target-2.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<script> + var channel = new BroadcastChannel(this.name); + channel.postMessage({ hasOpener: opener !== null , + hasParent: parent != this, + name: window.name }); + window.close(); +</script> diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/.gitkeep b/testing/web-platform/tests/html/semantics/links/linktypes/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css-ref.html b/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css-ref.html new file mode 100644 index 000000000..ec961eac1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css-ref.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Reference of Alternate css</title> +<link rel="stylesheet" href="preferred.css" title="preferred"> +<div>foobar</div> diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css.html b/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css.html new file mode 100644 index 000000000..366d6c559 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/alternate-css.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Alternate css</title> +<link rel="match" href="alternate-css-ref.html"> +<link rel="stylesheet" href="preferred.css" title="preferred"> +<link rel="alternate stylesheet" href="alternate.css" title="alternate"> +<div>foobar</div> diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/alternate.css b/testing/web-platform/tests/html/semantics/links/linktypes/alternate.css new file mode 100644 index 000000000..05920c613 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/alternate.css @@ -0,0 +1,3 @@ +div { + background-color: red; +} diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/contains.json b/testing/web-platform/tests/html/semantics/links/linktypes/contains.json new file mode 100644 index 000000000..55aa4f677 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/contains.json @@ -0,0 +1,68 @@ +[ + { + "id": "rel-alternate", + "original_id": "rel-alternate" + }, + { + "id": "link-type-author", + "original_id": "link-type-author" + }, + { + "id": "link-type-bookmark", + "original_id": "link-type-bookmark" + }, + { + "id": "link-type-help", + "original_id": "link-type-help" + }, + { + "id": "rel-icon", + "original_id": "rel-icon" + }, + { + "id": "link-type-license", + "original_id": "link-type-license" + }, + { + "id": "link-type-nofollow", + "original_id": "link-type-nofollow" + }, + { + "id": "link-type-noreferrer", + "original_id": "link-type-noreferrer" + }, + { + "id": "link-type-prefetch", + "original_id": "link-type-prefetch" + }, + { + "id": "link-type-search", + "original_id": "link-type-search" + }, + { + "id": "link-type-stylesheet", + "original_id": "link-type-stylesheet" + }, + { + "id": "link-type-tag", + "original_id": "link-type-tag" + }, + { + "id": "sequential-link-types", + "original_id": "sequential-link-types", + "children": [ + { + "id": "link-type-next", + "original_id": "link-type-next" + }, + { + "id": "link-type-prev", + "original_id": "link-type-prev" + } + ] + }, + { + "id": "other-link-types", + "original_id": "other-link-types" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/original-id.json b/testing/web-platform/tests/html/semantics/links/linktypes/original-id.json new file mode 100644 index 000000000..1e5f7b5ed --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/original-id.json @@ -0,0 +1 @@ +{"original_id":"linkTypes"}
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/links/linktypes/preferred.css b/testing/web-platform/tests/html/semantics/links/linktypes/preferred.css new file mode 100644 index 000000000..54b95ac28 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/linktypes/preferred.css @@ -0,0 +1,3 @@ +div { + border: 4px solid green; +} |