Changeset 65340 in webkit


Ignore:
Timestamp:
Aug 13, 2010 4:35:34 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-13 Mihai Parparita <mihaip@chromium.org>

Reviewed by Dimitri Glazkov.

Session history should skip over JS redirects
https://bugs.webkit.org/show_bug.cgi?id=42861

Lock the back/forward list for location changes and form submits that
happen before the onload event fires that are not the result of user
gestures.

http/tests/history tests now pass, their expectations were updated
accordingly. Other tests needed a setTimeout wrapper around location
changes and form submits during onload, otherwise they would not
generate history entries as expected anymore.

  • fast/css/target-fragment-match.html:
  • fast/dom/location-hash.html:
  • fast/dom/Geolocation/resources/cached-page-1.html:
  • fast/dom/Window/timer-resume-on-navigation-back.html:
  • fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt:
  • fast/events/pageshow-pagehide-on-back-cached-with-frames.html:
  • fast/forms/button-state-restore.html:
  • fast/forms/state-restore-to-non-autocomplete-form.html:
  • fast/forms/state-restore-to-non-edited-controls.html:
  • fast/frames/resources/cached-page-1.html:
  • fast/frames/resources/cached-page-2.html:
  • fast/harness/resources/cached-page-1.html:
  • fast/harness/resources/cached-page-with-data-urls.html:
  • fast/history/gesture-before-onload-expected.txt: Added.
  • fast/history/gesture-before-onload.html: Added.
  • fast/history/history-length.html:
  • fast/history/resources/gesture-before-onload-target.html: Added.
  • fast/history/saves-state-after-fragment-nav.html:
  • fast/loader/input-element-page-cache-crash.html:
  • fast/loader/stateobjects/document-destroyed-navigate-back.html:
  • fast/loader/stateobjects/pushstate-clears-forward-history.html:
  • fast/loader/subframe-navigate-during-main-frame-load.html:
  • http/tests/history/back-to-post.php:
  • http/tests/history/redirect-js-document-location-before-load-expected.txt:
  • http/tests/history/redirect-js-form-submit-before-load-expected.txt:
  • http/tests/history/redirect-js-location-assign-before-load-expected.txt:
  • http/tests/history/redirect-js-location-before-load-expected.txt:
  • http/tests/history/redirect-js-location-href-before-load-expected.txt:
  • http/tests/loading/307-after-303-after-post-expected.txt:
  • http/tests/loading/redirect-methods-expected.txt:
  • http/tests/navigation/resources/back-send-referrer-helper.php:
  • http/tests/navigation/resources/document-location.js: (start):
  • http/tests/navigation/resources/submit-to-fragment.pl:
  • security/autocomplete-cleared-on-back.html:
  • storage/hash-change-with-xhr.js: (updateDatabase): (invokeBack): (runTest): (runTestsInner):

2010-08-13 Mihai Parparita <mihaip@chromium.org>

Reviewed by Dimitri Glazkov.

Session history should skip over JS redirects
https://bugs.webkit.org/show_bug.cgi?id=42861

Lock the back/forward list for location changes and form submits that
happen before the onload event fires that are not the result of user
gestures.

Made form submission (at the ScheduledFormSubmission level) more similar
to ScheduledURLNavigation by having it call clientRedirected too, fixing
a long-standing FIXME.

Test: fast/history/gesture-before-onload-location-href.html,
fast/history/gesture-before-onload-form-submit.html and updated
expectations for http/tests/history tests that used to fail.

  • loader/FormSubmission.cpp: (WebCore::FormSubmission::requestURL): (WebCore::FormSubmission::populateFrameLoadRequest):
  • loader/FormSubmission.h:
  • loader/RedirectScheduler.cpp: (WebCore::ScheduledFormSubmission::ScheduledFormSubmission): (WebCore::ScheduledFormSubmission::fire): (WebCore::ScheduledFormSubmission::didStartTimer): (WebCore::ScheduledFormSubmission::didStopTimer): (WebCore::RedirectScheduler::scheduleRedirect): (WebCore::RedirectScheduler::mustLockBackForwardList): (WebCore::RedirectScheduler::scheduleLocationChange): (WebCore::RedirectScheduler::scheduleFormSubmission):
  • loader/RedirectScheduler.h:
