Changeset 53672 in webkit


Ignore:
Timestamp:
Jan 21, 2010 8:22:02 PM (14 years ago)
Author:
beidson@apple.com
Message:

history.back() for same-document history traversals isn't synchronous as the specification states.
<rdar://problem/7535011> and https://bugs.webkit.org/show_bug.cgi?id=33538

Reviewed by Maciej Stachowiak.

JavaScriptCore:

  • wtf/Platform.h: Add a "HISTORY_ALWAYS_ASYNC" enable and turn it on for Chromium.

WebCore:

In resolving https://bugs.webkit.org/show_bug.cgi?id=25570, all history.back()/forward()/go() navigations
were made asynchronous. That doesn't agree with the HTML5 spec and might have been overreaching for fixing
that particular bug. In working with the new history state APIs I noticed some things that should've been
possible were not possible because of this change.

The change in loading behavior is well covered via modifications to previous tests.

  • loader/RedirectScheduler.cpp:

(WebCore::RedirectScheduler::scheduleHistoryNavigation): Determine beforehand if the traversal is

a same-document navigation. If it is, perform the load directly instead of scheduling it.

LayoutTests:

The change in loading behavior is well covered via modifications to these previous tests:

  • fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html:
  • fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange-expected.txt:
  • fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html:
  • fast/loader/stateobjects/state-api-on-detached-frame-crash-expected.txt:
  • fast/loader/stateobjects/state-api-on-detached-frame-crash.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r53657 r53672  
     12010-01-21  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        history.back() for same-document history traversals isn't synchronous as the specification states.
     6        <rdar://problem/7535011> and https://bugs.webkit.org/show_bug.cgi?id=33538
     7
     8        * wtf/Platform.h: Add a "HISTORY_ALWAYS_ASYNC" enable and turn it on for Chromium.
     9
    1102010-01-21  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/JavaScriptCore/wtf/Platform.h

    r53579 r53672  
    459459/* PLATFORM(SKIA) for Win/Linux, CG/CI for Mac */
    460460#if PLATFORM(CHROMIUM)
     461#define ENABLE_HISTORY_ALWAYS_ASYNC 1
    461462#if OS(DARWIN)
    462463#define WTF_PLATFORM_CG 1
  • trunk/LayoutTests/ChangeLog

    r53669 r53672  
     12010-01-21  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        history.back() for same-document history traversals isn't synchronous as the specification states.
     6        <rdar://problem/7535011> and https://bugs.webkit.org/show_bug.cgi?id=33538
     7
     8        The change in loading behavior is well covered via modifications to these previous tests:
     9
     10        * fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html:
     11        * fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange-expected.txt:
     12        * fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html:
     13        * fast/loader/stateobjects/state-api-on-detached-frame-crash-expected.txt:
     14        * fast/loader/stateobjects/state-api-on-detached-frame-crash.html:
     15
    1162010-01-21  Kent Tamura  <tkent@chromium.org>
    217
  • trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html

    r53361 r53672  
    2525{
    2626    alert("Last path component of location is " + lastPathComponent());
    27     history.back();
     27    setTimeout("history.back();", 0);
    2828}
    2929
     
    4949    if (event.state == "FirstEntry") {
    5050        history.replaceState("FirstEntryWillLaterBeReactivated", null, "#FirstEntryWillLaterBeReactivated");
    51         history.forward();
     51        setTimeout("history.forward();", 0);
    5252    } else if (event.state == "SecondEntry") {
    5353        history.replaceState("SecondEntryWillLaterBeReactivated", null, "#SecondEntryWillLaterBeReactivated");
  • trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange-expected.txt

    r51653 r53672  
    33State popped with event null (type object) and last path component some-other.html?withsomeotherquery
    44State popped with event null (type object) and last path component some-other.html?withsomeotherquery#
    5 Hash change fired
     5Hash change fired and last path component is some-other.html?withsomeotherquery#
    66State popped with event null (type object) and last path component some-other.html?withsomeotherquery
    7 Hash change fired
     7Hash change fired and last path component is some-other.html?withsomeotherquery
    88State popped with event null (type object) and last path component some-other.html?withsomeotherquery#somehash
    9 Hash change fired
     9Hash change fired and last path component is some-other.html?withsomeotherquery#somehash
    1010State popped with event null (type object) and last path component some-other.html?withsomeotherquery#someotherhash
    11 Hash change fired
     11Hash change fired and last path component is some-other.html?withsomeotherquery#someotherhash
    1212State popped with event null (type object) and last path component some-other.html?withquery#someotherhash
    1313State popped with event null (type object) and last path component some-other.html?withquery#
    14 Hash change fired
     14Hash change fired and last path component is some-other.html?withquery#
    1515State popped with event null (type object) and last path component some-other.html?withquery#somehash
    16 Hash change fired
     16Hash change fired and last path component is some-other.html?withquery#somehash
    1717State popped with event null (type object) and last path component some-other.html?withquery
    18 Hash change fired
     18Hash change fired and last path component is some-other.html?withquery
    1919State popped with event null (type object) and last path component some-other.html?withquery#
    20 Hash change fired
     20Hash change fired and last path component is some-other.html?withquery#
    2121State popped with event null (type object) and last path component some-other.html?withquery
    22 Hash change fired
     22Hash change fired and last path component is some-other.html?withquery
    2323State popped with event null (type object) and last path component some-other.html
    2424State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#
    2525State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#
    2626State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#otherhash
    27 Hash change fired
     27Hash change fired and last path component is pushstate-with-fragment-urls-and-hashchange.html#otherhash
    2828State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#hash
    29 Hash change fired
     29Hash change fired and last path component is pushstate-with-fragment-urls-and-hashchange.html#hash
    3030State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#
    31 Hash change fired
     31Hash change fired and last path component is pushstate-with-fragment-urls-and-hashchange.html#
    3232State popped with event null (type object) and last path component pushstate-with-fragment-urls-and-hashchange.html#
    3333State popped with event OriginalEntry (type string) and last path component pushstate-with-fragment-urls-and-hashchange.html
  • trunk/LayoutTests/fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html

    r51653 r53672  
    4949    log("State popped with event " + event.state + " (type " + typeof event.state + ") and last path component " + lastPathComponent());
    5050    if (event.state != "OriginalEntry")
    51         history.back();
     51        setTimeout("history.back();", 0);
    5252    else if (window.layoutTestController)
    5353        layoutTestController.notifyDone();
     
    5656function hashChanged()
    5757{
    58     log("Hash change fired");
     58    log("Hash change fired and last path component is " + lastPathComponent());
    5959}
    6060
  • trunk/LayoutTests/fast/loader/stateobjects/state-api-on-detached-frame-crash-expected.txt

    r53472 r53672  
    1 If this test doesn't crash, it passed.
     1
  • trunk/LayoutTests/fast/loader/stateobjects/state-api-on-detached-frame-crash.html

    r53472 r53672  
    99    var ifr = frames[0];
    1010    document.body.removeChild(document.getElementsByTagName("iframe")[0])
    11     try {
    12         ifr.history.replaceState("foo", "bar");
    13     } catch(e) {
    14         alert(e);
    15     }
    16     try {
    17         ifr.history.pushState("fu", "barred");
    18     } catch(e) {
    19         alert(e);
    20     }   
     11    ifr.history.replaceState("foo", "bar");
     12    ifr.history.pushState("fu", "barred");
    2113}
    2214
    2315</script>
    2416<body onload="runTest();">
    25 If this test doesn't crash, it passed.
    2617<iframe src="about:blank">
    2718</iframe>
  • trunk/WebCore/ChangeLog

    r53670 r53672  
     12010-01-21  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        history.back() for same-document history traversals isn't synchronous as the specification states.
     6        <rdar://problem/7535011> and https://bugs.webkit.org/show_bug.cgi?id=33538
     7
     8        In resolving https://bugs.webkit.org/show_bug.cgi?id=25570, all history.back()/forward()/go() navigations
     9        were made asynchronous. That doesn't agree with the HTML5 spec and might have been overreaching for fixing
     10        that particular bug. In working with the new history state APIs I noticed some things that should've been
     11        possible were not possible because of this change.
     12
     13        The change in loading behavior is well covered via modifications to previous tests.
     14
     15        * loader/RedirectScheduler.cpp:
     16        (WebCore::RedirectScheduler::scheduleHistoryNavigation): Determine beforehand if the traversal is
     17          a same-document navigation. If it is, perform the load directly instead of scheduling it.
     18
    1192010-01-21  Jakub Wieczorek  <faw217@gmail.com>
    220
  • trunk/WebCore/loader/RedirectScheduler.cpp

    r52033 r53672  
    3333#include "RedirectScheduler.h"
    3434
     35#include "BackForwardList.h"
    3536#include "DocumentLoader.h"
    3637#include "Event.h"
     
    3940#include "FrameLoadRequest.h"
    4041#include "FrameLoader.h"
     42#include "HistoryItem.h"
    4143#include "HTMLFormElement.h"
    4244#include "HTMLFrameOwnerElement.h"
     
    266268    // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled
    267269    // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether.
    268     if (!m_frame->page()->canGoBackOrForward(steps)) {
    269         cancel();
    270         return;
    271     }
    272 
     270    HistoryItem* specifiedEntry = m_frame->page()->backForwardList()->itemAtIndex(steps);
     271    if (!specifiedEntry) {
     272        cancel();
     273        return;
     274    }
     275   
     276#if !ENABLE(HISTORY_ALWAYS_ASYNC)
     277    // If the specified entry and the current entry have the same document, this is either a state object traversal or a fragment
     278    // traversal (or both) and should be performed synchronously.
     279    HistoryItem* currentEntry = m_frame->loader()->history()->currentItem();
     280    if (currentEntry != specifiedEntry && specifiedEntry->document() && currentEntry->document() == specifiedEntry->document()) {
     281        m_frame->loader()->history()->goToItem(specifiedEntry, FrameLoadTypeIndexedBackForward);
     282        return;
     283    }
     284#endif
     285   
     286    // In all other cases, schedule the history traversal to occur asynchronously.
    273287    schedule(new ScheduledRedirection(steps));
    274288}
Note: See TracChangeset for help on using the changeset viewer.