Closed
Bug 515190
Opened 15 years ago
Closed 15 years ago
Hashchange event should be dispatched synchronously
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a1
People
(Reporter: justin.lebar+bug, Assigned: justin.lebar+bug)
References
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 3 obsolete files)
(deleted),
patch
|
Details | Diff | Splinter Review |
HTML5 now fires the hashchange event synchronously, and we probably should change our implementation to match this.
See http://www.whatwg.org/specs/web-apps/current-work/#history-traversal
Flags: wanted1.9.2?
Comment 1•15 years ago
|
||
So why synchronously? I thought IE dispatches async.
Assignee | ||
Comment 2•15 years ago
|
||
IE does dispatch async; in fact the spec was originally changed to match this behavior. Hixie decided to change it back in this message to the list [1]. I think it basically boils down to the following case:
Visit page, page#a, page#b.
Go back twice, quickly.
You'll get two hashchange events because the hash changed twice, but if you went back quickly enough, location.hash will be '#' for both those events, and so it's difficult for the app to determine that you went through state '#a' before reaching '#'.
I think we were willing to accept this before we started thinking about popstate, which might be even more confusing if it was dispatched while you were at the wrong page.
[1] http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-August/022312.html
Comment 3•15 years ago
|
||
Would it make sense if hashchange event had
attribute DOMString hash;
(I need to now remember what problems sync hashchange causes.)
Assignee | ||
Comment 4•15 years ago
|
||
Maybe. But then you have the same problem as async popstate -- now the state/hash argument doesn't match the current location.
There might be other problems, too. :)
Assignee | ||
Comment 5•15 years ago
|
||
Patch to make hashchange synchronous.
Attachment #414462 -
Flags: review?(Olli.Pettay)
Updated•15 years ago
|
Attachment #414462 -
Flags: review?(Olli.Pettay) → review+
Olli: is it really safe to run scripts here?
Comment 7•15 years ago
|
||
As far as I see it should be. Or at least it shouldn't be
any more scary than beforeunload.
But Justin, perhaps you could add an
assertion to DispatchSyncHashchange to check that it is safe to run scripts.
Don't we already have such an assertion in the event-dispatch code? If not, we should.
Assignee | ||
Comment 9•15 years ago
|
||
It doesn't appear that we call nsContentUtils::IsSafeToRunScripts from anywhere deep in the event dispatching code. I've added the check here and filed a follow-up at bug 531176.
Attachment #414462 -
Attachment is obsolete: true
Depends on: 531176
Assignee | ||
Comment 10•15 years ago
|
||
Attachment #414578 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Keywords: checkin-needed
I check this patch in, but backed it out since it seemed to cause a failure in test_bug509055.html:
http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1262828244.1262829317.1880.gz
Keywords: checkin-needed
Assignee | ||
Comment 12•15 years ago
|
||
Fixed the failing test.
Attachment #420361 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Keywords: checkin-needed
Comment 13•15 years ago
|
||
Should update https://developer.mozilla.org/en/DOM/window.onhashchange when this lands. It's a bit unfortunate that 3.6's behavior will be different from the newer versions..
Keywords: dev-doc-needed
Comment 14•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
Comment 15•15 years ago
|
||
Documentation updated:
https://developer.mozilla.org/en/DOM/window.onhashchange
Keywords: dev-doc-needed → dev-doc-complete
Comment 16•15 years ago
|
||
And now it seems that Hixie wants it to be async again :(
http://html5.org/tools/web-apps-tracker?from=4631&to=4632
Comment 17•15 years ago
|
||
Yeah, sorry about that. I try to minimise churn, but sometimes I make mistakes. :-(
Comment 18•15 years ago
|
||
Should this be backed out?
Comment 19•15 years ago
|
||
Seems like HTML5's session history handling isn't stable at all atm.
There are certainly still open issues and those may affect to the
recent change which made back()/forward() async (I may not agree with the change,
certainly the reasoning for the change isn't good enough), and caused also
hashchange event to become async again.
Comment 20•15 years ago
|
||
Yeah, this stuff is very new (hasn't ever been specced before, so we're finding all kinds of issues with it). It would probably make sense to wait a few months and see how it settles out. Again, sorry about the churn.
Assignee | ||
Updated•15 years ago
|
Flags: wanted1.9.2?
Updated•14 years ago
|
Comment 21•14 years ago
|
||
For what it's worth, the sync behavior breaks at least one site (dominos.com) as of a few days ago when they redesigned, presumably because they assumed the de-facto-standard async behavior.
So I think we do want async behavior here. See bug 615061.
Comment 22•14 years ago
|
||
(In reply to comment #16)
> Documentation updated:
> https://developer.mozilla.org/en/DOM/window.onhashchange
Bug 615061 is fixed, I took back that updates
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•