Location:
trunk
Files:
9 added
4 deleted
65 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65338 r65340  
     12010-08-13  Mihai Parparita  <mihaip@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Session history should skip over JS redirects
     6        https://bugs.webkit.org/show_bug.cgi?id=42861
     7       
     8        Lock the back/forward list for location changes and form submits that
     9        happen before the onload event fires that are not the result of user
     10        gestures.
     11       
     12        http/tests/history tests now pass, their expectations were updated
     13        accordingly. Other tests needed a setTimeout wrapper around location
     14        changes and form submits during onload, otherwise they would not
     15        generate history entries as expected anymore.
     16       
     17        * fast/css/target-fragment-match.html:
     18        * fast/dom/location-hash.html:
     19        * fast/dom/Geolocation/resources/cached-page-1.html:
     20        * fast/dom/Window/timer-resume-on-navigation-back.html:
     21        * fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt:
     22        * fast/events/pageshow-pagehide-on-back-cached-with-frames.html:
     23        * fast/forms/button-state-restore.html:
     24        * fast/forms/state-restore-to-non-autocomplete-form.html:
     25        * fast/forms/state-restore-to-non-edited-controls.html:
     26        * fast/frames/resources/cached-page-1.html:
     27        * fast/frames/resources/cached-page-2.html:
     28        * fast/harness/resources/cached-page-1.html:
     29        * fast/harness/resources/cached-page-with-data-urls.html:
     30        * fast/history/gesture-before-onload-expected.txt: Added.
     31        * fast/history/gesture-before-onload.html: Added.
     32        * fast/history/history-length.html:
     33        * fast/history/resources/gesture-before-onload-target.html: Added.
     34        * fast/history/saves-state-after-fragment-nav.html:
     35        * fast/loader/input-element-page-cache-crash.html:
     36        * fast/loader/stateobjects/document-destroyed-navigate-back.html:
     37        * fast/loader/stateobjects/pushstate-clears-forward-history.html:
     38        * fast/loader/subframe-navigate-during-main-frame-load.html:
     39        * http/tests/history/back-to-post.php:
     40        * http/tests/history/redirect-js-document-location-before-load-expected.txt:
     41        * http/tests/history/redirect-js-form-submit-before-load-expected.txt:
     42        * http/tests/history/redirect-js-location-assign-before-load-expected.txt:
     43        * http/tests/history/redirect-js-location-before-load-expected.txt:
     44        * http/tests/history/redirect-js-location-href-before-load-expected.txt:
     45        * http/tests/loading/307-after-303-after-post-expected.txt:
     46        * http/tests/loading/redirect-methods-expected.txt:
     47        * http/tests/navigation/resources/back-send-referrer-helper.php:
     48        * http/tests/navigation/resources/document-location.js:
     49        (start):
     50        * http/tests/navigation/resources/submit-to-fragment.pl:
     51        * security/autocomplete-cleared-on-back.html:
     52        * storage/hash-change-with-xhr.js:
     53        (updateDatabase):
     54        (invokeBack):
     55        (runTest):
     56        (runTestsInner):
     57       
     58       
    1592010-08-13  Sam Weinig  <sam@webkit.org>
    260
  • trunk/LayoutTests/fast/css/target-fragment-match.html

    r64411 r65340  
    1212    if (window.layoutTestController)
    1313        layoutTestController.waitUntilDone();
     14
     15    // Location changes need to happen outside the onload handler to generate history entries.
     16    setTimeout(runTest, 0);
     17}
     18
     19function runTest() {
    1420    window.location.hash ='#target-01';
    1521    document.body.offsetTop;
  • trunk/LayoutTests/fast/dom/Geolocation/resources/cached-page-1.html

    r65325 r65340  
    44    if (window.opener.reportPageOneOnload() == 1) {
    55        window.opener.debug('resources/cached-page-1.html about to navigate to resources/cached-page-2.html')
    6         location.href = 'cached-page-2.html';
     6        // Location changes need to happen outside the onload handler to generate history entries.
     7        setTimeout(function() {location.href = 'cached-page-2.html';}, 0);
    78    }
    89}
  • trunk/LayoutTests/fast/dom/Window/timer-resume-on-navigation-back.html

    r64411 r65340  
    1919      layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
    2020    }
    21     window.setTimeout("verify()", timeoutValue);
    22     timestamp = new Date().getTime();
    23     window.location.href = "data:text/html,<body onload='history.back()'></body>";
     21    // Location changes need to happen outside the onload handler to generate history entries.
     22    setTimeout(function() {
     23      window.setTimeout(verify, timeoutValue);
     24      timestamp = new Date().getTime();
     25      window.location.href = "data:text/html,<body onload='history.back()'></body>";
     26    }, 0);
    2427}
    2528
  • trunk/LayoutTests/fast/dom/location-hash.html

    r64411 r65340  
    8888        originalLocation = window.location.href;
    8989        originalHistoryLength = window.history.length;
    90      
    91         step();
     90
     91        // Location changes need to happen outside the onload handler to generate history entries.
     92        setTimeout(step, 0);
    9293    }
    9394    </script>
  • trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt

    r64411 r65340  
     1CONSOLE MESSAGE: line 20: ***Top level frame being parsed for the initial page load***
     2CONSOLE MESSAGE: line 20: Subsubframe window.onload
     3CONSOLE MESSAGE: line 20: Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = false
     4CONSOLE MESSAGE: line 20: Subframe window.onload
     5CONSOLE MESSAGE: line 20: Subframe window.onpageshow, target = [object HTMLDocument], persisted = false
     6CONSOLE MESSAGE: line 20: Main frame window.onload
     7CONSOLE MESSAGE: line 20: Main frame window.onpageshow, target = [object HTMLDocument], persisted = false
     8CONSOLE MESSAGE: line 20: ***Navigating top-level frame to a page that will immediately navigate back to this one***
     9CONSOLE MESSAGE: line 20: Main frame window.onpagehide, target = [object HTMLDocument], persisted = true
     10CONSOLE MESSAGE: line 20: Subframe window.onpagehide, target = [object HTMLDocument], persisted = true
     11CONSOLE MESSAGE: line 20: Subsubframe window.onpagehide, target = [object HTMLDocument], persisted = true
     12CONSOLE MESSAGE: line 20: Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = true
     13CONSOLE MESSAGE: line 20: Subframe window.onpageshow, target = [object HTMLDocument], persisted = true
     14CONSOLE MESSAGE: line 20: Main frame window.onpageshow, target = [object HTMLDocument], persisted = true
    115Test pageshow/pagehide event behavior when navigating away from a page with frames, putting the page in the page cache, then back to it.
    2 ***Top level frame being parsed for the initial page load***
    3 Subsubframe window.onload
    4 Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = false
    5 Subframe window.onload
    6 Subframe window.onpageshow, target = [object HTMLDocument], persisted = false
    7 Main frame window.onload
    8 Main frame window.onpageshow, target = [object HTMLDocument], persisted = false
    9 ***Navigating top-level frame to a page that will immediately navigate back to this one***
    10 Main frame window.onpagehide, target = [object HTMLDocument], persisted = true
    11 Subframe window.onpagehide, target = [object HTMLDocument], persisted = true
    12 Subsubframe window.onpagehide, target = [object HTMLDocument], persisted = true
    13 Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = true
    14 Subframe window.onpageshow, target = [object HTMLDocument], persisted = true
    15 Main frame window.onpageshow, target = [object HTMLDocument], persisted = true
    1616
  • trunk/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames.html

    r64411 r65340  
    1515function log(message)
    1616{
    17     var log = document.getElementById("log");
    18     log.innerHTML += message + "\n";
     17    // Logging to the console instead of the "log" DIV in the DOM because
     18    // otherwise we trigger the assert mentioned at http://webkit.org/b/43152
     19    // (since we log during pagehide)
     20    console.log(message);
    1921}
    2022
     
    3234    } else {
    3335        log("***Navigating top-level frame to a page that will immediately navigate back to this one***");
    34         window.location.href = "data:text/html,<script>history.back();</scr" + "ipt>";
     36        // Location changes need to happen outside the onload handler to generate history entries.
     37        setTimeout(function() {window.location.href = "data:text/html,<script>history.back();</scr" + "ipt>";}, 0);
    3538    }
    3639}
  • trunk/LayoutTests/fast/forms/button-state-restore.html

    r57013 r65340  
    3232
    3333            var form = document.getElementById("form");
    34             form.submit();
     34           
     35            // Submit form in a timeout to make sure that we create a new back/forward list item.           
     36            setTimeout(function() {form.submit();}, 0);
    3537        }
    3638    </script>
  • trunk/LayoutTests/fast/forms/state-restore-to-non-autocomplete-form.html

    r57012 r65340  
    3939    document.getElementById('textarea2').value = 'good';
    4040    document.getElementById('select2').value = 'BSD';
    41     document.getElementById('form2').submit();
     41    // Submit form in a timeout to make sure that we create a new back/forward list item.           
     42    setTimeout(function() {document.getElementById('form2').submit();}, 0);
    4243} else {
    4344    // Second visit.
  • trunk/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html

    r57013 r65340  
    3838
    3939    document.getElementById('text1').value = 'edit';
    40     document.getElementById('form1').submit();
     40    // Submit form in a timeout to make sure that we create a new back/forward list item.           
     41    setTimeout(function() {document.getElementById('form1').submit();}, 0);
    4142} else {
    4243    // Second visit.
  • trunk/LayoutTests/fast/frames/resources/cached-page-1.html

    r64411 r65340  
    1818
    1919    window.opener.log("page-1, about to navigate to page-2.")
    20     location.href = "cached-page-2.html";
     20    // Location changes need to happen outside the onload handler to generate history entries.
     21    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
    2122}
    2223
  • trunk/LayoutTests/fast/frames/resources/cached-page-2.html

    r64411 r65340  
    2020
    2121    window.opener.log("page-2, about to navigate to page-3.")
    22     location.href = "cached-page-3.html";
     22    // Location changes need to happen outside the onload handler to generate history entries.
     23    setTimeout(function() {location.href = "cached-page-3.html";}, 0);
    2324}
    2425</script>
  • trunk/LayoutTests/fast/harness/resources/cached-page-1.html

    r64411 r65340  
    2323
    2424    window.opener.log("page-1, about to navigate to page-2.")
    25     location.href = "cached-page-2.html";
     25    // Location changes need to happen outside the onload handler to generate history entries.
     26    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
    2627}
    2728</script>
  • trunk/LayoutTests/fast/harness/resources/cached-page-with-data-urls.html

    r64411 r65340  
    1919
    2020    window.opener.log("page with data urls, about to navigate to page-2.")
    21     location.href = "cached-page-2.html";
     21    // Location changes need to happen outside the onload handler to generate history entries.
     22    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
    2223}
    2324</script>
  • trunk/LayoutTests/fast/history/history-length.html

    r64411 r65340  
    99    }
    1010  }
    11   // This test advances history by 2 pages, then navigates back one, and
    12   // records history.length.  We expect history.length to indicate the total
    13   // length of session history.  At the end of the test, it should be 2 greater
    14   // than it was at the start of the test.
    15   switch (sessionStorage.testStage++) {
    16   case 0:
    17     sessionStorage.initialLength = history.length;
    18     location = "?a";
    19     break;
    20   case 1:
    21     location = "?b";
    22     break;
    23   case 2:
    24     history.back();
    25     break;
    26   case 3:
    27     if (history.length == (sessionStorage.initialLength - 0) + 2)
    28       document.body.innerHTML = "PASS";
    29     else
    30       document.body.innerHTML = "FAIL: initialLength=" + sessionStorage.initialLength + ", history.length=" + history.length;
    31     if (window.layoutTestController)
    32       layoutTestController.notifyDone();
    33     break;
    34   }
     11
     12  // Location changes need to happen outside the onload handler to generate history entries.
     13  setTimeout(function() {
     14    // This test advances history by 2 pages, then navigates back one, and
     15    // records history.length.  We expect history.length to indicate the total
     16    // length of session history.  At the end of the test, it should be 2 greater
     17    // than it was at the start of the test.
     18    switch (sessionStorage.testStage++) {
     19    case 0:
     20      sessionStorage.initialLength = history.length;
     21      location = "?a";
     22      break;
     23    case 1:
     24      location = "?b";
     25      break;
     26    case 2:
     27      history.back();
     28      break;
     29    case 3:
     30      if (history.length == (sessionStorage.initialLength - 0) + 2)
     31        document.body.innerHTML = "PASS";
     32      else
     33        document.body.innerHTML = "FAIL: initialLength=" + sessionStorage.initialLength + ", history.length=" + history.length;
     34      if (window.layoutTestController)
     35        layoutTestController.notifyDone();
     36      break;
     37    }
     38  }, 0);
    3539}
    3640onunload = function() {
  • trunk/LayoutTests/fast/history/resources/gesture-before-onload-target.html

    r65339 r65340  
    1515{
    1616    var expected = parseInt(location.hash.slice(1));
    17     var actual = layoutTestController.webHistoryItemCount + 1; // Add one to include the referring page, which loaded before we started recording history.
     17    var actual = history.length;
    1818    if (actual === expected)
    1919        log("PASS: History item count should be " + expected + " and is.");
     
    2828        layoutTestController.dumpBackForwardList();
    2929        layoutTestController.notifyDone();
     30    } else {
     31        testHistoryItemCount();
    3032    }
    3133}, false);
  • trunk/LayoutTests/fast/history/saves-state-after-fragment-nav.html

    r64411 r65340  
    3131      layoutTestController.waitUntilDone();
    3232    }
    33     navigateToHash(field);
    34     navigateAwayAndBack();
     33    // Location changes need to happen outside the onload handler to generate history entries.
     34    setTimeout(function() {
     35      navigateToHash(field);
     36      navigateAwayAndBack();
     37    }, 0);
    3538  } else {
    3639    document.body.innerHTML = (field.value == '') ? 'FAIL' : 'PASS';
  • trunk/LayoutTests/fast/loader/input-element-page-cache-crash.html

    r64411 r65340  
    1414    input.setAttribute("autocomplete", "on");
    1515    input.parentNode.removeChild(input);
    16    
    17     window.location = "data:text/html,<script>history.back();</scrip" + "t>";
     16
     17    // Location changes need to happen outside the onload handler to generate history entries.
     18    setTimeout(function() {window.location = "data:text/html,<script>history.back();</scrip" + "t>";}, 0);
    1819}
    1920
  • trunk/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html

    r64411 r65340  
    3434function loaded()
    3535{
    36     if (!sessionStorage.stage)
    37         runFirstStageOfTest();
    38     else if (sessionStorage.stage == 2)
     36    if (!sessionStorage.stage) {
     37        // Location changes need to happen outside the onload handler to generate history entries.
     38        setTimeout(runFirstStageOfTest, 0);
     39    } else if (sessionStorage.stage == 2)
    3940        runSecondStageOfTest();
    4041    else if (sessionStorage.stage == 3)
  • trunk/LayoutTests/fast/loader/stateobjects/pushstate-clears-forward-history.html

    r64411 r65340  
    99    }
    1010  }
    11   switch (sessionStorage.testStage++) {
    12   case 0:
    13     location = "?a";
    14     break;
    15   case 1:
    16     location = "?b";
    17     break;
    18   case 2:
    19     history.back();
    20     break;
    21   case 3:
    22     history.pushState(null, null);
    23     if (window.layoutTestController)
    24       layoutTestController.notifyDone();
    25     break;
    26   }
     11
     12  // Location changes need to happen outside the onload handler to generate history entries.
     13  setTimeout(function() {
     14      switch (sessionStorage.testStage++) {
     15      case 0:
     16        location = "?a";
     17        break;
     18      case 1:
     19        location = "?b";
     20        break;
     21      case 2:
     22        history.back();
     23        break;
     24      case 3:
     25        history.pushState(null, null);
     26        if (window.layoutTestController)
     27          layoutTestController.notifyDone();
     28        break;
     29      }
     30    }, 0);
    2731}
    2832onunload = function() {
  • trunk/LayoutTests/fast/loader/subframe-navigate-during-main-frame-load.html

    r64411 r65340  
    1010        layoutTestController.waitUntilDone();
    1111    }
    12    
    13     location='resources/subframe-navigate-during-main-frame-load2.html';
     12
     13    // Location changes need to happen outside the onload handler to generate history entries.
     14    setTimeout(function() {location='resources/subframe-navigate-during-main-frame-load2.html';}, 0);
    1415}
    1516
  • trunk/LayoutTests/http/tests/history/back-to-post.php

    r47335 r65340  
    1515</form>
    1616<script>
     17
     18function submitForm()
     19{
     20    // Submit form in a timeout to make sure that we create a new back/forward list item.
     21    setTimeout(function() {document.forms[0].submit()}, 0);
     22}
     23
    1724if (window.layoutTestController) {
    1825    layoutTestController.dumpAsText();
     
    2633if (document.location.search == "") {
    2734    window.name = ""; // Use window.name to communicate between steps.
    28     document.forms[0].submit();
     35    submitForm();
    2936} else if (document.location.search == "?1") {
    3037    if (window.name == "finish") {
     
    3542    } else {
    3643        document.forms[0].action = "?2";
    37         document.forms[0].submit();
     44        submitForm();
    3845    }
    3946} else {
  • trunk/LayoutTests/http/tests/history/redirect-200-refresh-0-seconds.pl

    r40424 r65340  
    1313<script>
    1414if (window.layoutTestController) {
    15     layoutTestController.keepWebHistory();
     15    layoutTestController.clearBackForwardList();
    1616    layoutTestController.waitUntilDone();
    1717}
  • trunk/LayoutTests/http/tests/history/redirect-200-refresh-2-seconds.pl

    r40424 r65340  
    1313<script>
    1414if (window.layoutTestController) {
    15     layoutTestController.keepWebHistory();
     15    layoutTestController.clearBackForwardList();
    1616    layoutTestController.waitUntilDone();
    1717}
  • trunk/LayoutTests/http/tests/history/redirect-301-expected.txt

    r40424 r65340  
    11This page is the target of a redirect.
    22
    3 PASS: History item count should be 1 and is.
     3PASS: History item count should be 2 and is.
    44
    55
    66============== Back Forward List ==============
    7 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
     7        http://127.0.0.1:8000/history/redirect-301.html  **nav target**
     8curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#2  **nav target**
    89===============================================
  • trunk/LayoutTests/http/tests/history/redirect-302-expected.txt

    r40424 r65340  
    11This page is the target of a redirect.
    22
    3 PASS: History item count should be 1 and is.
     3PASS: History item count should be 2 and is.
    44
    55
    66============== Back Forward List ==============
    7 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
     7        http://127.0.0.1:8000/history/redirect-302.html  **nav target**
     8curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#2  **nav target**
    89===============================================
  • trunk/LayoutTests/http/tests/history/redirect-303-expected.txt

    r40424 r65340  
    11This page is the target of a redirect.
    22
    3 PASS: History item count should be 1 and is.
     3PASS: History item count should be 2 and is.
    44
    55
    66============== Back Forward List ==============
    7 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
     7        http://127.0.0.1:8000/history/redirect-303.html  **nav target**
     8curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#2  **nav target**
    89===============================================
  • trunk/LayoutTests/http/tests/history/redirect-307-expected.txt

    r40424 r65340  
    11This page is the target of a redirect.
    22
    3 PASS: History item count should be 1 and is.
     3PASS: History item count should be 2 and is.
    44
    55
    66============== Back Forward List ==============
    7 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
     7        http://127.0.0.1:8000/history/redirect-307.html  **nav target**
     8curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#2  **nav target**
    89===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-document-location-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-document-location-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt

    r64411 r65340  
    11This page is the target of a redirect.
    22
    3 FAIL: History item count should be 1 but instead is 2.
     3PASS: History item count should be 1 and is.
    44
    55
    66============== Back Forward List ==============
    7         http://127.0.0.1:8000/history/redirect-js-document-location-before-load.html  **nav target**
    87curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
    98===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-document-location-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-form-submit-0-seconds.html

    r53356 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-form-submit-2-seconds.html

    r53356 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-form-submit-before-load-expected.txt

    r40424 r65340  
    11This page is the target of a redirect.
    22
    3 FAIL: History item count should be 1 but instead is 2.
     3PASS: History item count should be 1 and is.
    44
    55
    66============== Back Forward List ==============
    7         http://127.0.0.1:8000/history/redirect-js-form-submit-before-load.html  **nav target**
    87curr->  http://127.0.0.1:8000/history/resources/redirect-target.html?#1  **nav target**
    98===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-form-submit-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-assign-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-assign-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt

    r64411 r65340  
    11This page is the target of a redirect.
    22
    3 FAIL: History item count should be 1 but instead is 2.
     3PASS: History item count should be 1 and is.
    44
    55
    66============== Back Forward List ==============
    7         http://127.0.0.1:8000/history/redirect-js-location-assign-before-load.html  **nav target**
    87curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
    98===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-location-assign-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt

    r64411 r65340  
    11This page is the target of a redirect.
    22
    3 FAIL: History item count should be 1 but instead is 2.
     3PASS: History item count should be 1 and is.
    44
    55
    66============== Back Forward List ==============
    7         http://127.0.0.1:8000/history/redirect-js-location-before-load.html  **nav target**
    87curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
    98===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-location-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-href-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-href-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt

    r64411 r65340  
    11This page is the target of a redirect.
    22
    3 FAIL: History item count should be 1 but instead is 2.
     3PASS: History item count should be 1 and is.
    44
    55
    66============== Back Forward List ==============
    7         http://127.0.0.1:8000/history/redirect-js-location-href-before-load.html  **nav target**
    87curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
    98===============================================
  • trunk/LayoutTests/http/tests/history/redirect-js-location-href-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-replace-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-replace-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-js-location-replace-before-load.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-meta-refresh-0-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/redirect-meta-refresh-2-seconds.html

    r40424 r65340  
    55<script>
    66if (window.layoutTestController) {
    7     layoutTestController.keepWebHistory();
     7    layoutTestController.clearBackForwardList();
    88    layoutTestController.waitUntilDone();
    99}
  • trunk/LayoutTests/http/tests/history/resources/redirect-target.html

    r40424 r65340  
    1515{
    1616    var expected = parseInt(location.hash.slice(1));
    17     var actual = layoutTestController.webHistoryItemCount + 1; // Add one to include the referring page, which loaded before we started recording history.
     17    var actual = history.length;
    1818    if (actual === expected)
    1919        log("PASS: History item count should be " + expected + " and is.");
  • trunk/LayoutTests/http/tests/loading/307-after-303-after-post-expected.txt

    r55157 r65340  
    22main frame - didCommitLoadForFrame
    33main frame - didFinishDocumentLoadForFrame
     4main frame - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/post-to-303-target.php
    45main frame - didHandleOnloadEventsForFrame
    56main frame - didFinishLoadForFrame
     
    1213main frame - didReceiveServerRedirectForProvisionalLoadForFrame
    1314http://127.0.0.1:8000/loading/resources/post-to-303-target.php - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/loading/resources/307-post-output-target.php, http status code 200>
     15main frame - didCancelClientRedirectForFrame
    1416main frame - didCommitLoadForFrame
    1517main frame - didFinishDocumentLoadForFrame
  • trunk/LayoutTests/http/tests/loading/redirect-methods-expected.txt

    r48953 r65340  
    2020frame "0" - didCommitLoadForFrame
    2121frame "0" - didFinishDocumentLoadForFrame
     22frame "0" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    2223frame "0" - didHandleOnloadEventsForFrame
    2324frame "0" - didFinishLoadForFrame
     
    2829frame "0" - didReceiveServerRedirectForProvisionalLoadForFrame
    2930http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true, http status code 200>
     31frame "0" - didCancelClientRedirectForFrame
    3032frame "0" - didCommitLoadForFrame
    3133frame "0" - didFinishDocumentLoadForFrame
     
    4850frame "1" - didCommitLoadForFrame
    4951frame "1" - didFinishDocumentLoadForFrame
     52frame "1" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    5053frame "1" - didHandleOnloadEventsForFrame
    5154frame "1" - didFinishLoadForFrame
     
    5659frame "1" - didReceiveServerRedirectForProvisionalLoadForFrame
    5760http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true, http status code 200>
     61frame "1" - didCancelClientRedirectForFrame
    5862frame "1" - didCommitLoadForFrame
    5963frame "1" - didFinishDocumentLoadForFrame
     
    7680frame "2" - didCommitLoadForFrame
    7781frame "2" - didFinishDocumentLoadForFrame
     82frame "2" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    7883frame "2" - didHandleOnloadEventsForFrame
    7984frame "2" - didFinishLoadForFrame
     
    8489frame "2" - didReceiveServerRedirectForProvisionalLoadForFrame
    8590http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true, http status code 200>
     91frame "2" - didCancelClientRedirectForFrame
    8692frame "2" - didCommitLoadForFrame
    8793frame "2" - didFinishDocumentLoadForFrame
     
    104110frame "3" - didCommitLoadForFrame
    105111frame "3" - didFinishDocumentLoadForFrame
     112frame "3" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    106113frame "3" - didHandleOnloadEventsForFrame
    107114frame "3" - didFinishLoadForFrame
     
    112119frame "3" - didReceiveServerRedirectForProvisionalLoadForFrame
    113120http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true, http status code 200>
     121frame "3" - didCancelClientRedirectForFrame
    114122frame "3" - didCommitLoadForFrame
    115123frame "3" - didFinishDocumentLoadForFrame
  • trunk/LayoutTests/http/tests/navigation/resources/back-send-referrer-helper.php

    r40132 r65340  
    1919<script>
    2020    if (window.name == 1) {
    21         // Navigate once more to add a history entry.
    22         document.loopback.submit();
     21        // Navigate once more (in a timeout) to add a history entry.
     22        setTimeout(function() {document.loopback.submit();}, 0);
    2323    } else if (window.name == 2) {
    2424        history.go(-1);
  • trunk/LayoutTests/http/tests/navigation/resources/document-location.js

    r64411 r65340  
    88      layoutTestController.waitUntilDone();
    99
    10       runTest();
     10      // Location changes need to happen outside the onload handler to generate history entries.
     11      setTimeout(runTest, 0);
    1112    } else {
    1213      // loaded the ?1 navigation
  • trunk/LayoutTests/http/tests/navigation/resources/submit-to-fragment.pl

    r61207 r65340  
    2323  switch (sessionStorage.stage++) {
    2424  case 1:
    25     document.forms[0].submit();
     25    // Submit form in a timeout to make sure that we create a new back/forward list item.
     26    setTimeout(function() {document.forms[0].submit();}, 0);
    2627    break;
    2728  case 2:
  • trunk/LayoutTests/security/autocomplete-cleared-on-back.html

    r64411 r65340  
    2020        document.getElementById("firstInput").value = "SuperSeekritValue";
    2121        document.getElementById("secondInput").value = "SuperSeekritValue";
    22         window.location = "resources/autocomplete-cleared-on-back2.html";
     22        // Location changes need to happen outside the onload handler to generate history entries.
     23        setTimeout(function() {window.location = "resources/autocomplete-cleared-on-back2.html";}, 0);
    2324        return;
    2425    }
  • trunk/LayoutTests/storage/hash-change-with-xhr.js

    r64411 r65340  
    8282function runTest()
    8383{
     84    // Location changes need to happen outside the onload handler to generate history entries.
     85    setTimeout(runTestsInner, 0);
     86}
     87
     88function runTestsInner()
     89{
    8490    backIterations = 10;
    8591    consecutiveFailures = 0;
  • trunk/WebCore/ChangeLog

    r65336 r65340  
     12010-08-13  Mihai Parparita  <mihaip@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Session history should skip over JS redirects
     6        https://bugs.webkit.org/show_bug.cgi?id=42861
     7       
     8        Lock the back/forward list for location changes and form submits that
     9        happen before the onload event fires that are not the result of user
     10        gestures.
     11       
     12        Made form submission (at the ScheduledFormSubmission level) more similar
     13        to ScheduledURLNavigation by having it call clientRedirected too, fixing
     14        a long-standing FIXME.
     15
     16        Test: fast/history/gesture-before-onload-location-href.html,
     17        fast/history/gesture-before-onload-form-submit.html and updated
     18        expectations for http/tests/history tests that used to fail.
     19
     20        * loader/FormSubmission.cpp:
     21        (WebCore::FormSubmission::requestURL):
     22        (WebCore::FormSubmission::populateFrameLoadRequest):
     23        * loader/FormSubmission.h:
     24        * loader/RedirectScheduler.cpp:
     25        (WebCore::ScheduledFormSubmission::ScheduledFormSubmission):
     26        (WebCore::ScheduledFormSubmission::fire):
     27        (WebCore::ScheduledFormSubmission::didStartTimer):
     28        (WebCore::ScheduledFormSubmission::didStopTimer):
     29        (WebCore::RedirectScheduler::scheduleRedirect):
     30        (WebCore::RedirectScheduler::mustLockBackForwardList):
     31        (WebCore::RedirectScheduler::scheduleLocationChange):
     32        (WebCore::RedirectScheduler::scheduleFormSubmission):
     33        * loader/RedirectScheduler.h:
     34
    1352010-08-13  Leandro Pereira  <leandro@profusion.mobi>
    236
  • trunk/WebCore/loader/FormSubmission.cpp

    r63999 r65340  
    180180}
    181181
     182KURL FormSubmission::requestURL() const
     183{
     184    if (m_method == FormSubmission::PostMethod)
     185        return m_action;
     186
     187    KURL requestURL(m_action);
     188    requestURL.setQuery(m_formData->flattenToString());   
     189    return requestURL;
     190}
     191
    182192void FormSubmission::populateFrameLoadRequest(FrameLoadRequest& frameRequest)
    183193{
     
    188198        frameRequest.resourceRequest().setHTTPReferrer(m_referrer);
    189199
    190     if (m_method == FormSubmission::GetMethod)
    191         m_action.setQuery(m_formData->flattenToString());
    192     else {
     200    if (m_method == FormSubmission::PostMethod) {
    193201        frameRequest.resourceRequest().setHTTPMethod("POST");
    194202        frameRequest.resourceRequest().setHTTPBody(m_formData);
     
    201209    }
    202210
    203     frameRequest.resourceRequest().setURL(m_action);
     211    frameRequest.resourceRequest().setURL(requestURL());
    204212    FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), m_origin);
    205213}
  • trunk/WebCore/loader/FormSubmission.h

    r63999 r65340  
    8686
    8787    void populateFrameLoadRequest(FrameLoadRequest&);
     88   
     89    KURL requestURL() const;
    8890
    8991    Method method() const { return m_method; }
  • trunk/WebCore/loader/RedirectScheduler.cpp

    r64411 r65340  
    176176        : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true)
    177177        , m_submission(submission)
    178         , m_wasProcessingUserGesture(UserGestureIndicator::processingUserGesture())
     178        , m_haveToldClient(false)
    179179    {
    180180        ASSERT(m_submission->state());
     
    183183    virtual void fire(Frame* frame)
    184184    {
    185         UserGestureIndicator gestureIndicator(m_wasProcessingUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
    186 
    187185        // The submitForm function will find a target frame before using the redirection timer.
    188186        // Now that the timer has fired, we need to repeat the security check which normally is done when
     
    195193        frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackForwardList(), m_submission->event(), m_submission->state(), SendReferrer);
    196194    }
    197 
    198     // FIXME: Implement didStartTimer? It would make sense to report form
    199     // submissions as client redirects too. But we didn't do that in the past
    200     // when form submission used a separate delay mechanism, so doing it will
    201     // be a behavior change.
     195   
     196    virtual void didStartTimer(Frame* frame, Timer<RedirectScheduler>* timer)
     197    {
     198        if (m_haveToldClient)
     199            return;
     200        m_haveToldClient = true;
     201        frame->loader()->clientRedirected(m_submission->requestURL(), delay(), currentTime() + timer->nextFireInterval(), lockBackForwardList());
     202    }
     203
     204    virtual void didStopTimer(Frame* frame, bool newLoadInProgress)
     205    {
     206        if (!m_haveToldClient)
     207            return;
     208        frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);
     209    }
    202210
    203211private:
    204212    RefPtr<FormSubmission> m_submission;
    205     bool m_wasProcessingUserGesture;
     213    bool m_haveToldClient;
    206214};
    207215
     
    241249        return;
    242250
    243     // We want a new history item if the refresh timeout is > 1 second.
     251    // We want a new back/forward list item if the refresh timeout is > 1 second.
    244252    if (!m_redirect || delay <= m_redirect->delay())
    245253        schedule(new ScheduledRedirect(delay, url, true, delay <= 1, false));
    246254}
    247255
    248 bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame)
    249 {
     256bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame, bool wasUserGesture)
     257{
     258    // Non-user navigation before the page has loaded should not create a new back/forward item.
     259    // See https://webkit.org/b/42861 for the original motivation for this.   
     260    if (!wasUserGesture && targetFrame->loader()->documentLoader() && targetFrame->loader()->documentLoader()->isLoadingInAPISense())
     261        return true;
     262   
    250263    // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
    251264    // The definition of "during load" is any time before all handlers for the load event have been run.
    252265    // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.
    253 
    254266    for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {
    255267        Document* document = ancestor->document();
     
    267279        return;
    268280
    269     lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
     281    lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame, wasUserGesture);
    270282
    271283    FrameLoader* loader = m_frame->loader();
     
    301313    // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this.
    302314
    303     bool lockBackForwardList = mustLockBackForwardList(m_frame) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
     315    bool lockBackForwardList = mustLockBackForwardList(m_frame, UserGestureIndicator::processingUserGesture()) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
    304316
    305317    schedule(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad));
  • trunk/WebCore/loader/RedirectScheduler.h

    r65021 r65340  
    7171    void schedule(PassOwnPtr<ScheduledNavigation>);
    7272
    73     static bool mustLockBackForwardList(Frame* targetFrame);
     73    static bool mustLockBackForwardList(Frame* targetFrame, bool mustLockIfDuringLoad);
    7474
    7575    Frame* m_frame;
     
    8080} // namespace WebCore
    8181
    82 #endif // FrameLoader_h
     82#endif // RedirectScheduler_h
Note: See TracChangeset for help on using the changeset viewer.