Bug 33931 - pushstate() from within a popstate handler might lead to improper scroll/view state being incorrect later
Summary: pushstate() from within a popstate handler might lead to improper scroll/view...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-20 18:07 PST by Brady Eidson
Modified: 2010-06-29 14:14 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2010-01-20 18:07:13 PST
pushstate() from within a popstate handler might lead to improper scroll/view state being incorrect later

See the test case in https://bugs.webkit.org/show_bug.cgi?id=33830 for reference.

Since the popstate event - fired from within FrameLoader::loadInSameDocument() called from FrameLoader::navigateWithinDocument() - can effectively change the current history item, the later call to history()->restoreScrollPositionAndViewState() will be operating on the wrong "current history item" from the perspective of the load.

There's a lot of complexity here in getting this precisely right, especially since popstate events might nest and we'd probably only want to restore the scroll/view state from the most recently popped item.
Comment 1 Darin Fisher (:fishd, Google) 2010-01-22 00:27:58 PST
We should be very careful here since history()->restoreScrollPositionAndViewState() may lead to the scroll event being dispatched.  Can the app do other things within the popstate event that could cause the scroll event to be confusing to the app?  (This re-entrancy stuff gives me a headache!)
Comment 2 Justin Lebar 2010-06-29 14:13:53 PDT
Forgot to include a link above:

[2]: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-definitions
Comment 3 Justin Lebar 2010-06-29 14:14:15 PDT
Oops, wrong bug.  Sorry!