summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html')
-rw-r--r--testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html
new file mode 100644
index 0000000000..3e25f0e6f2
--- /dev/null
+++ b/testing/web-platform/tests/portals/history/resources/portal-manipulate-history.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<script src="portal-harness.js"></script>
+<body>
+<script>
+ function testHistoryPushStateInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ assert(!history.state, 'Initial history state');
+
+ history.pushState('teststate', null, null);
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(history.state == 'teststate', 'Update state');
+ }
+
+ function testHistoryReplaceStateInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ assert(!history.state, 'Initial history state');
+
+ history.replaceState('teststate', null, null);
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(history.state == 'teststate', 'Update state');
+ }
+
+ function testLocationAssignInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ let initialLocation = location.href;
+ location.assign('#test');
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(location.href != initialLocation, 'Update location');
+ }
+
+ function testLocationReplaceInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ let initialLocation = location.href;
+ location.replace('#test');
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(location.href != initialLocation, 'Update location');
+ }
+
+ function testSetLocationHrefInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ let initialLocation = location.href;
+ location.href = '#test';
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(location.href != initialLocation, 'Update location');
+ }
+
+ function testSyntheticAnchorClickInPortal() {
+ assert(history.length == 1, 'Initial history length');
+ let initialLocation = location.href;
+
+ var anchor = document.createElement('a');
+ anchor.href = '#test';
+ document.body.appendChild(anchor);
+
+ anchor.click();
+
+ assert(history.length == 1, 'History length unchanged');
+ assert(location.href != initialLocation, 'Update location');
+ }
+</script>
+</body>