Re: Issue 63040 in chromium: Add window.history.state and don't fire popstate after load

1,457 views
Skip to first unread message

chro...@googlecode.com

unread,
May 27, 2011, 3:35:21 PM5/27/11
to chromi...@chromium.org
Updates:
Summary: Add window.history.state and don't fire popstate after load
Status: Assigned
Owner: mih...@chromium.org
Labels: Mstone-14

Comment #7 on issue 63040 by mih...@chromium.org: Add window.history.state
and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Yes, there was a meeting with Mozilla and a spec-change in March. Mozilla
implemented these changes
(http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/),
Chrome/WebKit has not yet. Re-purposing this bug for that.

chro...@googlecode.com

unread,
Sep 5, 2011, 12:23:06 PM9/5/11
to chromi...@chromium.org

Comment #11 on issue 63040 by kaspars....@efumo.lv: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

//found fast workaround to get same behawior as ff4:

setTimeout(function(){
window.onpopstate = function(event){
window.console && window.console.log(event);
};
},1000);

chro...@googlecode.com

unread,
Oct 26, 2011, 4:54:28 PM10/26/11
to chromi...@chromium.org
Updates:
Status: Available
Owner: ---
Labels: WebKit-ID-70876

Comment #13 on issue 63040 by mih...@chromium.org: Add window.history.state

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jan 20, 2012, 6:56:36 PM1/20/12
to chromi...@chromium.org
Updates:
Labels: -WebKit-ID-70876-RESOLVED WebKit-ID-76035

Comment #18 on issue 63040 by mih...@chromium.org: Add window.history.state

chro...@googlecode.com

unread,
Jan 20, 2012, 8:29:19 PM1/20/12
to chromi...@chromium.org
Updates:
Labels: -WebKit-ID-76035 WebKit-ID-76035-UNCONFIRMED WebKit-Rev-105308

Comment #19 on issue 63040 by bugdro...@chromium.org: Add

window.history.state and don't fire popstate after load

http://code.google.com/p/chromium/issues/detail?id=63040#c19

https://bugs.webkit.org/show_bug.cgi?id=76035
http://trac.webkit.org/changeset/105308

chro...@googlecode.com

unread,
Feb 8, 2012, 6:39:46 AM2/8/12
to chromi...@chromium.org
Updates:
Labels: -WebKit-ID-76035-UNCONFIRMED WebKit-ID-76035-RESOLVED
WebKit-Rev-107058

Comment #21 on issue 63040 by bugdro...@chromium.org: Add

window.history.state and don't fire popstate after load

http://code.google.com/p/chromium/issues/detail?id=63040#c21

https://bugs.webkit.org/show_bug.cgi?id=76035
http://trac.webkit.org/changeset/107058

chro...@googlecode.com

unread,
May 3, 2012, 2:29:25 AM5/3/12
to chromi...@chromium.org

Comment #22 on issue 63040 by zhouyanm...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

please don't fire onpopstate after load like firefox
I think onpopstate must be one-to-one with every pushState

chro...@googlecode.com

unread,
May 17, 2012, 2:35:51 PM5/17/12
to chromi...@chromium.org

Comment #23 on issue 63040 by ericbide...@chromium.org: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

There are 2 bugs here. history.state is implemented. We can make that as
fixed.
onpopstate firing on page load should be moved to a new issue.

chro...@googlecode.com

unread,
Aug 31, 2012, 7:04:35 AM8/31/12
to chromi...@chromium.org

Comment #24 on issue 63040 by sonny.pi...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Any update?
The popstate event emitted on load is really annoying.

chro...@googlecode.com

unread,
Aug 31, 2012, 7:32:47 AM8/31/12
to chromi...@chromium.org

Comment #25 on issue 63040 by sonny.pi...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Here is my solution if it can helps someone:
https://gist.github.com/3551566

chro...@googlecode.com

unread,
Aug 31, 2012, 7:33:47 AM8/31/12
to chromi...@chromium.org

Comment #26 on issue 63040 by sonny.pi...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Here is my workaround if it can helps someone:
https://gist.github.com/3551566

chro...@googlecode.com

unread,
Jan 11, 2013, 1:53:34 AM1/11/13
to chromi...@chromium.org

