summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep0
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html11
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html5
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html30
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST16
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html31
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html35
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html4
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html13
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html41
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html47
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html47
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json6
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html151
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html43
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html8
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html145
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html34
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html67
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html54
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html71
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html81
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html40
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html7
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html7
31 files changed, 1047 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/.gitkeep
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html
new file mode 100644
index 000000000..cadcf126f
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-1.html
@@ -0,0 +1,11 @@
+<!doctype html>
+001-1
+<script>
+addEventListener("pageshow",
+ function(e) {
+ parent.events.push(e);
+ if (parent.events.length == 2) {
+ parent.do_test();
+ }
+ }, false);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html
new file mode 100644
index 000000000..6387bc89c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001-2.html
@@ -0,0 +1,5 @@
+<!doctype html>
+001-2
+<script>
+onload = function() {setTimeout(function() {history.go(-1)}, 500)}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html
new file mode 100644
index 000000000..26a66304a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/001.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<title>pageshow event from traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<iframe src="001-1.html"></iframe>
+<script>
+var t = async_test();
+var events = [];
+var iframe = document.getElementsByTagName("iframe")[0];
+
+onload = t.step_func(function() {
+ setTimeout(t.step_func(
+ function() {
+ assert_equals(iframe.contentDocument.readyState, "complete")
+ iframe.src = "001-2.html";
+ }), 500);
+ onload = null;
+})
+
+do_test = t.step_func(function() {
+ assert_equals(events.length, 2);
+ events.forEach(function(e, i) {
+ phase = i ? "after" : "before";
+ assert_equals(e.type, "pageshow", "type " + phase + " navigation");
+ assert_equals(e.persisted, i == 0 ? false : true, "persisted " + phase + " navigation");
+ t.done();
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST
new file mode 100644
index 000000000..b3b6014f6
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/MANIFEST
@@ -0,0 +1,16 @@
+support 001-1.html
+support 001-2.html
+001.html
+support browsing_context_name-1.html
+support browsing_context_name-2.html
+support browsing_context_name-3.html
+support browsing_context_name-4.html
+browsing_context_name_cross_origin_2.html
+browsing_context_name_cross_origin_3.html
+browsing_context_name_cross_origin.html
+browsing_context_name.html
+events.html
+hashchange_event.html
+popstate_event.html
+support unset_context_name-1.html
+unset_context_name.html
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html
new file mode 100644
index 000000000..ace09e574
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Synthetic popstate events</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function () {
+ var e = document.createEvent('PopStateEvent');
+ var eProto = Object.getPrototypeOf(e);
+ assert_equals(eProto, PopStateEvent.prototype);
+}, 'document.createEvent');
+
+test(function () {
+ assert_false('initPopStateEvent' in PopStateEvent.prototype,
+ 'There should be no PopStateEvent#initPopStateEvent');
+}, 'initPopStateEvent');
+
+test(function () {
+ var state = history.state;
+ var data;
+ window.addEventListener('popstate', function (e) {
+ data = e.state;
+ });
+ window.dispatchEvent(new PopStateEvent('popstate', {
+ 'state': {testdata:true}
+ }));
+ assert_true(data.testdata,'state data was corrupted');
+ assert_equals(history.state, state, "history.state was NOT set by dispatching the event");
+}, 'Dispatching a synthetic PopStateEvent');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html
new file mode 100644
index 000000000..5cbab71a5
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-0.html
@@ -0,0 +1,35 @@
+<iframe id="test"></iframe>
+<script>
+var opener = window.opener;
+var t = opener.t;
+var f = document.getElementById("test");
+var l = opener.document.getElementById("step_log");
+
+log = function(t) {l.textContent += ("\n" + t)}
+var navigated = false;
+var steps = [
+ () => f.src = "browsing_context_name-1.html",
+ () => {
+ navigated = true;
+ opener.assert_equals(f.contentWindow.name, "test", "Initial load");
+ f.src = "browsing_context_name-2.html"
+ },
+ () => {
+ opener.assert_equals(f.contentWindow.name, "test1");
+ opener.assert_equals(history.length, 2);
+ history.back()
+ },
+ () => {
+ opener.assert_equals(f.contentWindow.name, "test1", "After navigation");
+ t.done();
+ }
+].map((x, i) => t.step_func(() => {log("Step " + (i+1)); x()}));
+
+next = () => steps.shift()();
+
+onload = () => {
+ log("page load");
+ f.onload = () => {log("iframe onload"); next()};
+ setTimeout(next, 0);
+};
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html
new file mode 100644
index 000000000..85748a2eb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-1.html
@@ -0,0 +1,6 @@
+document 1
+<script>
+if (!parent.navigated) {
+ window.name = "test";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html
new file mode 100644
index 000000000..b0c869046
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-2.html
@@ -0,0 +1,4 @@
+document 2
+<script>
+window.name = "test1";
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html
new file mode 100644
index 000000000..e0c239744
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-3.html
@@ -0,0 +1,6 @@
+document 3
+<script>
+if (!parent.navigated) {
+ window.name = "test3";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html
new file mode 100644
index 000000000..5d2dfa6bb
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name-4.html
@@ -0,0 +1,6 @@
+document 4
+<script>
+if (!parent.navigated) {
+ window.name = "test4";
+}
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html
new file mode 100644
index 000000000..60a8acb09
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>Retaining window.name on history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<pre id="step_log"></pre>
+
+<script>
+var t = async_test();
+t.step(() => {
+ win = window.open("browsing_context_name-0.html");
+ t.add_cleanup(() => win.close());
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html
new file mode 100644
index 000000000..b04eee66e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
+ function() {
+ setTimeout(next, 0);
+ },
+ function() {history.back(); setTimeout(next, 500)},
+ function() {
+ assert_equals(f.contentWindow.name, "test", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html
new file mode 100644
index 000000000..1a57e838c
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_2.html
@@ -0,0 +1,47 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = "browsing_context_name-3.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test3", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-3", "browsing_context_name-2");},
+ function() {
+ setTimeout(next, 0);
+ },
+ function() {history.go(-2); setTimeout(next, 500)},
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html
new file mode 100644
index 000000000..0f0702732
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/browsing_context_name_cross_origin_3.html
@@ -0,0 +1,47 @@
+<!doctype html>
+<title>Restoring window.name on cross-origin history traversal</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<pre id="step_log"></pre>
+<iframe id="test"></iframe>
+<script>
+var t = async_test(undefined, {timeout:10000});
+var f = document.getElementById("test");
+var l = document.getElementById("step_log");
+var navigated = false;
+
+log = function(t) {l.textContent += ("\n" + t)}
+
+var steps = [
+ function() {f.src = "browsing_context_name-1.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = "browsing_context_name-3.html"},
+ function() {
+ var navigated = true;
+ assert_equals(f.contentWindow.name, "test3", "Initial load");
+ setTimeout(next, 0);
+ },
+ function() {f.src = f.src.replace("http://", "http://www.").replace("browsing_context_name-1", "browsing_context_name-2");},
+ function() {f.src = f.src.replace("http://www.", "http://").replace("browsing_context_name-2", "browsing_context_name-4");},
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ history.go(-3); setTimeout(next, 500)
+ },
+ function() {
+ assert_equals(f.contentWindow.name, "test3", "After navigation");
+ t.done();
+ }
+].map(function(x) {return t.step_func(function() {log("Step " + step + " " + f.contentWindow.location); x()})});
+
+var step = 0;
+next = t.step_func(function() {steps[step++]()});
+
+f.onload=next;
+
+onload = setTimeout(next, 0);
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json
new file mode 100644
index 000000000..90b346668
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/contains.json
@@ -0,0 +1,6 @@
+[
+ {
+ "id": "event-definitions-0",
+ "original_id": "event-definitions-0"
+ }
+] \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html
new file mode 100644
index 000000000..d5ff83fac
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/events.html
@@ -0,0 +1,151 @@
+<!doctype html>
+<title> PageTransitionEffect Event </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:false, cancelable:false, bubbles:false});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+ assert_false(e.persisted, "persisted");
+}, "Constructing pageshow event");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:false, cancelable:false, bubbles:false});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_true(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_true(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted true");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, empty options");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, empty options");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow");
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, missing options");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide");
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, missing options");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:null});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted:null");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:null});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted:null");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {persisted:undefined});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, persisted:undefined");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {persisted:undefined});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, persisted:undefined");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {bubbles:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_true(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pageshow event, bubbles:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {bubbles:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_true(e.bubbles, "bubbles");
+ assert_false(e.cancelable, "cancelable");
+}, "Constructing pagehide event, bubbles:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pageshow", {cancelable:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pageshow");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "cancelable");
+}, "Constructing pageshow event, cancelable:true");
+
+test(function() {
+ var e = new PageTransitionEvent("pagehide", {cancelable:true});
+ assert_true(e instanceof PageTransitionEvent);
+ assert_equals(e.type, "pagehide");
+ assert_false(e.persisted, "persisted");
+ assert_false(e.bubbles, "bubbles");
+ assert_true(e.cancelable, "cancelable");
+}, "Constructing pagehide event, cancelable:true");
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html
new file mode 100644
index 000000000..4b701ad04
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/hashchange_event.html
@@ -0,0 +1,43 @@
+<!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) {
+ 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.newURL");
+ assert_array_equals([root+"#foo", root+"#bar"], newURLs, "e.newURL");
+ t.done();
+ } finally {
+ location.hash = "";
+ }
+ });
+
+ location.hash = 'bar';
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html
new file mode 100644
index 000000000..6b4df1ef2
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+<body> Blank 1 </body> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html
new file mode 100644
index 000000000..def213966
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank2.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+<body> Blank 2 </body>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html
new file mode 100644
index 000000000..11737661d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/page-with-fragment.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+#fragment {
+ position: absolute;
+ top: 800px;
+ background-color: #faa;
+ display: block;
+ height: 100px;
+ width: 100px;
+}
+
+</style>
+<body>
+Page with fragment
+ <a id="fragment" name="fragment" class='box'></a>
+</body> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html
new file mode 100644
index 000000000..1e9b10d1e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/post_name_on_load.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script>
+addEventListener('load', _ => {
+ let params = new URLSearchParams(window.location.search);
+ window.opener.postMessage(params.get('name'), '*');
+});
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html
new file mode 100644
index 000000000..fb7365bd3
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resume-timer-on-history-back.html
@@ -0,0 +1,145 @@
+<!doctype html>
+<title>Verify history.back() on a persisted page resumes timers</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+
+function make_post_back_url(name) {
+ return new URL('resources/post_name_on_load.html?name=' + name,
+ window.location).href;
+}
+
+function wait_for_message(name) {
+ return new Promise(resolve => {
+ addEventListener('message', function onMsg(evt) {
+ if (evt.data !== name) {
+ return;
+ }
+ removeEventListener('message', onMsg);
+ resolve();
+ });
+ });
+}
+
+function with_window_by_name(name) {
+ let win = window.open(make_post_back_url(name));
+ return wait_for_message(name).then(_ => {
+ return win;
+ });
+}
+
+function with_nested_frame(win, url) {
+ return new Promise(resolve => {
+ let frame = win.document.createElement('iframe');
+ frame.addEventListener('load', function onLoad(evt) {
+ removeEventListener('load', onLoad);
+ resolve(frame);
+ });
+ frame.src = url;
+ win.document.body.appendChild(frame);
+ });
+}
+
+function delay(win, delay) {
+ return new Promise(resolve => {
+ win.setTimeout(_ => {
+ resolve(win);
+ }, delay);
+ });
+}
+
+function navigate_by_name(win, name) {
+ win.location = make_post_back_url(name);
+ return wait_for_message(name).then(_ => {
+ return win;
+ });
+}
+
+function go_back(win) {
+ return new Promise(resolve => {
+ win.onpagehide = e => resolve(win);
+ win.history.back();
+ });
+}
+
+let DELAY = 500;
+
+promise_test(t => {
+ // Create a new window so we can navigate it later.
+ return with_window_by_name('foo').then(win => {
+ // Schedule a timer within the new window. Our intent is
+ // to navigate the window before the timer fires.
+ let delayFired = false;
+ let innerDelay = delay(win, DELAY);
+ innerDelay.then(_ => {
+ delayFired = true;
+ });
+
+ return navigate_by_name(win, 'bar').then(_ => {
+ // Since the window has navigated the timer should not
+ // fire. We set a timer on our current test window
+ // to verify the other timer is not received.
+ assert_false(delayFired);
+ return delay(window, DELAY * 2);
+ }).then(_ => {
+ // The navigated window's timer should not have fired.
+ assert_false(delayFired);
+ // Now go back to the document that set the timer.
+ return go_back(win);
+ }).then(_ => {
+ // We wait for one of two conditions here. For browsers
+ // with a bfcache the original suspended timer will fire.
+ // Alternatively, if the browser reloads the page the original
+ // message will be sent again. Wait for either of these
+ // two events.
+ return Promise.race([wait_for_message('foo'), innerDelay]);
+ }).then(_ => {
+ win.close();
+ });
+ });
+}, 'history.back() handles top level page timer correctly');
+
+promise_test(t => {
+ let win;
+ // Create a new window so we can navigate it later.
+ return with_window_by_name('foo').then(w => {
+ win = w;
+
+ // Create a nested frame so we check if navigation and history.back()
+ // properly handle child window state.
+ return with_nested_frame(win, 'about:blank');
+
+ }).then(frame => {
+ // Schedule a timer within the nested frame contained by the new window.
+ // Our intent is to navigate the window before the timer fires.
+ let delayFired = false;
+ let innerDelay = delay(frame.contentWindow, DELAY);
+ innerDelay.then(_ => {
+ delayFired = true;
+ });
+
+ return navigate_by_name(win, 'bar').then(_ => {
+ // Since the window has navigated the timer should not
+ // fire. We set a timer on our current test window
+ // to verify the other timer is not received.
+ assert_false(delayFired);
+ return delay(window, DELAY * 2);
+ }).then(_ => {
+ // The navigated window's timer should not have fired.
+ assert_false(delayFired);
+ // Now go back to the document containing the frame that set the timer.
+ return go_back(win);
+ }).then(_ => {
+ // We wait for one of two conditions here. For browsers
+ // with a bfcache the original suspended timer will fire.
+ // Alternatively, if the browser reloads the page the original
+ // message will be sent again. Wait for either of these
+ // two events.
+ return Promise.race([wait_for_message('foo'), innerDelay]);
+ }).then(_ => {
+ win.close();
+ });
+ });
+}, 'history.back() handles nested iframe timer correctly');
+
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html
new file mode 100644
index 000000000..e47cd9c38
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>Verify existence and basic read/write function of history.scrollRestoration</title>
+
+<style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+</style>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ test(function() {
+ assert_equals(history.scrollRestoration, 'auto');
+ }, 'Default value is "auto"');
+
+ test(function() {
+ history.scrollRestoration = 'manual';
+ assert_equals(history.scrollRestoration, 'manual', 'should be able to set "manual"');
+ history.scrollRestoration = 'auto';
+ assert_equals(history.scrollRestoration, 'auto', 'should be able to set "auto"');
+ }, 'It is writable');
+
+ test(function() {
+ history.scrollRestoration = 'auto';
+ for (var v of [3.1415, {}, 'bogus']) {
+ history.scrollRestoration = v;
+ assert_equals(history.scrollRestoration, 'auto', `setting to invalid value (${v}) should be ignored`);
+ }
+ }, 'Invalid values are ignored');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html
new file mode 100644
index 000000000..e3da59e39
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<meta name=timeout content=long>
+<title>Precedence of scroll restoration mode over fragment scrolling in cross-origin history traversal</title>
+<style>
+ iframe {
+ height: 300px;
+ width: 300px;
+ }
+</style>
+
+<body>
+ <iframe></iframe>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ // The test does the following navigation steps for iframe
+ // 1. load page-with-fragment.html#fragment
+ // 2. load blank1
+ // 3. go back to page-with-fragment.html
+ async_test(function(t) {
+ var iframe = document.querySelector('iframe');
+ var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
+
+ var steps = [
+ function() {
+ iframe.src = 'resources/page-with-fragment.html#fragment';
+ }, function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be on page-with-fragment page');
+ // wait one animation frame to ensure layout is run and fragment scrolling is complete
+ iframe.contentWindow.requestAnimationFrame(function() {
+ assert_equals(iframe.contentWindow.scrollY, 800, 'should scroll to fragment');
+
+ iframe.contentWindow.history.scrollRestoration = 'manual';
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
+ setTimeout(next, 0);
+ });
+ }, function() {
+ // navigate to a new page from a different origin
+ iframe.src = iframe.src.replace("http://", "http://www.").replace("page-with-fragment.html#fragment", "blank1.html");
+ }, function() {
+ // going back causes the iframe to traverse back
+ history.back();
+ }, function() {
+ // coming back from history, scrollRestoration should be set to manual and respected
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/page-with-fragment.html#fragment', 'should be back on page-with-fragment page');
+ iframe.contentWindow.requestAnimationFrame(function() {
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
+ assert_equals(iframe.contentWindow.scrollX, 0, 'should not scroll to fragment');
+ assert_equals(iframe.contentWindow.scrollY, 0, 'should not scroll to fragment');
+ t.done();
+ });
+ }
+ ];
+
+ var stepCount = 0;
+ var next = t.step_func(function() {
+ steps[stepCount++]();
+ });
+
+ iframe.onload = next;
+ next();
+ }, 'Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html
new file mode 100644
index 000000000..d837b8f63
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+
+ #fragment {
+ position: absolute;
+ top: 800px;
+ background-color: #faa;
+ display: block;
+ height: 100px;
+ width: 100px;
+ }
+</style>
+
+<body>
+ <a id="fragment" name="fragment" class='box'></a>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ async_test(function(t) {
+ history.scrollRestoration = 'manual';
+ assert_equals(history.scrollRestoration, 'manual');
+
+ location.hash = '#fragment';
+ assert_equals(window.scrollY, 800, 'new navigations should scroll to fragment');
+
+ // create a new entry and reset the scroll before verification
+ history.pushState(null, null, '#done');
+ window.scrollTo(0, 0);
+ assert_equals(window.scrollY, 0, 'should reset scroll before verification');
+
+ setTimeout(function() {
+ // setup verification
+ window.addEventListener('hashchange', t.step_func(function() {
+ assert_equals(location.hash, '#fragment');
+ assert_equals(history.scrollRestoration, 'manual');
+ // navigating back should give precedent to history restoration which is 'manual'
+ assert_equals(window.scrollX, 0, 'should not scroll to fragment');
+ assert_equals(window.scrollY, 0, 'should not scroll to fragment');
+ t.done();
+ }));
+ // kick off verification
+ window.history.back();
+ }, 0);
+
+ }, 'Manual scroll restoration should take precedent over scrolling to fragment in cross doc navigation');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html
new file mode 100644
index 000000000..87a337b2d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<meta name=timeout content=long>
+<title>Correct behaviour of scroll restoration mode is cross origin history traversal</title>
+
+<style>
+ iframe {
+ height: 300px;
+ width: 300px;
+ }
+</style>
+
+<body>
+ <iframe></iframe>
+</body>
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ // The test does the following navigation steps for iframe
+ // 1. load blank1
+ // 2. load blank2
+ // 3. go back to blank1
+ async_test(function(t) {
+ var iframe = document.querySelector('iframe');
+ var baseURL = location.href.substring(0, location.href.lastIndexOf('/'));
+
+ var steps = [
+ function() {
+ iframe.src = 'resources/blank1.html';
+ },
+ function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be on first blank page');
+ iframe.contentWindow.history.scrollRestoration = 'manual';
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual');
+ iframe.contentWindow.scrollTo(500, 500);
+ assert_equals(iframe.contentWindow.scrollX, 500, 'scripted scrolling should take effect');
+ assert_equals(iframe.contentWindow.scrollY, 500, 'scripted scrolling should take effect');
+ setTimeout(next, 0);
+ },
+ function() {
+ // navigate to new page
+ iframe.src = 'resources/blank2.html';
+ },
+ function() {
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank2.html', 'should be on second blank page');
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'auto', 'new page loads should set scrollRestoration to "auto"');
+ setTimeout(next, 0);
+ }, function() {
+ iframe.contentWindow.history.back();
+ }, function() {
+ // coming back scrollRestoration should be restored to 'manual' and respected
+ assert_equals(iframe.contentWindow.location.href, baseURL + '/resources/blank1.html', 'should be back on first blank page');
+ assert_equals(iframe.contentWindow.history.scrollRestoration, 'manual', 'navigating back should retain scrollRestoration value');
+ assert_equals(iframe.contentWindow.scrollX, 0, 'horizontal scroll offset should not be restored');
+ assert_equals(iframe.contentWindow.scrollY, 0, 'vertical scroll offset should not be restored');
+ t.done();
+ }
+ ];
+
+ var stepCount = 0;
+ var next = t.step_func(function() {
+ steps[stepCount++]();
+ });
+
+ iframe.onload = next;
+ next();
+ }, 'Navigating to new page should reset to "auto" and navigating back should restore and respect scroll restoration mode');
+
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html
new file mode 100644
index 000000000..46d40eedc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<title>Correct behaviour of scroll restoration mode in same document history traversals</title>
+
+<style>
+ body {
+ height: 10000px;
+ width: 10000px;
+ }
+</style>
+
+<body></body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script type="text/javascript">
+ 'use strict';
+
+ async_test(function(t) {
+ history.scrollRestoration = 'auto';
+ window.scrollTo(0, 0);
+
+ // create history entries and then verify the impact of scrollRestoration
+ // when they are popped
+ var entries = {
+ /* For scroll restoration mode 'auto', the spec does not require scroll
+ position to be restored at any particular value. */
+ '#1': {type: 'push', expectedScroll: null, scrollRestoration: 'auto'},
+ '#2': {type: 'replace', expectedScroll: null, scrollRestoration: 'auto'},
+ /* For scroll restoration mode 'manual', the spec requires scroll position
+ not to be restored. So we expect [555,555] which is the latest position
+ before navigation. */
+ '#3': {type: 'push', expectedScroll: [555, 555], scrollRestoration: 'manual'},
+ '#4': {type: 'replace', expectedScroll: [555, 555], scrollRestoration: 'manual'}
+ };
+
+ // setup entries
+ for (var key in entries) {
+ var entry = entries[key],
+ beforeValue = history.scrollRestoration,
+ newValue = entry.scrollRestoration;
+
+ var args = [{key: key}, '', key];
+ if (entry.type == 'push') {
+ history.pushState.apply(history, args);
+ } else {
+ history.pushState(null, '', key);
+ history.replaceState.apply(history, args);
+ }
+ assert_equals(history.scrollRestoration, beforeValue, `history.scrollRestoration value is retained after pushing new state`);
+ history.scrollRestoration = newValue;
+ assert_equals(history.scrollRestoration, newValue, `Setting scrollRestoration to ${newValue} works as expected`);
+ window.scrollBy(50, 100);
+ }
+
+ // setup verification
+ window.addEventListener('hashchange', t.step_func(function() {
+ var key = location.hash,
+ entry = entries[key];
+
+ if (key === '') {
+ t.done();
+ return;
+ }
+ assert_equals(history.state.key, key, `state should have key: ${key}`);
+ assert_equals(history.scrollRestoration, entry.scrollRestoration, 'scrollRestoration is updated correctly');
+ if (entry.expectedScroll) {
+ assert_equals(window.scrollX, entry.expectedScroll[0], `scrollX is correct for ${key}`);
+ assert_equals(window.scrollY, entry.expectedScroll[1], `scrollY is correct for ${key}`);
+ }
+
+ window.history.back();
+ }));
+
+ // reset the scroll and kick off the verification
+ setTimeout(function() {
+ history.pushState(null, null, '#done');
+ window.scrollTo(555, 555);
+ window.history.back();
+ }, 0);
+
+ }, 'history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it');
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html
new file mode 100644
index 000000000..7630b9918
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/popstate_event.html
@@ -0,0 +1,40 @@
+<!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) {
+ 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/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html
new file mode 100644
index 000000000..d3d67d0f8
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<title>window.name after navigating to a different origin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(function() {assert_equals(window.name, "")})
+</script>
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html
new file mode 100644
index 000000000..6814ed50e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/unset_context_name.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<!-- test must be run in a top level browsing context -->
+<title>window.name after navigating to a different origin</title>
+<script>
+window.name = "test_window";
+location.href = location.href.replace("http://", "http://www.").replace("unset_context_name", "unset_context_name-1");
+</script>