Commit 1b2ce4af authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

wpt: Fix the test of history.state === popStateEvent.state

Firefox, Safari, and Chrome agree the behavior of
    history.state === popStateEvent.state
so update the test case accordingly.

IIUC, HTML also requires this behavior.
https://html.spec.whatwg.org/C/#history-traversal:dom-history-state
step 13. Set history.state to state.
step 16.1. If state changed is true, then fire an event
  named popstate at the Document object's relevant global
  object, using PopStateEvent, with the state attribute
  initialized to state.
where |state| is the result of StructuredDeserialize, so it's
expected that history.state === popStateEvent.state.

Bug: 1070938
Change-Id: I161e415ce986be56031080e1538a0d4ac4fbf133
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147169Reviewed-by: default avatarDomenic Denicola <domenic@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759269}
parent 2a266c7a
...@@ -36,7 +36,7 @@ PASS state data should cope with circular object references ...@@ -36,7 +36,7 @@ PASS state data should cope with circular object references
PASS state data should be a clone of the original object, not a reference to it PASS state data should be a clone of the original object, not a reference to it
PASS history.state should also reference a clone of the original object (2) PASS history.state should also reference a clone of the original object (2)
PASS history.state should be a clone of the original object, not a reference to it (2) PASS history.state should be a clone of the original object, not a reference to it (2)
FAIL history.state should be a separate clone of the object, not a reference to the object passed to the event handler assert_false: expected false got true PASS history.state should be identical to the object passed to the event handler unless history.state is updated
PASS pushState should not actually load the new URL PASS pushState should not actually load the new URL
PASS reloading a pushed state should actually load the new URL PASS reloading a pushed state should actually load the new URL
Harness: the test ran to completion. Harness: the test ran to completion.
......
...@@ -274,8 +274,8 @@ function reportload() { ...@@ -274,8 +274,8 @@ function reportload() {
assert_false( cloneobj === iframe.contentWindow.history.state ); assert_false( cloneobj === iframe.contentWindow.history.state );
}, 'history.state should be a clone of the original object, not a reference to it (2)'); }, 'history.state should be a clone of the original object, not a reference to it (2)');
test(function () { test(function () {
assert_false( iframe.contentWindow.history.state === ev.state ); assert_true( iframe.contentWindow.history.state === ev.state );
}, 'history.state should be a separate clone of the object, not a reference to the object passed to the event handler'); }, 'history.state should be identical to the object passed to the event handler unless history.state is updated');
try { try {
iframe.contentWindow.persistval = true; iframe.contentWindow.persistval = true;
iframe.contentWindow.history.pushState('','', location.href.replace(/\/[^\/]*$/,'/blank3.html') ); iframe.contentWindow.history.pushState('','', location.href.replace(/\/[^\/]*$/,'/blank3.html') );
......
This is a testharness.js-based test.
PASS history.length should update when loading pages in an iframe
PASS history.length should update when setting location.hash
PASS history.replaceState must exist
PASS history.replaceState must exist within iframes
PASS initial history.state should be null
PASS history.length should not update when replacing a state with no URL
PASS history.state should update after a state is pushed
PASS hash should not change when replaceState is called without a URL
PASS history.length should not update when replacing a state with a URL
PASS hash should change when replaceState is called with a URL
PASS replaceState must replace the existing state and not add an extra one
PASS replaceState must replace the existing state without altering the forward history
PASS replaceState must not be allowed to create invalid URLs
PASS replaceState must not be allowed to create cross-origin URLs
PASS replaceState must not be allowed to create cross-origin URLs (about:blank)
PASS replaceState must not be allowed to create cross-origin URLs (data:URI)
PASS security errors are expected to be thrown in the context of the document that owns the history object
PASS replaceState must be able to set location.pathname
PASS replaceState must be able to set absolute URLs to the same host
PASS replaceState must not remove any tasks queued by the history traversal task source
PASS .go must queue a task with the history traversal task source (run asynchronously)
PASS replaceState must not fire hashchange events
PASS replaceState must not be able to use a function as data
PASS replaceState must not be able to use a DOM node as data
PASS replaceState must be able to use an error object as data
PASS security errors are expected to be thrown in the context of the document that owns the history object (2)
PASS replaceState must be able to make structured clones of complex objects
PASS history.state should also reference a clone of the original object
PASS history.state should be a clone of the original object, not a reference to it
PASS popstate event should fire when navigation occurs
PASS popstate event should pass the state data
PASS state data should cope with circular object references
PASS state data should be a clone of the original object, not a reference to it
PASS history.state should also reference a clone of the original object (2)
PASS history.state should be a clone of the original object, not a reference to it (2)
FAIL history.state should be a separate clone of the object, not a reference to the object passed to the event handler assert_false: expected false got true
PASS replaceState should not actually load the new URL
PASS reloading a replaced state should actually load the new URL
Harness: the test ran to completion.
...@@ -249,8 +249,8 @@ function reportload() { ...@@ -249,8 +249,8 @@ function reportload() {
assert_false( cloneobj === iframe.contentWindow.history.state ); assert_false( cloneobj === iframe.contentWindow.history.state );
}, 'history.state should be a clone of the original object, not a reference to it (2)'); }, 'history.state should be a clone of the original object, not a reference to it (2)');
test(function () { test(function () {
assert_false( iframe.contentWindow.history.state === ev.state ); assert_true( iframe.contentWindow.history.state === ev.state );
}, 'history.state should be a separate clone of the object, not a reference to the object passed to the event handler'); }, 'history.state should be identical to the object passed to the event handler unless history.state is updated');
try { try {
iframe.contentWindow.persistval = true; iframe.contentWindow.persistval = true;
iframe.contentWindow.history.replaceState('','', location.href.replace(/\/[^\/]*$/,'/blank3.html') ); iframe.contentWindow.history.replaceState('','', location.href.replace(/\/[^\/]*$/,'/blank3.html') );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment