Truly independent web browser
Tests/LibWeb: Import WPT tests for the target of events fired at windows
Andreas Kling1654d4e1c5e6
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 1e7478344d2..1658cef4ea3 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -147,6 +147,10 @@ Text/input/wpt-import/html/browsers/history/the-history-interface/history_pushstText/input/wpt-import/html/browsers/history/the-history-interface/history_replacestate_too_many_calls.optional.htmlText/input/wpt-import/html/browsers/history/the-history-interface/history_replacestate_too_many_calls_ordering.optional.html+; Navigates by root-relative URLs, which need an HTTP origin.+Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.html+Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.html+; Calls reload() on a child window's Location, which requires a shared tuple origin.Text/input/wpt-import/html/browsers/history/the-location-interface/reload_document_write.htmldiff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txtnew file mode 100644index 00000000000..e868d66c1f8--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Queue a task to fire hashchange event\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txtnew file mode 100644index 00000000000..e1984a45db3--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Queue a task to fire popstate event\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txtnew file mode 100644index 00000000000..96065c76d3a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Fragment Navigation: hashchange event\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.html b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.htmlnew file mode 100644index 00000000000..b89e62b96ae--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.html@@ -0,0 +1,49 @@+<!doctype html>+<title>Queue a task to fire hashchange event</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<div id="log"></div>+<script>+t = async_test();+window.onload = t.step_func(function () {+ if (location.href.toString().indexOf("#") > -1) {+ location.href = location.href.replace(/#.*$/,'');+ return;+ }+ var root = location.href;+ var oldURLs = [];+ var newURLs = [];++ var timer = null;++ location.hash = 'foo';+ window.onhashchange = t.step_func(function (e) {+ assert_true(e.isTrusted, "isTrusted");+ assert_equals(e.target, window, "target");+ assert_equals(e.type, "hashchange", "type");+ assert_true(e instanceof HashChangeEvent, "is HashChangeEvent");+ assert_false(e.bubbles, "bubbles");+ assert_false(e.cancelable, "cancelable");+ oldURLs.push(e.oldURL);+ newURLs.push(e.newURL);+ if (newURLs.length === 2) {+ check_result();+ } else if (timer === null) {+ timer = setTimeout(function() {check_result()}, 500);+ }+ })++ check_result = t.step_func(function() {+ clearTimeout(timer);+ try {+ assert_array_equals([root, root+"#foo"], oldURLs, "e.oldURL");+ assert_array_equals([root+"#foo", root+"#bar"], newURLs, "e.newURL");+ t.done();+ } finally {+ location.hash = "";+ }+ });++ location.hash = 'bar';+});+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.html b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.htmlnew file mode 100644index 00000000000..2389e48bd5a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.html@@ -0,0 +1,48 @@+<!doctype html>+<title>Queue a task to fire popstate event</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<div id="log"></div>+<script>+t = async_test();+window.onload = t.step_func(function () {+ var states = [];++ var timer = null;++ history.pushState("a", "State a", "/a");+ history.pushState("b", "State b", "/b");++ history.back();+ window.onpopstate = t.step_func(function (e) {+ assert_true(e.isTrusted, "isTrusted");+ assert_equals(e.target, window, "target");+ assert_equals(e.type, "popstate", "type");+ assert_true(e instanceof PopStateEvent, "is PopStateEvent");+ assert_false(e.bubbles, "bubbles");+ assert_false(e.cancelable, "cancelable");+ assert_not_equals(e.hasUAVisualTransition, undefined);++ states.push(e.state);++ if (states.length === 2) {+ check_result();+ } else if (timer === null) {+ timer = setTimeout(function() {check_result()}, 500);+ }+ })++ check_result = t.step_func(function() {+ clearTimeout(timer);+ try {+ assert_array_equals(states, ["a", null]);+ t.done();+ } finally {+ location.hash = "";+ }+ });++ setTimeout(function() {history.back()}, 0);++});+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.html b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.htmlnew file mode 100644index 00000000000..37eb20d11c8--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.html@@ -0,0 +1,23 @@+<!doctype html>+<!-- this tests the spec as it hopefully will be once bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=17155 is fixed -->+<title>Fragment Navigation: hashchange event</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<body>+<div id="log"></div>+<script>+var t = async_test();+t.step(function() {+ assert_equals(location.hash, "", "Page must be loaded with no hash");+ location.hash = "test";++ addEventListener("hashchange",+ t.step_func(function(e) {+ assert_equals(e.target, window);+ assert_equals(e.type, "hashchange");+ assert_false(e.bubbles, "bubbles");+ assert_false(e.cancelable, "cancelable");+ t.done();+ }), true)+});+</script>