Comment #27 on issue 63040 by ksh...@crct.de: Add window.history.state and
The latest W3C Candidate Recommendation
(http://www.w3.org/TR/2012/CR-html5-20121217/browsers.html#history-traversal)
makes it relatively clear that his is indeed a bug.


To paraphrase, "Fire a popstate event at the Window object of the Document
if the Document of the specified entry has a latest entry, and that entry
is not the specified entry."

chro...@googlecode.com

unread,
Jan 11, 2013, 4:30:23 PM1/11/13
to chromi...@chromium.org

Comment #29 on issue 63040 by ksh...@crct.de: Add window.history.state and
Thanks.
http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#history-traversal
says pretty much the same though.

chro...@googlecode.com

unread,
Jan 13, 2013, 2:19:04 PM1/13/13
to chromi...@chromium.org

Comment #30 on issue 63040 by p2km...@gmail.com: Add window.history.state
I've being trying to avoid this (as comment 11:
https://code.google.com/p/chromium/issues/detail?id=63040#c11) and I guess
this way behaves a little faster:

$(window).on('load', function () {
setTimeout(function () {
$(window).bind("popstate", function (event) {
// Do whatever you want...
});
}, 0);
});

Binding the popstate event after the window loads works for me even with no
delay.

chro...@googlecode.com

unread,
Mar 26, 2013, 6:36:09 AM3/26/13
to chromi...@chromium.org

Comment #32 on issue 63040 by tranquoc...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Does popstate fired when user pressing on Back button? According to w3c:

onpopstate : Script to be run when the window's history changes

So, I though when pressing on Back button the history object invoked back()
function which navigate to previous state on history object => that fired
the popstate event.
Currently, Chrome fire popstate after window load success.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Mar 26, 2013, 6:37:09 AM3/26/13
to chromi...@chromium.org

Comment #33 on issue 63040 by tranquoc...@gmail.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

Does popstate fired when user pressing on Back button and before browser
navigate to previous page (user can listen this event and stop the
navigation process of back button, like disable back button)? According to

chro...@googlecode.com

unread,
Oct 24, 2013, 11:35:56 PM10/24/13
to chromi...@chromium.org

Comment #36 on issue 63040 by i...@segment.io: Add window.history.state and
Not firing a popstate event is still a bug many months later. Any updates?

The only workarounds are really kludgey involving timeouts or assuming
things about history.state...

chro...@googlecode.com

unread,
Jan 1, 2014, 5:35:14 PM1/1/14
to chromi...@chromium.org

Comment #38 on issue 63040 by agamemnus: Add window.history.state and don't
Please fix this.

chro...@googlecode.com

unread,
Jan 12, 2014, 4:46:56 PM1/12/14
to chromi...@chromium.org

Comment #41 on issue 63040 by a...@zenexity.com: Add window.history.state
Please fix this old and very irritating bug.

There is no 100% reliable workaround.

chro...@googlecode.com

unread,
Jan 13, 2014, 5:16:58 AM1/13/14
to chromi...@chromium.org
Updates:
Status: Started
Owner: j...@opera.com

Comment #42 on issue 63040 by j...@opera.com: Add window.history.state and
(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jan 13, 2014, 6:11:06 AM1/13/14
to chromi...@chromium.org

Comment #43 on issue 63040 by j...@opera.com: Add window.history.state and
CL=https://codereview.chromium.org/136463002/

chro...@googlecode.com

unread,
Jan 13, 2014, 11:10:03 AM1/13/14
to chromi...@chromium.org

Comment #44 on issue 63040 by sim...@homeservealliance.com: Add
window.history.state and don't fire popstate after load
http://code.google.com/p/chromium/issues/detail?id=63040

We're tired of workarounds, please fix this.

chro...@googlecode.com

unread,
Feb 10, 2014, 4:18:28 PM2/10/14
to chromi...@chromium.org

Comment #47 on issue 63040 by laukstein: Add window.history.state and don't
Still not landed on Chrome 32 stable, fixed on Chrome Canary 34.

chro...@googlecode.com

unread,
Aug 2, 2014, 1:19:33 AM8/2/14
to chromi...@chromium.org

Comment #50 on issue 63040 by agamemnus: Add window.history.state and don't
!!!This bug is not fixed!!! The patch still misinterprets the text of the
specification.

#45
'According to the specification [1], a popstate event should only be fired
when the document has a "last entry" and the entry being navigated to isn't
it. A document is created without a "last entry" and gets one just after
this check when it is first navigated to, so a popstate should be fired any
time a document is navigated to except for the first time after it has been
created.'

'[1]
http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#traverse-the-history
(step 12-14 in particular)'

1) The document being navigated to is called the "specified entry".
2) The document being navigated from is called the "latest entry".
3) Steps 12-14 discuss the "specified entry" and the "latest entry".. not
the LAST ENTRY! Latest entry, not last entry. BIG DIFFERENCE HERE my
friend!!!

From
http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#traverse-the-history:
"12) Let state changed be true if the Document of the specified entry has a
latest entry, and that entry is not the specified entry; otherwise let it
be false."
The "state changed" is true, because the latest entry is not the specified
entry. This is where the logic of the patch diverges, because the patch
considers the latest entry to be the "LAST" entry.

Examine the code below. Going to e.g. google.com, then the page with the
code below, then back to google.com and back again to this page, should NOT
FIRE ONPOPSTATE!

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script type="text/javascript">
var history_control = new history_control_object ()
function history_control_object (new_state) {
window.addEventListener ('popstate', function (evt) {console.log
(evt.state)})
history.replaceState ({url: 'apple'}, "")
}
</script>
</body>
</html>
Reply all
Reply to author
Forward
0 new messages