diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/the-window-object')
71 files changed, 1787 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/the-window-object/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/Document-defaultView.html b/testing/web-platform/tests/html/browsers/the-window-object/Document-defaultView.html new file mode 100644 index 000000000..dbc75d30b --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/Document-defaultView.html @@ -0,0 +1,38 @@ +<!doctype html> +<meta charset=utf-8> +<title>Document#defaultView</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +test(function() { + assert_equals(document.defaultView, window); +}, "Document in a browsing context"); + +test(function() { + var d = new Document(); + assert_equals(d.defaultView, null); +}, "Document created with the Document constructor"); + +test(function() { + var d = document.implementation.createDocument(null, null); + assert_equals(d.defaultView, null); +}, "Document created with createDocument"); + +test(function() { + var d = document.implementation.createHTMLDocument(); + assert_equals(d.defaultView, null); +}, "Document created with createHTMLDocument"); + +test(function() { + var parser = new DOMParser(); + var d = parser.parseFromString("<foo\/\>", "application/xml"); + assert_equals(d.defaultView, null); +}, "Document created with XML DOMParser"); + +test(function() { + var parser = new DOMParser(); + var d = parser.parseFromString("bar", "text/html"); + assert_equals(d.defaultView, null); +}, "Document created with HTML DOMParser"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/Window-document.html b/testing/web-platform/tests/html/browsers/the-window-object/Window-document.html new file mode 100644 index 000000000..9b27f5f7c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/Window-document.html @@ -0,0 +1,25 @@ +<!doctype html> +<meta charset=utf-8> +<title>Window#document</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +async_test(function() { + var URL = "/common/blank.html"; + + var iframe = document.createElement("iframe"); + document.body.appendChild(iframe); + var initialWindow = iframe.contentWindow; + var initialDocument = initialWindow.document; + assert_equals(initialDocument.URL, "about:blank"); + iframe.src = URL; + iframe.onload = this.step_func_done(function() { + assert_equals(iframe.contentWindow, initialWindow); + assert_equals(initialDocument.URL, "about:blank"); + var loadedDocument = initialWindow.document; + assert_equals(loadedDocument.URL, location.href.replace(location.pathname, URL)); + assert_not_equals(initialDocument, loadedDocument); + }); +}, "Document in a browsing context"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-01.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-01.html new file mode 100644 index 000000000..9710d15fb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-01.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: the browsing contexts must be sorted in the order that their containers were inserted into the Document</title> +<link rel="author" title="Intel" href="http://www.intel.com/" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#accessing-other-browsing-contexts" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +var t1 = async_test("The window's length must return the number of child browsing contexts(in iframe)"); +function on_load1(fr) { + t1.step(function () { + var doc = fr.contentDocument; + var fr3 = doc.createElement("iframe"); + fr3.setAttribute("id", "fr3"); + doc.body.insertBefore(fr3, doc.getElementById("tbl")); + + assert_equals(fr.contentWindow.length, 3, "The window.length should be 3."); + assert_array_equals([fr.contentWindow[0].frameElement, fr.contentWindow[1].frameElement, fr.contentWindow[2].frameElement], + [fr.contentDocument.getElementById("fr4"), fr.contentDocument.getElementById("fr5"), fr.contentDocument.getElementById("fr3")], + "The child browsing contexts must be sorted in the order that their containers were inserted into the Document."); + }); + t1.done(); +} + +var t2 = async_test("The window's length must return zero if it has no child browsing context"); +function on_load2(fr) { + t2.step(function () { + assert_equals(fr.contentWindow.length, 0, "The window.length should be 0."); + }); + t2.done(); +} + +</script> +<iframe id="fr1" src="test1.html" style="display:none" onload="on_load1(this)"></iframe> +<iframe id="fr2" src="test2.html" style="display:none" onload="on_load2(this)"></iframe> +<script> + +test(function () { + assert_equals(window.length, 2, "The window.length should be 2."); + assert_array_equals([window[0].frameElement, window[1].frameElement], + [document.getElementById("fr1"), document.getElementById("fr2")], + "The child browsing contexts must be sorted in the tree order."); +}, "The window's length must return the number of child browsing contexts"); + +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-02.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-02.html new file mode 100644 index 000000000..d09c944fd --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-02.html @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<head> + <meta charset="utf-8"> + <title>HTML Test: the browsing contexts created by various container elements</title> + <link rel="author" title="Intel" href="http://www.intel.com/" /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script> + + var t1 = async_test("Accessing child browsing contexts 1"); + var t2 = async_test("Accessing child browsing contexts 2"); + var t3 = async_test("Accessing child browsing contexts 3"); + function on_load() { + //Child browsing contexts created by iframe, object and embed elements. + t1.step(function () { + assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); + }); + t1.step(function () { + assert_equals(window[0].name, "win1", "The browsing context name should be 'win1'."); + assert_equals(window[1].name, "win2", "The browsing context name should be 'win2'."); + assert_equals(window[2].name, "win3", "The browsing context name should be 'win3'."); + }); + t1.done(); + + //Child browsing contexts created by frame elements. + t2.step(function () { + assert_equals(document.getElementById("fr").contentWindow.length, 2, + "The child browsing context created by the iframe element should have 2 child browsing contexts."); + }); + t2.step(function () { + assert_equals(document.getElementById("fr").contentWindow[0].name, "win4", + "The browsing context name should be 'win4'."); + assert_equals(document.getElementById("fr").contentWindow[1].name, "win5", + "The browsing context name should be 'win5'."); + }); + t2.done(); + + //The child browsing context will be removed if the data attribute of the associated object element is removed. + t3.step(function () { + document.getElementById("obj").removeAttribute("type"); + assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); + document.getElementById("obj").removeAttribute("data"); + assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts."); + + setTimeout(function () { + assert_equals(window.length, 2, "The top browsing context should have 2 child browsing contexts."); + }, 1); + }); + t3.done(); + } + + </script> +</head> +<body onload="on_load()"> + <div id="log"></div> + <div style="display:none"> + <iframe id="fr" name="win1" src="test3.html"></iframe> + <object id="obj" name="win2" type="text/html" data="about:blank"></object> + <object type="image/png" src="/images/green.png"></object> + <embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg"></embed> + </div> +</body> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html new file mode 100644 index 000000000..154889117 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-03.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<head> + <meta charset="utf-8"> + <title>HTML Test: indexed property of a Window object</title> + <link rel="author" title="Intel" href="http://www.intel.com/" /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script> + + var t1 = async_test("Indexed child browsing contexts"); + function on_load() { + t1.step(function () { + assert_equals(window[0], document.getElementsByTagName("object")[0].contentWindow, + "The first child browsing context's container should be the object element."); + assert_equals(window[1], document.getElementsByTagName("iframe")[0].contentWindow, + "The second child browsing context's container should be the iframe element."); + }); + t1.done(); + } + + </script> +</head> +<body onload="on_load()"> + <div id="log"></div> + <div style="display:none"> + <div id="0"></div> + <object name="0" type="text/html" data="test2.html"></object> + <iframe name="0" src="about:blank"></iframe> + </div> +</body> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/iterator.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/iterator.html new file mode 100644 index 000000000..76dc7dbae --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/iterator.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>window[@@iterator]</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_false(Symbol.iterator in window); +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test1.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test1.html new file mode 100644 index 000000000..f85f90f7c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test1.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: child browsing contexts created by iframe elements</title> +<link rel="author" title="Intel" href="http://www.intel.com/" /> +<table id="tbl"> + <tr> + <td> + <iframe id="fr4" src=""></iframe> + </td> + </tr> + <iframe id="fr5" src="about:blank"></iframe> +</table> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test2.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test2.html new file mode 100644 index 000000000..d6a16647f --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test2.html @@ -0,0 +1,6 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: child browsing contexts created by object and embed elements</title> +<link rel="author" title="Intel" href="http://www.intel.com/" /> +<object type="image/png" src="/images/green.png"></object> +<embed type="image/png" src="/images/green.png"></embed> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test3.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test3.html new file mode 100644 index 000000000..a62fdbaae --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/test3.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: child browsing contexts created by frame elements</title> +<link rel="author" title="Intel" href="http://www.intel.com/" /> +<frameset> + <frame name="win4"></frame> + <frame name="win5"></frame> +</frameset> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/window_length.html b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/window_length.html new file mode 100644 index 000000000..c9559b531 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/window_length.html @@ -0,0 +1,51 @@ +<!doctype html> +<title>window.length</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var iframe; +var subframe; +var other_window; +test(function() {assert_equals(window.length, 0)}, "No child browsing contexts"); +test(function() { + iframe = document.createElement("iframe"); + assert_equals(window.length, 0) +}, "iframe not inserted into the document"); + +test(function() { + document.body.appendChild(iframe); + assert_equals(window.length, 1) +}, "One iframe inserted into the document"); + +test(function() { + subframe = document.createElement("iframe"); + iframe.contentDocument.body.appendChild(subframe); + assert_equals(window.length, 1); +}, "Child browsing context has a child browsing context"); + +test(function() { + try { + assert_equals(iframe.contentWindow.length, 1); + } finally { + subframe.parentNode.removeChild(subframe); + } +}, "window.length in child frame"); + +test(function() { + iframe.parentNode.removeChild(iframe); + other_window = window.open(); + assert_equals(window.length, 0); + assert_equals(other_window.length, 0); +}, "Opened window") + +test(function() { + other_window.document.body.appendChild(iframe); + try { + assert_equals(other_window.length, 1); + } finally { + other_window.close(); + } +}, "Iframe in opened window") + +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/callback.js b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/callback.js new file mode 100644 index 000000000..ae51265a2 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/callback.js @@ -0,0 +1 @@ +opener.callback()
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload-1.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload-1.html new file mode 100644 index 000000000..6f44d8a83 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload-1.html @@ -0,0 +1,7 @@ +<!doctype html> +<script> +onload = function() {opener.postMessage("loaded", "*")}; +onbeforeunload = function() { + opener.callback(); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload.html new file mode 100644 index 000000000..dcb8830ab --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_beforeunload.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>Running beforeunload handler in window.close()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +var w = window.open("close_beforeunload-1.html"); +onmessage = t.step_func(function(event) { + if (event.data != "loaded") { + return; + } + w.close(); +}); +callback = function() {t.done()} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer-1.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer-1.html new file mode 100644 index 000000000..c50eddd41 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer-1.html @@ -0,0 +1 @@ +<!doctype html> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer.html new file mode 100644 index 000000000..874f5be9d --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_script_defer.html @@ -0,0 +1,18 @@ +<!doctype html> +<title>Running defer script in window.close()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(undefined, {timeout:4000}); +t.step(function() { + var w = window.open("close_script_defer-1.html"); + w.document.open() + w.document.write("<script defer src='callback.js'><\/script>") + setTimeout(function() { + w.close(); + }, 1000); +}) +setTimeout(function() {t.done();}, 1000) +callback = t.step(function() {assert_unreached()}) +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload-1.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload-1.html new file mode 100644 index 000000000..9a9e304e8 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload-1.html @@ -0,0 +1,7 @@ +<!doctype html> +<script> +onload = function() {opener.postMessage("loaded", "*")}; +onunload = function() { + opener.callback(); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload.html new file mode 100644 index 000000000..e4d231b28 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>Running unload handler in window.close()</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +var w = window.open("close_unload-1.html"); +onmessage = t.step_func(function(event) { + if (event.data != "loaded") { + return; + } + w.close(); +}); +callback = function() {t.done()} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html new file mode 100644 index 000000000..75c8729cf --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[Browsing Context] : [APIs for creating browsing_contexts by name]</title> +<link rel="author" title="Duhyeong Kim" href="mailto:dduskim@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name"> +<meta name=timeout content=long> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(function() { + var currentUrl = 'http://' + window.location.host + '/common/blank.html'; + var win = window.open(currentUrl, '', 'height=1,width=1'); + this.add_cleanup(function() { win.close(); }); + win.onload = this.step_func_done(function () { + assert_equals(win.location.href, currentUrl, 'should be equal to result url'); + }); +}, 'first argument: absolute url'); + +test(function() { + var win = window.open('', '', 'height=1,width=1'); + this.add_cleanup(function() { win.close(); }); + assert_equals(win.location.href, 'about:blank', 'win.location.href'); +}, 'first argument: empty url'); + +test(function () { + var win = window.open('', 'testWindow', 'height=1,width=1'); + win.close(); + assert_equals(win.name, 'testWindow', 'should have a browsing context name'); +}, 'second argument: passing a non-empty name'); + +test(function () { + var win = window.open('', '', 'height=1,width=1'); + this.add_cleanup(function() { win.close(); }); + assert_equals(win.name, '', 'window should not have a name'); + win.name = 'testWindow'; + assert_equals(win.name, 'testWindow', 'window should have a name'); +}, 'second argument: setting name after opening'); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-1.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-1.html new file mode 100644 index 000000000..7dd48b41c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-1.html @@ -0,0 +1,2 @@ +<!doctype html> +<p>Now open a new tab and navigate to <a href="001-2.html">001-2</a></p> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-2.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-2.html new file mode 100644 index 000000000..b1413861a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001-2.html @@ -0,0 +1,16 @@ +<!doctype html> +<script> +var result = "FAIL"; +if (opener != null) { + result = "FAIL (did you open this page in a new tab?)"; +} else { + var w = window.open("", "test_name"); + if (w.location.href !== "about:blank") { + result = "FAIL (didn't open an about:blank browsing context)"; + } else { + w.close(); + result = "PASS"; + } + document.write(result); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001.html new file mode 100644 index 000000000..7b0f21ec0 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/001.html @@ -0,0 +1,3 @@ +<!doctype html> +<title>Accessing named windows from outside the unit of related browsing contexts</title> +<a href="001-1.html" target="test_name">Click here</a> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-1.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-1.html new file mode 100644 index 000000000..0e210f351 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-1.html @@ -0,0 +1,8 @@ +<!doctype html> +<p>Now open a new tab and navigate to <a></a></p> +<script> +href = window.location.href.replace("http://", "http://www.").replace("002-1.html", "002-2.html"); +var a = document.getElementsByTagName("a")[0]; +a.href = href; +a.textContent = href; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-2.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-2.html new file mode 100644 index 000000000..b1413861a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002-2.html @@ -0,0 +1,16 @@ +<!doctype html> +<script> +var result = "FAIL"; +if (opener != null) { + result = "FAIL (did you open this page in a new tab?)"; +} else { + var w = window.open("", "test_name"); + if (w.location.href !== "about:blank") { + result = "FAIL (didn't open an about:blank browsing context)"; + } else { + w.close(); + result = "PASS"; + } + document.write(result); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002.html b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002.html new file mode 100644 index 000000000..b568ae8d4 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/non_automated/002.html @@ -0,0 +1,3 @@ +<!doctype html> +<title>Accessing different-origin named windows from outside the unit of related browsing contexts</title> +<a href="002-1.html" target="test_name">Click here</a> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/browser-interface-elements/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/browser-interface-elements/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/browser-interface-elements/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/closing-browsing-contexts/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/closing-browsing-contexts/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/closing-browsing-contexts/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-1.html new file mode 100644 index 000000000..217608e46 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-1.html @@ -0,0 +1,20 @@ +<!doctype html> +<iframe></iframe> +<script> +var t = opener.t; + +onload = t.step_func(function() { + setTimeout(t.step_func(function() { + var history_length = history.length; + var iframe = document.getElementsByTagName("iframe")[0]; + iframe.onload = t.step_func(function() { + opener.assert_equals(history.length, history_length + 1); + iframe.parentNode.removeChild(iframe); + opener.assert_equals(history.length, history_length); + t.done(); + window.close(); + }); + iframe.src = "discard_iframe_history_1-2.html;"; + }), 100); +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-2.html new file mode 100644 index 000000000..b43598f2c --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1-2.html @@ -0,0 +1,2 @@ +<!doctype html> +Filler text diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html new file mode 100644 index 000000000..4d1e473fc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>Removing iframe from document removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +var w = window.open("discard_iframe_history_1-1.html"); +</script> + diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2-1.html new file mode 100644 index 000000000..61e5891eb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2-1.html @@ -0,0 +1,22 @@ +<!doctype html> +<iframe></iframe> +<script> +var t = opener.t; + +onload = t.step_func(function() { + setTimeout(t.step_func(function() { + var history_length = history.length; + var iframe = document.getElementsByTagName("iframe")[0]; + iframe.onload = t.step_func(function() { + setTimeout(t.step_func(function() { + opener.assert_equals(history.length, history_length + 1, "History length before iframe removal"); + document.body.innerHTML = ""; + opener.assert_equals(history.length, history_length, "History length after iframe removal"); + t.done(); + window.close(); + }), 100); + }); + iframe.src = "discard_iframe_history_1-2.html"; + }), 100); +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2.html new file mode 100644 index 000000000..89d0fb4c6 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_2.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>Removing iframe from document via innerHTML removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +var w = window.open("discard_iframe_history_2-1.html"); +</script> + diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-1.html new file mode 100644 index 000000000..de3f075d6 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-1.html @@ -0,0 +1,21 @@ +<script> +history_lengths = []; + +var t = opener.t; + +push_length = t.step_func(function () { + history_lengths.push(history.length) +}); + +do_test = t.step_func(function () { + try { + var start_length = history_lengths[0]; + expected = [start_length, start_length + 1, start_length]; + opener.assert_array_equals(history_lengths, expected); + t.done(); + } finally { + window.close(); + } +}); +</script> +<iframe src="discard_iframe_history_3-2.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-2.html new file mode 100644 index 000000000..95f9fce5d --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-2.html @@ -0,0 +1,4 @@ +<a href="discard_iframe_history_3-3.html" onclick="parent.push_length()">Click me</a> +<script> +onload = function() {setTimeout(parent.t.step_func(function() {document.links[0].click()}), 100)} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-3.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-3.html new file mode 100644 index 000000000..4672b0ec3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3-3.html @@ -0,0 +1,4 @@ +<button onclick="var p = parent; p.push_length(); frameElement.parentNode.removeChild(frameElement); p.push_length(); p.do_test();">Click me</button> +<script> +onload = function() {setTimeout(parent.t.step_func(function() {document.getElementsByTagName("button")[0].click()}), 100)} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3.html new file mode 100644 index 000000000..3046f854f --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_3.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>Removing iframe from document removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(undefined); +var w = window.open("discard_iframe_history_3-1.html"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-1.html new file mode 100644 index 000000000..1b5726cdc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-1.html @@ -0,0 +1,21 @@ +<script> +history_lengths = []; + +var t = opener.t; + +push_length = t.step_func(function () { + history_lengths.push(history.length) +}); + +do_test = t.step_func(function () { + try { + var start_length = history_lengths[0]; + expected = [start_length, start_length + 1, start_length]; + opener.assert_array_equals(history_lengths, expected); + t.done(); + } finally { + window.close(); + } +}); +</script> +<iframe src="discard_iframe_history_4-2.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-2.html new file mode 100644 index 000000000..979b2b28e --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-2.html @@ -0,0 +1,4 @@ +<a href="discard_iframe_history_4-3.html" onclick="parent.push_length()">Click me</a> +<script> +onload = function() {setTimeout(parent.t.step_func(function() {document.links[0].click()}), 100)} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-3.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-3.html new file mode 100644 index 000000000..b4308f439 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4-3.html @@ -0,0 +1,4 @@ +<button onclick="var p = parent; p.push_length(); frameElement.parentNode.innerHTML = ''; p.push_length(); p.do_test();">Click me</button> +<script> +onload = function() {setTimeout(parent.t.step_func(function() {document.getElementsByTagName("button")[0].click()}), 100)} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4.html new file mode 100644 index 000000000..ffd444e3b --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_4.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>Removing iframe from document removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +var w = window.open("discard_iframe_history_4-1.html"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-1.html new file mode 100644 index 000000000..996942798 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-1.html @@ -0,0 +1,27 @@ +<!doctype html> +<iframe></iframe> +<script> +var t = opener.t; +var iframe = document.getElementsByTagName("iframe")[0]; +var history_length; + +function load_frame(src) { + history_length = history.length; + iframe.src = src; + var button = document.getElementsByTagName("button")[0]; + button.parentNode.removeChild(button); +} + +remove_frame = t.step_func(function() { + try { + opener.assert_equals(history.length, history_length + 1, "History length after loading page in iframe"); + iframe.parentNode.removeChild(iframe); + opener.assert_equals(history.length, history_length, "History length after removing iframe"); + t.done(); + } finally { + window.close(); + } +}); + +</script> +<button onclick="load_frame('discard_iframe_history_1-2.html')">Click here</button> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-2.html new file mode 100644 index 000000000..8c3d1a9da --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-2.html @@ -0,0 +1,2 @@ +<!doctype html> +<button onclick="parent.remove_frame()">Click here</button> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-manual.html new file mode 100644 index 000000000..d69d7d7a8 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_1-manual.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>Removing iframe from document removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +setup({timeout:3600000}) +var t = async_test(undefined, {timeout:3600000}); +var w = window.open("discard_iframe_history_1-1.html"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-1.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-1.html new file mode 100644 index 000000000..bc01cae88 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-1.html @@ -0,0 +1,19 @@ +<script> +history_lengths = []; + +function push_length() { + history_lengths.push(history.length) +} + +do_test = opener.t.step_func(function () { + try { + var start_length = history_lengths[0]; + expected = [start_length, start_length + 1, start_length]; + opener.assert_array_equals(history_lengths, expected); + opener.t.done(); + } finally { + window.close(); + } +}); +</script> +<iframe src="discard_iframe_history_2-2.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-2.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-2.html new file mode 100644 index 000000000..b25bf5f00 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-2.html @@ -0,0 +1 @@ +<a href="discard_iframe_history_2-3.html" onclick="parent.push_length()">Click me</a> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-3.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-3.html new file mode 100644 index 000000000..68847e9a7 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-3.html @@ -0,0 +1 @@ +<button onclick="var p = parent; p.push_length(); frameElement.parentNode.removeChild(frameElement); p.push_length(); p.do_test();">Click me</button> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-manual.html new file mode 100644 index 000000000..27d395d22 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/non-automated/discard_iframe_history_2-manual.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>Removing iframe from document removes it from history</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +setup({timeout:3600000}) +var t = async_test(undefined, {timeout:3600000}); +var w = window.open("discard_iframe_history_2-1.html"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/named-objects.html b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/named-objects.html new file mode 100644 index 000000000..f020e0ecb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/named-objects.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: Named access on the Window object</title> +<link rel="author" title="Intel" href="http://www.intel.com/"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#named-access-on-the-window-object"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<div style="display:none"> + <p name="a" id="p1"></p> + <a name="a" id="a1" href="#"></a> + <applet name="a" id="app1"></applet> + <area name="a" id="area1"></area> + <embed name="a" id="embed1"></embed> + <form name="a" id="form1"></form> + <img name="a" id="img1"> + <object name="a" id="obj1"></object> + <span name="a" id="span1"></span> + + <b id="b" name="c"></b> + <a name="c"></a> + <iframe name="c" id="fm1"></iframe> + <iframe name="c" id="fm2" src="test.html" onload="on_load()"></iframe> + <input id="b"></input> + <span id="d"></span> + <a name=""></a> + <b id=""></b> +</div> +<script> + +test(function() { + assert_equals(window['c'], document.getElementById("fm1").contentWindow, "The first iframe's window should be returned."); +}, "Check if the first nested browsing context is returned by window['c']"); + +test(function() { + assert_equals(window['a'].length, 5, "The length should be 5."); + assert_true(window['a'] instanceof HTMLCollection); + assert_array_equals(window['a'], + [ document.getElementById('app1'), document.getElementById('embed1'), + document.getElementById('form1'), document.getElementById('img1'), + document.getElementById('obj1') ], + "The elements are not in tree order."); + + document.getElementById('form1').setAttribute("name", ""); + document.getElementById('embed1').setAttribute("name", ""); + assert_array_equals(window['a'], + [ document.getElementById('app1'), document.getElementById('img1'), + document.getElementById('obj1') ], + "Window['a'] should not contain the elements with empty name attribute."); +}, "Check if window['a'] contains all applet, embed, form, img, and object elements, and their order"); + +var t = async_test("Check that window['fs'] does not return the frameset element with name='fs' (historical)"); +function on_load () { + t.step(function () { + assert_equals(document.getElementById('fm2').contentWindow['fs'], + undefined, + "The frameset element should not be returned."); + }); + t.done(); +} + +test(function() { + assert_true(window['b'] instanceof HTMLCollection); + assert_array_equals(window['b'], [document.getElementsByTagName('b')[0], document.getElementsByTagName('input')[0]]); + + document.getElementsByTagName('b')[0].setAttribute("id", ""); + assert_equals(window['b'], document.getElementsByTagName('input')[0], + "The window['b'] should not contain the elements with empty id attribute."); +}, "Check if window['b'] returns the elements with the id='b'"); + +test(function() { + assert_equals(window['d'], document.getElementById('d')); +}, "Check if window['d'] returns the element with id='d'"); + +test(function() { + assert_equals(window[''], undefined, "The window[''] should be undefined"); +}, "Check widow[''] when there are some elements with empty id or name attribute"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/test.html b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/test.html new file mode 100644 index 000000000..c3b3cc185 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/test.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: Named Object</title> +<link rel="author" title="Intel" href="http://www.intel.com/"> +<frameset name="fs" id="fs1"> + <frame></frame> +</frameset> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/window-null-names.html b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/window-null-names.html new file mode 100644 index 000000000..760bd418d --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/named-access-on-the-window-object/window-null-names.html @@ -0,0 +1,20 @@ +<!doctype html> +<meta charset=utf-8> +<title>Named access with null characters</title> +<link rel="author" title="Ms2ger" href="ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-nameditem"> +<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var iframe = document.createElement("iframe") + iframe.name = "a\0b" + document.body.appendChild(iframe) + assert_equals(window["a\0b"], iframe.contentWindow) + assert_equals(window["ab"], undefined) + assert_equals(window["a"], undefined) +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/security-window/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/security-window/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/security-window/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/security-window/window-security.sub.html b/testing/web-platform/tests/html/browsers/the-window-object/security-window/window-security.sub.html new file mode 100644 index 000000000..9a9ef358e --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/security-window/window-security.sub.html @@ -0,0 +1,203 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTML Test: Window Security</title> +<link rel="author" title="Intel" href="http://www.intel.com/" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#the-window-object" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/timers.html#timers" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/webappapis.html#atob" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstorage" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorage" /> +<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#window" /> +<link rel="help" href="http://dev.w3.org/csswg/cssom/#extensions-to-the-window-interface" /> +<link rel="help" href="http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<div id="log"></div> +<script> +var t = async_test("Window Security testing"); + +function fr_load() { + fr = document.getElementById("fr"); + + t.step(function () { + //SecurityError should be thrown + [ + //attributes + {name: "applicationCache"}, + {name: "devicePixelRatio"}, + {name: "document"}, + {name: "external"}, + {name: "frameElement"}, + {name: "history"}, + {name: "innerWidth"}, + {name: "innerHeight"}, + {name: "locationbar"}, + {name: "localStorage"}, + {name: "menubar"}, + {name: "name"}, + {name: "navigator"}, + {name: "onabort"}, + {name: "onafterprint"}, + {name: "onbeforeprint"}, + {name: "onbeforeunload"}, + {name: "onblur"}, + {name: "oncancel"}, + {name: "oncanplay"}, + {name: "oncanplaythrough"}, + {name: "onchange"}, + {name: "onclick"}, + {name: "onclose"}, + {name: "oncontextmenu"}, + {name: "oncuechange"}, + {name: "ondblclick"}, + {name: "ondrag"}, + {name: "ondragend"}, + {name: "ondragenter"}, + {name: "ondragleave"}, + {name: "ondragover"}, + {name: "ondragstart"}, + {name: "ondrop"}, + {name: "ondurationchange"}, + {name: "onemptied"}, + {name: "onended"}, + {name: "onerror"}, + {name: "onfocus"}, + {name: "onhashchange"}, + {name: "oninput"}, + {name: "oninvalid"}, + {name: "onkeydown"}, + {name: "onkeypress"}, + {name: "onkeyup"}, + {name: "onload"}, + {name: "onloadeddata"}, + {name: "onloadedmetadata"}, + {name: "onloadstart"}, + {name: "onmessage"}, + {name: "onmousedown"}, + {name: "onmousemove"}, + {name: "onmouseout"}, + {name: "onmouseover"}, + {name: "onmouseup"}, + {name: "onmousewheel"}, + {name: "onoffline"}, + {name: "ononline"}, + {name: "onpause"}, + {name: "onplay"}, + {name: "onplaying"}, + {name: "onpagehide"}, + {name: "onpageshow"}, + {name: "onpopstate"}, + {name: "onprogress"}, + {name: "onratechange"}, + {name: "onreset"}, + {name: "onresize"}, + {name: "onscroll"}, + {name: "onseeked"}, + {name: "onseeking"}, + {name: "onselect"}, + {name: "onshow"}, + {name: "onstalled"}, + {name: "onstorage"}, + {name: "onsubmit"}, + {name: "onsuspend"}, + {name: "ontimeupdate"}, + {name: "onunload"}, + {name: "onvolumechange"}, + {name: "onwaiting"}, + {name: "pageXOffset"}, + {name: "pageYOffset"}, + {name: "personalbar"}, + {name: "screen"}, + {name: "scrollbars"}, + {name: "statusbar"}, + {name: "status"}, + {name: "screenX"}, + {name: "screenY"}, + {name: "sessionStorage"}, + {name: "toolbar"}, + //methods + {name: "alert", isMethod: true}, + {name: "clearInterval", isMethod: true, args:[1]}, + {name: "clearTimeout", isMethod: true, args:[function () {}, 1]}, + {name: "confirm", isMethod: true}, + {name: "getComputedStyle", isMethod: true, args:[document.body, null]}, + {name: "getSelection", isMethod: true}, + {name: "matchMedia", isMethod: true, args:["(min-width:50px)"]}, + {name: "moveBy", isMethod: true, args:[10, 10]}, + {name: "moveTo", isMethod: true, args:[10, 10]}, + {name: "open", isMethod: true}, + {name: "print", isMethod: true}, + {name: "prompt", isMethod: true}, + {name: "resizeTo", isMethod: true, args:[10, 10]}, + {name: "resizeBy", isMethod: true, args:[10, 10]}, + {name: "scroll", isMethod: true, args:[10, 10]}, + {name: "scrollTo", isMethod: true, args:[10, 10]}, + {name: "scrollBy", isMethod: true, args:[10, 10]}, + {name: "setInterval", isMethod: true, args:[function () {}, 1]}, + {name: "setTimeout", isMethod: true, args:[function () {}, 1]}, + {name: "showModalDialog", isMethod: true, args:["auto:blank", "dialog"]}, + {name: "stop", isMethod: true}, + ].forEach(function (item) { + test(function () { + assert_true(item.name in window, "window." + item.name + " should exist."); + assert_throws("SecurityError", function () { + if (item.isMethod) + if (item.args) + fr.contentWindow[item.name](item.args[0], item.args[1]); + else + fr.contentWindow[item.name](); + else + fr.contentWindow[item.name]; + }, "A SecurityError exception should be thrown."); + }, "A SecurityError exception must be thrown when window." + item.name + " is accessed from a different origin."); + }); + + //SecurityError should not be thrown + [ + //attributes + {name: "closed"}, + {name: "frames"}, + {name: "length"}, + {name: "location"}, + {name: "opener"}, + {name: "parent"}, + {name: "self"}, + {name: "top"}, + {name: "window"}, + //methods + {name: "blur", isMethod: true}, + {name: "close", isMethod: true}, + {name: "focus", isMethod: true}, + {name: "postMessage", isMethod: true, args: [{msg: 'foo'}, "*"]} + ].forEach(function (item) { + test(function () { + assert_true(item.name in window, "window." + item.name + " should exist."); + try { + if (item.isMethod) + if (item.args) + fr.contentWindow[item.name](item.args[0], item.args[1]); + else + fr.contentWindow[item.name](); + else + fr.contentWindow[item.name]; + } catch (e) { + assert_unreached("An unexpected exception was thrown."); + } + }, "A SecurityError exception should not be thrown when window." + item.name + " is accessed from a different origin."); + }); + }); + t.done(); +} + +</script> +<script> +onload = function() { + var frame = document.createElement('iframe'); + frame.id = "fr"; + frame.setAttribute("style", "display:none"); + frame.setAttribute('src', get_host_info().HTTP_REMOTE_ORIGIN + "/"); + frame.setAttribute("onload", "fr_load()"); + document.body.appendChild(frame); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/support/noopener-target.html b/testing/web-platform/tests/html/browsers/the-window-object/support/noopener-target.html new file mode 100644 index 000000000..d0d036026 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/support/noopener-target.html @@ -0,0 +1,8 @@ +<!DOCTYPE html> +<script> + var channelName = location.search.substr(1); + var channel = new BroadcastChannel(channelName); + channel.postMessage({ name: window.name, + haveOpener: window.opener !== null }); + window.close(); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/.gitkeep b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/.gitkeep diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-locationbar-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-locationbar-manual.html new file mode 100644 index 000000000..4331b3b66 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-locationbar-manual.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Window Proxy locationbar visible flag Test</title> + <link rel="author" title='JuneyoungOh' href="juneyoung85@gmail.com"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.locationbar Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the locationbar visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script> + test(function() { + assert_not_equals(typeof window.locationbar, undefined, 'window.locationbar is undefined'); + assert_true(window.locationbar.visible) + }, "window.locationbar.visible"); + </script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-menubar-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-menubar-manual.html new file mode 100644 index 000000000..43345934a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-menubar-manual.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Window Proxy menubar visible flag Test</title> + <link rel="author" title='JuneyoungOh' href="juneyoung85@gmail.com"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.menubar Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the menubar visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script> + test(function() { + assert_not_equals(typeof window.menubar, undefined, 'window.menubar is undefined'); + assert_true(window.menubar.visible); + }, "window.menubar.visible"); + </script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-personalbar-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-personalbar-manual.html new file mode 100644 index 000000000..d7f109840 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-personalbar-manual.html @@ -0,0 +1,29 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8" /> + <title>Window Proxy personalbar visible flag Test</title> + <link rel="author" title="vanessa" href="mailto:vanessaohsy@gmail.com"> + <script type="text/javascript" src="/resources/testharness.js"></script> + <script type="text/javascript" src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.personalbar Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the personalbar visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script type="text/javascript" > + test(function () { + assert_not_equals(window.personalbar, undefined, "window.personalbar is undefined"); + assert_true(window.personalbar.visible, "window.personalbar.visible"); + }); + </script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-scrollbars-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-scrollbars-manual.html new file mode 100644 index 000000000..c412bdbe5 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-scrollbars-manual.html @@ -0,0 +1,29 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8" /> + <title>Window Proxy scrollbars visible flag Test</title> + <link rel="author" title="vanessa" href="vanessaohsy@gmail.com"> + <script type="text/javascript" src="/resources/testharness.js"></script> + <script type="text/javascript" src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.scrollbars Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the scrollbars visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script type="text/javascript" > + test(function () { + assert_not_equals(window.scrollbars, undefined, "window.scrollbars is undefined"); + assert_true(window.scrollbars.visible, "window.scrollbars.visible"); + }); + </script> +</body> +</html> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-statusbar-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-statusbar-manual.html new file mode 100644 index 000000000..b09fcc017 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-statusbar-manual.html @@ -0,0 +1,29 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8" /> + <title>WindowProxy statusbar visible flag Test</title> + <link rel="author" title="dokenzy" href="dokenzy@gmail.com"> + <script type="text/javascript" src="/resources/testharness.js"></script> + <script type="text/javascript" src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.statusbar Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the statusbar visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script type="text/javascript" > + test(function () { + assert_not_equals(typeof window.statusbar.visible, undefined, 'window.statusbar.visible'); + assert_true(window.statusbar.visible, 'window.statusbar.visible'); + }, "BarProp attribute: window.statusbar.visible"); + </script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-toolbar-manual.html b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-toolbar-manual.html new file mode 100644 index 000000000..ba4654431 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/the-windowproxy-object/test-window-proxy-toolbar-manual.html @@ -0,0 +1,29 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8" /> + <title>WindowProxy toolbar visible flag Test</title> + <link rel="author" title="dokenzy" href="dokenzy@gmail.com"> + <script type="text/javascript" src="/resources/testharness.js"></script> + <script type="text/javascript" src="/resources/testharnessreport.js"></script> +</head> +<body> + <h1>Description</h1> + <p>WindowProxy.toolbar Test</p> + + <h1>Manual Test Steps:</h1> + <ol> + <li>Make the toolbar visible in the user agent before executing this test.</li> + <li>You may need to manually reload afterwards.</li> + </ol> + + <div id="log"></div> + + <script type="text/javascript" > + test(function () { + assert_not_equals(typeof window.toolbar.visible, undefined, 'window.toolbar.visible'); + assert_true(window.toolbar.visible, 'window.toolbar.visible'); + }, "BarProp attribute: window.toolbar.visible"); + </script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-aliases.html b/testing/web-platform/tests/html/browsers/the-window-object/window-aliases.html new file mode 100644 index 000000000..135be02a3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-aliases.html @@ -0,0 +1,28 @@ +<!doctype html> +<meta charset=utf-8> +<title>Aliases of the window object</title> +<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-frames"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-self"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var global = this; + +test(function() { + assert_equals(window, global); + assert_equals(window.window, global); +}, "window should be the global object"); + +test(function() { + assert_equals(frames, global); + assert_equals(window.frames, global); +}, "frames should be the global object"); + +test(function() { + assert_equals(self, global); + assert_equals(window.self, global); +}, "self should be the global object"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties-strict.html b/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties-strict.html new file mode 100644 index 000000000..610941fc8 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties-strict.html @@ -0,0 +1,43 @@ +<!doctype html> +<meta charset=utf-8> +<title>Indexed properties of the window object (strict mode)</title> +<link rel="author" title="Ms2ger" href="ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-item"> +<link rel="help" href="https://heycam.github.io/webidl/#getownproperty"> +<link rel="help" href="https://heycam.github.io/webidl/#defineownproperty"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe></iframe> +<script> +test(function() { + "use strict"; + assert_false("-1" in window, "-1 not in window"); + assert_equals(window[-1], undefined); + window[-1] = "foo"; + assert_equals(window[-1], "foo"); +}); +test(function() { + "use strict"; + assert_throws(new TypeError(), function() { + window[0] = "foo"; + }); + assert_equals(window[0], + document.getElementsByTagName("iframe")[0].contentWindow); +}); +test(function() { + "use strict"; + assert_throws(new TypeError(), function() { + window[1] = "foo"; + }); + assert_equals(window[1], undefined); +}); +test(function() { + "use strict"; + var proto = Window.prototype; + [-1, 0, 1].forEach(function(idx) { + assert_false(idx in proto, idx + " in proto"); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties.html b/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties.html new file mode 100644 index 000000000..9577ab8fb --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-indexed-properties.html @@ -0,0 +1,35 @@ +<!doctype html> +<meta charset=utf-8> +<title>Indexed properties of the window object (non-strict mode)</title> +<link rel="author" title="Ms2ger" href="ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-item"> +<link rel="help" href="https://heycam.github.io/webidl/#getownproperty"> +<link rel="help" href="https://heycam.github.io/webidl/#defineownproperty"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe></iframe> +<script> +test(function() { + assert_false("-1" in window, "-1 not in window"); + assert_equals(window[-1], undefined); + window[-1] = "foo"; + assert_equals(window[-1], "foo"); +}); +test(function() { + window[0] = "foo"; + assert_equals(window[0], + document.getElementsByTagName("iframe")[0].contentWindow); +}); +test(function() { + window[1] = "foo"; + assert_equals(window[1], undefined); +}); +test(function() { + var proto = Window.prototype; + [-1, 0, 1].forEach(function(idx) { + assert_false(idx in proto, idx + " in proto"); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-named-properties.html b/testing/web-platform/tests/html/browsers/the-window-object/window-named-properties.html new file mode 100644 index 000000000..54f37bbdc --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-named-properties.html @@ -0,0 +1,77 @@ +<!doctype html> +<meta charset=utf-8> +<title>Changes to named properties of the window object</title> +<link rel="author" title="Ms2ger" href="ms2ger@gmail.com"> +<link rel="author" title="Boris Zbarsky" href="bzbarsky@mit.edu"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-nameditem"> +<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe name="bar"></iframe> +<iframe name="baz"></iframe> +<iframe name="baz"></iframe> +<iframe name="constructor"></iframe> +<script> +function assert_data_propdesc(pd, Writable, Enumerable, Configurable) { + assert_equals(typeof pd, "object"); + assert_equals(pd.writable, Writable); + assert_equals(pd.enumerable, Enumerable); + assert_equals(pd.configurable, Configurable); +} +test(function() { + assert_true("bar" in window, "bar not in window"); + assert_equals(window["bar"], + document.getElementsByTagName("iframe")[0].contentWindow); +}, "Static name"); +test(function() { + assert_true("bar" in Window.prototype, "bar in Window.prototype"); + assert_false(Window.prototype.hasOwnProperty("bar"), "Window.prototype.hasOwnProperty(\"bar\")"); + + var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window)); + assert_true("bar" in gsp, "bar in gsp"); + assert_true(gsp.hasOwnProperty("bar"), "gsp.hasOwnProperty(\"bar\")"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "bar"), + true, false, true); +}, "Static name on the prototype"); +test(function() { + assert_equals(window.constructor, Window); + assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property."); + + var proto = Object.getPrototypeOf(window); + assert_equals(proto.constructor, Window); + assert_true("constructor" in proto, "constructor in proto"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(proto, "constructor"), + true, false, true); + + var gsp = Object.getPrototypeOf(proto); + assert_true("constructor" in gsp, "constructor in gsp"); + assert_false(gsp.hasOwnProperty("constructor"), "gsp.hasOwnProperty(\"constructor\")"); + assert_equals(Object.getOwnPropertyDescriptor(gsp, "constructor"), undefined); +}, "constructor"); +test(function() { + var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window)); + var names = Object.getOwnPropertyNames(gsp); + assert_equals(names.filter((name) => name == "baz").length, 1); + +}, "duplicate property names") +var t = async_test("Dynamic name") +var t2 = async_test("Ghost name") +t.step(function() { + var iframe = document.getElementsByTagName("iframe")[0]; + iframe.setAttribute("src", "data:text/html,<script>window.name='foo'<\/script>"); + iframe.onload = function() { + t.step(function() { + assert_true("foo" in window, "foo not in window"); + assert_equals(window["foo"], iframe.contentWindow); + }); + t.done(); + t2.step(function() { + assert_false("bar" in window, "bar still in window"); + assert_equals(window["bar"], undefined); + }); + t2.done(); + }; +}); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-open-noopener.html b/testing/web-platform/tests/html/browsers/the-window-object/window-open-noopener.html new file mode 100644 index 000000000..808f55e23 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-open-noopener.html @@ -0,0 +1,105 @@ +<!doctype html> +<meta charset=utf-8> +<title>window.open() with "noopener" tests</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +var testData = [ + { testDescription: "window.open() with 'noopener' should not reuse existing target", + secondWindowFeatureString: "noopener", + shouldReuse: false }, + { testDescription: "noopener needs to be present as a token on its own", + secondWindowFeatureString: "noopener=1", + shouldReuse: true }, + { testDescription: "noopener needs to be present as a token on its own again", + secondWindowFeatureString: "noopener=0", + shouldReuse: true }, + { testDescription: "noopener needs to be present as a token on its own yet again", + secondWindowFeatureString: "make me noopener", + shouldReuse: true }, + { testDescription: "Trailing noopener should work", + secondWindowFeatureString: "abc def, \n\r noopener", + shouldReuse: false }, + { testDescription: "Leading noopener should work", + secondWindowFeatureString: "noopener \f\t , hey, there", + shouldReuse: false }, + { testDescription: "Interior noopener should work", + secondWindowFeatureString: "and now, noopener , hey, there", + shouldReuse: false }, +]; + +var tests = []; +/** + * Loop over our testData array and kick off an async test for each entry. Each + * async test opens a window using window.open() with some per-test unique name, + * then tries to do a second window.open() call with the same name and the + * test-specific feature string. It then checks whether that second + * window.open() call reuses the existing window, whether the return value of + * the second window.open() call is correct (it should be null in the noopener + * cases and non-null in the cases when the existing window gets reused) and so + * forth. + */ +for (var i = 0; i < testData.length; ++i) { + var test = testData[i]; + var t = async_test(test.testDescription); + tests.push(t); + t.secondWindowFeatureString = test.secondWindowFeatureString; + t.windowName = "someuniquename" + i; + + if (test.shouldReuse) { + t.step(function() { + var windowName = this.windowName; + + var w1 = window.open("", windowName); + this.add_cleanup(function() { w1.close(); }); + + assert_equals(w1.opener, window); + + var w2 = window.open("", windowName, this.secondWindowFeatureString); + assert_equals(w2, w1); + assert_equals(w2.opener, w1.opener); + assert_equals(w2.opener, window); + this.done(); + }); + } else { + t.step(function() { + var w1; + this.add_cleanup(function() { w1.close(); }); + + var windowName = this.windowName; + var channel = new BroadcastChannel(windowName); + + channel.onmessage = this.step_func_done(function(e) { + var data = e.data; + assert_equals(data.name, windowName, "Should have the right name"); + assert_equals(data.haveOpener, false, "Should not have opener"); + assert_equals(w1.opener, window); + assert_equals(w1.location.href, "about:blank"); + }); + + w1 = window.open("", windowName); + assert_equals(w1.opener, window); + + var w2 = window.open("support/noopener-target.html?" + windowName, + windowName, this.secondWindowFeatureString); + assert_equals(w2, null); + + assert_equals(w1.opener, window); + }); + } +} + +/** + * Loop over the special targets that ignore noopener and check that doing a + * window.open() with those targets correctly reuses the existing window. + */ +for (var target of ["_self", "_parent", "_top"]) { + var t = async_test("noopener window.open targeting " + target); + tests.push(t); + t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}", "noopener"); this.checkValues(w2); this.close(); void(0);`); + assert_equals(t.openedWindow.opener, window); + t.openedWindow.checkValues = t.step_func_done(function(win) { + assert_equals(win, this.openedWindow); + }); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-properties.html b/testing/web-platform/tests/html/browsers/the-window-object/window-properties.html new file mode 100644 index 000000000..3316bf531 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-properties.html @@ -0,0 +1,322 @@ +<!doctype html> +<meta charset=utf-8> +<title>Properties of the window object</title> +<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com"> +<link rel="help" href="http://ecma-international.org/ecma-262/5.1/#sec-15.1"> +<link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object"> +<link rel="help" href="https://heycam.github.io/webidl/#es-attributes"> +<link rel="help" href="https://heycam.github.io/webidl/#es-operations"> +<link rel="help" href="https://dom.spec.whatwg.org/#eventtarget"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowtimers"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowbase64"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstorage"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorage"> +<link rel="help" href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-window-getselection"> +<link rel="help" href="http://dev.w3.org/csswg/cssom/#widl-def-Window"> +<link rel="help" href="http://dev.w3.org/csswg/cssom-view/#widl-def-Window"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +function assert_data_propdesc(pd, Writable, Enumerable, Configurable) { + assert_equals(typeof pd, "object"); + assert_equals(pd.writable, Writable); + assert_equals(pd.enumerable, Enumerable); + assert_equals(pd.configurable, Configurable); +} +function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) { + assert_equals(typeof pd, "object"); + assert_equals(typeof pd.get, "function"); + assert_true("set" in pd, + "Should always have a setter property on the property descriptor"); + assert_equals(typeof pd.set, hasSetter ? "function" : "undefined"); + assert_equals(pd.enumerable, Enumerable); + assert_equals(pd.configurable, Configurable); +} + +var unforgeableAttributes = [ + "window", + "document", + "location", + "top" +]; + +var replaceableAttributes = [ + "self", + "locationbar", + "menubar", + "personalbar", + "scrollbars", + "statusbar", + "toolbar", + "frames", + "parent", + "external", + "length", + + // CSSOM-View + "screen", + "scrollX", + "scrollY", + "pageXOffset", + "pageYOffset", + "innerWidth", + "innerHeight", + "screenX", + "screenY", + "outerWidth", + "outerHeight", + "devicePixelRatio", +]; + +var methods = [ + "close", + "stop", + "focus", + "blur", + "open", + "alert", + "confirm", + "prompt", + "print", + // See below: "showModalDialog", + "postMessage", + + // WindowBase64 + "btoa", + "atob", + + // WindowTimers + "setTimeout", + "clearTimeout", + "setInterval", + "clearInterval", + + // HTML Editing APIs + "getSelection", + + // CSSOM + "getComputedStyle", + + // CSSOM-View + "matchMedia", + "scroll", + "scrollTo", + "scrollBy" +]; + +// We would like to remove showModalDialog from the platform, +// see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=26437>. +if ("showModalDialog" in window) { + methods.push("showModalDialog"); +} + +var readonlyAttributes = [ + "history", + "frameElement", + "navigator", + "applicationCache", + + // WindowSessionStorage + "sessionStorage", + + // WindowLocalStorage + "localStorage", +]; + +var writableAttributes = [ + "name", + "status", + "opener", + "onabort", + "onafterprint", + "onbeforeprint", + "onbeforeunload", + "onblur", + "oncancel", + "oncanplay", + "oncanplaythrough", + "onchange", + "onclick", + "onclose", + "oncontextmenu", + "oncuechange", + "ondblclick", + "ondrag", + "ondragend", + "ondragenter", + "ondragleave", + "ondragover", + "ondragstart", + "ondrop", + "ondurationchange", + "onemptied", + "onended", + "onerror", + "onfocus", + "onhashchange", + "oninput", + "oninvalid", + "onkeydown", + "onkeypress", + "onkeyup", + "onload", + "onloadeddata", + "onloadedmetadata", + "onloadstart", + "onmessage", + "onmousedown", + "onmousemove", + "onmouseout", + "onmouseover", + "onmouseup", + "onmousewheel", + "onoffline", + "ononline", + "onpause", + "onplay", + "onplaying", + "onpagehide", + "onpageshow", + "onpopstate", + "onprogress", + "onratechange", + "onreset", + "onresize", + "onscroll", + "onseeked", + "onseeking", + "onselect", + "onshow", + "onstalled", + "onstorage", + "onsubmit", + "onsuspend", + "ontimeupdate", + "onunload", + "onvolumechange", + "onwaiting" +]; + +test(function() { + // 15.1.1 Value Properties of the Global Object + ["NaN", "Infinity", "undefined"].forEach(function(id) { + test(function() { + assert_true(id in window, id + " in window"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + false, false, false); + }, "Value Property: " + id); + }); +}, "Value Properties of the Global Object"); +test(function() { + // 15.1.2 Function Properties of the Global Object + ["eval", "parseInt", "parseFloat", "isNaN", "isFinite"].forEach(function(id) { + test(function() { + assert_true(id in window, id + " in window"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, false, true); + }, "Function Property: " + id); + }); +}, "Function Properties of the Global Object"); +test(function() { + // 15.1.3 URI Handling Function Properties + ["decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent"].forEach(function(id) { + test(function() { + assert_true(id in window, id + " in window"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, false, true); + }, "URI Handling Function Property: " + id); + }); +}, "URI Handling Function Properties"); +test(function() { + // 15.1.4 Constructor Properties of the Global Object + ["Object", "Function", "Array", "String", "Boolean", "Number", "Date", + "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", + "SyntaxError", "TypeError", "URIError"].forEach(function(id) { + test(function() { + assert_true(id in window, id + " in window"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, false, true); + }, "Constructor Property: " + id); + }); +}, "Constructor Properties of the Global Object"); +test(function() { + // 15.1.5 Other Properties of the Global Object + ["Math", "JSON"].forEach(function(id) { + test(function() { + assert_true(id in window, id + " in window"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, false, true); + }, "Other Property: " + id); + }); +}, "Other Properties of the Global Object"); +test(function() { + // EventTarget interface + ["addEventListener", "removeEventListener", "dispatchEvent"].forEach(function(id) { + test(function() { + var EventTargetProto = EventTarget.prototype; + assert_true(id in window, id + " in window"); + assert_equals(window[id], EventTargetProto[id]); + assert_data_propdesc(Object.getOwnPropertyDescriptor(EventTargetProto, id), + true, true, true); + assert_equals(Object.getOwnPropertyDescriptor(window, id), undefined); + }, "EventTarget method: " + id); + }); +}, "EventTarget interface"); +test(function() { + // Window interface + methods.forEach(function(id) { + test(function() { + var WindowProto = Window.prototype; + assert_true(id in window, id + " in window"); + assert_false(id in WindowProto, id + " in Window.prototype"); + assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, true, true); + }, "Window method: " + id); + }); + readonlyAttributes.forEach(function(id) { + test(function() { + var WindowProto = Window.prototype; + assert_true(id in window, id + " in window"); + assert_false(id in WindowProto, id + " in Window.prototype"); + assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id), + false, true, true); + }, "Window readonly attribute: " + id); + }); + writableAttributes.forEach(function(id) { + test(function() { + var WindowProto = Window.prototype; + assert_true(id in window, id + " in window"); + assert_false(id in WindowProto, id + " in Window.prototype"); + assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, true, true); + }, "Window attribute: " + id); + }); + unforgeableAttributes.forEach(function(id) { + test(function() { + var WindowProto = Window.prototype; + assert_true(id in window, id + " in window"); + assert_false(id in WindowProto, id + " in Window.prototype"); + // location has a [PutForwards] extended attribute. + assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id), + id === "location", true, false); + }, "Window unforgeable attribute: " + id); + }); + replaceableAttributes.forEach(function(id) { + test(function() { + var WindowProto = Window.prototype; + assert_true(id in window, id + " in window"); + assert_false(id in WindowProto, id + " in Window.prototype"); + assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id), + true, true, true); + }, "Window replaceable attribute: " + id); + }); +}, "Window interface"); +test(function() { + assert_equals(window.constructor, Window); + assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property."); + assert_data_propdesc(Object.getOwnPropertyDescriptor(Window.prototype, "constructor"), + true, false, true); +}, "constructor"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-window-object/window-prototype-chain.html b/testing/web-platform/tests/html/browsers/the-window-object/window-prototype-chain.html new file mode 100644 index 000000000..d29a8e11f --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-window-object/window-prototype-chain.html @@ -0,0 +1,35 @@ +<!doctype html> +<meta charset=utf-8> +<title>Prototype chain of the window object</title> +<link rel="author" title="Ms2ger" href="ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#window"> +<link rel="help" href="https://dom.spec.whatwg.org/#eventtarget"> +<link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object"> +<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + assert_class_string(window, "Window"); +}, "window object"); +test(function() { + var proto = Object.getPrototypeOf(window); + assert_class_string(proto, "WindowPrototype"); + assert_equals(proto, Window.prototype); +}, "Window.prototype"); +test(function() { + var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window)); + assert_class_string(gsp, "WindowProperties"); +}, "Global scope polluter"); +test(function() { + var protoproto = Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(window))); + assert_class_string(protoproto, "EventTargetPrototype"); + assert_equals(protoproto, EventTarget.prototype); +}, "EventTarget.prototype"); +test(function() { + var protoprotoproto = Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(window)))); + assert_class_string(protoprotoproto, "Object"); + assert_equals(protoprotoproto, Object.prototype); +}, "Object.prototype"); +</script> |