[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 11:37:22 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit c50ed1a4f3ea917cef013d2572224bb80290b1a3
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jul 31 05:39:24 2010 +0000

    2010-07-30  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Session history should skip over JS redirects
            https://bugs.webkit.org/show_bug.cgi?id=42861
    
            Lock the back/forward list for location changes that happen before the
            onload event fires that are not the result of user gestures.
    
            http/tests/history tests now pass, their expectatiosn were updated
            accordingly. Other tests needed a setTimeout wrapper around location
            changes during onload, otherwise they would not generate history
            entries as expected anymore.
    
            * fast/css/target-fragment-match.html:
            * fast/dom/Window/timer-resume-on-navigation-back.html:
            * fast/dom/location-hash.html:
            * fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt:
            * fast/events/pageshow-pagehide-on-back-cached-with-frames.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/redirect-js-document-location-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/navigation/resources/document-location.js:
            (start):
            * security/autocomplete-cleared-on-back.html:
            * storage/hash-change-with-xhr.js:
            (updateDatabase):
            (invokeBack):
            (runTest):
            (runTestsInner):
    2010-07-30  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Session history should skip over JS redirects
            https://bugs.webkit.org/show_bug.cgi?id=42861
    
            Lock the back/forward list for location changes that happen before the
            onload event fires that are not the result of user gestures.
    
            Test: fast/history/gesture-before-onload.html and updated expectations
            for http/tests/history tests that used to fail.
    
            * loader/RedirectScheduler.cpp:
            (WebCore::RedirectScheduler::scheduleRedirect):
            (WebCore::RedirectScheduler::mustLockBackForwardList):
            (WebCore::RedirectScheduler::scheduleLocationChange):
            (WebCore::RedirectScheduler::scheduleFormSubmission):
            * loader/RedirectScheduler.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64408 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4e80731..eeb7fb3 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,49 @@
+2010-07-30  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Session history should skip over JS redirects
+        https://bugs.webkit.org/show_bug.cgi?id=42861
+        
+        Lock the back/forward list for location changes that happen before the 
+        onload event fires that are not the result of user gestures.
+        
+        http/tests/history tests now pass, their expectatiosn were updated 
+        accordingly. Other tests needed a setTimeout wrapper around location
+        changes during onload, otherwise they would not generate history 
+        entries as expected anymore.
+        
+        * fast/css/target-fragment-match.html:
+        * fast/dom/Window/timer-resume-on-navigation-back.html:
+        * fast/dom/location-hash.html:
+        * fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt:
+        * fast/events/pageshow-pagehide-on-back-cached-with-frames.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/redirect-js-document-location-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/navigation/resources/document-location.js:
+        (start):
+        * security/autocomplete-cleared-on-back.html:
+        * storage/hash-change-with-xhr.js:
+        (updateDatabase):
+        (invokeBack):
+        (runTest):
+        (runTestsInner):
+
 2010-07-30  Matthew Delaney  <mdelaney at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/css/target-fragment-match.html b/LayoutTests/fast/css/target-fragment-match.html
index 9e99d47..a2b697f 100644
--- a/LayoutTests/fast/css/target-fragment-match.html
+++ b/LayoutTests/fast/css/target-fragment-match.html
@@ -11,6 +11,12 @@ function test()
 {
     if (window.layoutTestController)
         layoutTestController.waitUntilDone();
+
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(runTest, 0);
+}
+
+function runTest() {
     window.location.hash ='#target-01';
     document.body.offsetTop;
     window.history.back(); // This queues up a navigation, so we need to delay the call to notifyDone.
diff --git a/LayoutTests/fast/dom/Window/timer-resume-on-navigation-back.html b/LayoutTests/fast/dom/Window/timer-resume-on-navigation-back.html
index f7ea76b..b46fb25 100644
--- a/LayoutTests/fast/dom/Window/timer-resume-on-navigation-back.html
+++ b/LayoutTests/fast/dom/Window/timer-resume-on-navigation-back.html
@@ -18,9 +18,12 @@ function runTest() {
       layoutTestController.waitUntilDone();
       layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
     }
-    window.setTimeout("verify()", timeoutValue);
-    timestamp = new Date().getTime();
-    window.location.href = "data:text/html,<body onload='history.back()'></body>";
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {
+      window.setTimeout(verify, timeoutValue);
+      timestamp = new Date().getTime();
+      window.location.href = "data:text/html,<body onload='history.back()'></body>";
+    }, 0);
 }
 
 </script>
diff --git a/LayoutTests/fast/dom/location-hash.html b/LayoutTests/fast/dom/location-hash.html
index b26e906..f580f52 100644
--- a/LayoutTests/fast/dom/location-hash.html
+++ b/LayoutTests/fast/dom/location-hash.html
@@ -87,8 +87,9 @@
         numErrors = 0;
         originalLocation = window.location.href;
         originalHistoryLength = window.history.length;
-     
-        step();
+
+        // Location changes need to happen outside the onload handler to generate history entries.
+        setTimeout(step, 0);
     }
     </script>
 </head>
diff --git a/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt b/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt
index 1ee69a1..94f24e6 100644
--- a/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt
+++ b/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames-expected.txt
@@ -1,16 +1,16 @@
+CONSOLE MESSAGE: line 20: ***Top level frame being parsed for the initial page load***
+CONSOLE MESSAGE: line 20: Subsubframe window.onload
+CONSOLE MESSAGE: line 20: Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = false
+CONSOLE MESSAGE: line 20: Subframe window.onload
+CONSOLE MESSAGE: line 20: Subframe window.onpageshow, target = [object HTMLDocument], persisted = false
+CONSOLE MESSAGE: line 20: Main frame window.onload
+CONSOLE MESSAGE: line 20: Main frame window.onpageshow, target = [object HTMLDocument], persisted = false
+CONSOLE MESSAGE: line 20: ***Navigating top-level frame to a page that will immediately navigate back to this one***
+CONSOLE MESSAGE: line 20: Main frame window.onpagehide, target = [object HTMLDocument], persisted = true
+CONSOLE MESSAGE: line 20: Subframe window.onpagehide, target = [object HTMLDocument], persisted = true
+CONSOLE MESSAGE: line 20: Subsubframe window.onpagehide, target = [object HTMLDocument], persisted = true
+CONSOLE MESSAGE: line 20: Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = true
+CONSOLE MESSAGE: line 20: Subframe window.onpageshow, target = [object HTMLDocument], persisted = true
+CONSOLE MESSAGE: line 20: Main frame window.onpageshow, target = [object HTMLDocument], persisted = true
 Test pageshow/pagehide event behavior when navigating away from a page with frames, putting the page in the page cache, then back to it.
-***Top level frame being parsed for the initial page load***
-Subsubframe window.onload
-Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = false
-Subframe window.onload
-Subframe window.onpageshow, target = [object HTMLDocument], persisted = false
-Main frame window.onload
-Main frame window.onpageshow, target = [object HTMLDocument], persisted = false
-***Navigating top-level frame to a page that will immediately navigate back to this one***
-Main frame window.onpagehide, target = [object HTMLDocument], persisted = true
-Subframe window.onpagehide, target = [object HTMLDocument], persisted = true
-Subsubframe window.onpagehide, target = [object HTMLDocument], persisted = true
-Subsubframe window.onpageshow, target = [object HTMLDocument], persisted = true
-Subframe window.onpageshow, target = [object HTMLDocument], persisted = true
-Main frame window.onpageshow, target = [object HTMLDocument], persisted = true
 
diff --git a/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames.html b/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames.html
index 72e1658..489c090 100644
--- a/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames.html
+++ b/LayoutTests/fast/events/pageshow-pagehide-on-back-cached-with-frames.html
@@ -14,8 +14,10 @@ if (window.layoutTestController) {
 
 function log(message)
 {
-    var log = document.getElementById("log");
-    log.innerHTML += message + "\n";
+    // Logging to the console instead of the "log" DIV in the DOM because
+    // otherwise we trigger the assert mentioned at http://webkit.org/b/43152
+    // (since we log during pagehide)
+    console.log(message);
 }
 
 log("***Top level frame being parsed for the initial page load***");
@@ -31,7 +33,8 @@ window.onpageshow = function(evt) {
             layoutTestController.notifyDone();
     } else {
         log("***Navigating top-level frame to a page that will immediately navigate back to this one***");
-        window.location.href = "data:text/html,<script>history.back();</scr" + "ipt>";
+        // Location changes need to happen outside the onload handler to generate history entries.
+        setTimeout(function() {window.location.href = "data:text/html,<script>history.back();</scr" + "ipt>";}, 0);
     }
 }
 
diff --git a/LayoutTests/fast/frames/resources/cached-page-1.html b/LayoutTests/fast/frames/resources/cached-page-1.html
index 610c8d4..2715102 100644
--- a/LayoutTests/fast/frames/resources/cached-page-1.html
+++ b/LayoutTests/fast/frames/resources/cached-page-1.html
@@ -17,7 +17,8 @@ function loadNext() {
     intervalId = setInterval(endTest, 100);
 
     window.opener.log("page-1, about to navigate to page-2.")
-    location.href = "cached-page-2.html";
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
 }
 
 // This unload handler exists just to make sure this page is not added
diff --git a/LayoutTests/fast/frames/resources/cached-page-2.html b/LayoutTests/fast/frames/resources/cached-page-2.html
index fd4f272..b159242 100644
--- a/LayoutTests/fast/frames/resources/cached-page-2.html
+++ b/LayoutTests/fast/frames/resources/cached-page-2.html
@@ -19,7 +19,8 @@ function loadNext() {
     intervalId = setInterval(goBack, 20);
 
     window.opener.log("page-2, about to navigate to page-3.")
-    location.href = "cached-page-3.html";
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {location.href = "cached-page-3.html";}, 0);
 }
 </script>
 <body onload="loadNext()">
diff --git a/LayoutTests/fast/harness/resources/cached-page-1.html b/LayoutTests/fast/harness/resources/cached-page-1.html
index 9b66a65..0dbfd4d 100755
--- a/LayoutTests/fast/harness/resources/cached-page-1.html
+++ b/LayoutTests/fast/harness/resources/cached-page-1.html
@@ -22,7 +22,8 @@ function loadNext()
     intervalId = setInterval(check, 10);
 
     window.opener.log("page-1, about to navigate to page-2.")
-    location.href = "cached-page-2.html";
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
 }
 </script>
 <body onload="loadNext()"></body>
diff --git a/LayoutTests/fast/harness/resources/cached-page-with-data-urls.html b/LayoutTests/fast/harness/resources/cached-page-with-data-urls.html
index f85166d..f20ec0b 100644
--- a/LayoutTests/fast/harness/resources/cached-page-with-data-urls.html
+++ b/LayoutTests/fast/harness/resources/cached-page-with-data-urls.html
@@ -18,7 +18,8 @@ function loadNext()
     intervalId = setInterval(check, 10);
 
     window.opener.log("page with data urls, about to navigate to page-2.")
-    location.href = "cached-page-2.html";
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {location.href = "cached-page-2.html";}, 0);
 }
 </script>
 <body onload="loadNext()">
diff --git a/LayoutTests/fast/history/gesture-before-onload-expected.txt b/LayoutTests/fast/history/gesture-before-onload-expected.txt
new file mode 100644
index 0000000..f2a0faf
--- /dev/null
+++ b/LayoutTests/fast/history/gesture-before-onload-expected.txt
@@ -0,0 +1,9 @@
+This page is the target of a redirect.
+
+PASS: History item count should be 2 and is.
+
+
+============== Back Forward List ==============
+        (file test):fast/history/gesture-before-onload.html  **nav target**
+curr->  (file test):fast/history/resources/gesture-before-onload-target.html#2  **nav target**
+===============================================
diff --git a/LayoutTests/fast/history/gesture-before-onload.html b/LayoutTests/fast/history/gesture-before-onload.html
new file mode 100644
index 0000000..560adcb
--- /dev/null
+++ b/LayoutTests/fast/history/gesture-before-onload.html
@@ -0,0 +1,32 @@
+<head>
+</head>
+<body onload="onload()">
+  <button id="nav-button" onclick="nav();">Navigate</button>
+  <div id="manual-explanation" style="display: none; color: blue">When running this test outside of DRT, please click on the "Navigate" button.</div>
+</body>
+<script>
+  if (window.layoutTestController) {
+      layoutTestController.clearBackForwardList();
+      layoutTestController.waitUntilDone();
+  }
+
+  if (window.eventSender) {
+      var navButtonNode = document.getElementById('nav-button');
+      eventSender.mouseMoveTo(
+          navButtonNode.offsetLeft + navButtonNode.offsetWidth / 2,
+          navButtonNode.offsetTop + navButtonNode.offsetHeight / 2);
+      eventSender.mouseDown();
+      eventSender.mouseUp();
+  } else {
+      document.getElementById('manual-explanation').style.display = '';
+  }
+
+  function nav() {
+      window.location.href = 'resources/gesture-before-onload-target.html#2';
+  }
+
+  function onload() {
+      window.console.log('FAIL: Should not have reached onload before navigating away');
+  }
+</script>
+
diff --git a/LayoutTests/fast/history/history-length.html b/LayoutTests/fast/history/history-length.html
index 4baa7e7..94f507d 100644
--- a/LayoutTests/fast/history/history-length.html
+++ b/LayoutTests/fast/history/history-length.html
@@ -8,30 +8,34 @@ onload = function() {
       layoutTestController.waitUntilDone();
     }
   }
-  // This test advances history by 2 pages, then navigates back one, and
-  // records history.length.  We expect history.length to indicate the total
-  // length of session history.  At the end of the test, it should be 2 greater
-  // than it was at the start of the test.
-  switch (sessionStorage.testStage++) {
-  case 0:
-    sessionStorage.initialLength = history.length;
-    location = "?a";
-    break;
-  case 1:
-    location = "?b";
-    break;
-  case 2:
-    history.back();
-    break;
-  case 3:
-    if (history.length == (sessionStorage.initialLength - 0) + 2)
-      document.body.innerHTML = "PASS";
-    else
-      document.body.innerHTML = "FAIL: initialLength=" + sessionStorage.initialLength + ", history.length=" + history.length;
-    if (window.layoutTestController)
-      layoutTestController.notifyDone();
-    break;
-  }
+
+  // Location changes need to happen outside the onload handler to generate history entries.
+  setTimeout(function() {
+    // This test advances history by 2 pages, then navigates back one, and
+    // records history.length.  We expect history.length to indicate the total
+    // length of session history.  At the end of the test, it should be 2 greater
+    // than it was at the start of the test.
+    switch (sessionStorage.testStage++) {
+    case 0:
+      sessionStorage.initialLength = history.length;
+      location = "?a";
+      break;
+    case 1:
+      location = "?b";
+      break;
+    case 2:
+      history.back();
+      break;
+    case 3:
+      if (history.length == (sessionStorage.initialLength - 0) + 2)
+        document.body.innerHTML = "PASS";
+      else
+        document.body.innerHTML = "FAIL: initialLength=" + sessionStorage.initialLength + ", history.length=" + history.length;
+      if (window.layoutTestController)
+        layoutTestController.notifyDone();
+      break;
+    }
+  }, 0);
 }
 onunload = function() {
   // disable page cache
diff --git a/LayoutTests/fast/history/resources/gesture-before-onload-target.html b/LayoutTests/fast/history/resources/gesture-before-onload-target.html
new file mode 100644
index 0000000..2f43ec9
--- /dev/null
+++ b/LayoutTests/fast/history/resources/gesture-before-onload-target.html
@@ -0,0 +1,41 @@
+<!-- This page accepts a query string specifying how many history items should
+be present once it finishes loading. -->
+
+<html>
+<head>
+<title>Redirect Target</title>
+
+<script>
+function log(s)
+{
+    document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
+}
+
+function testHistoryItemCount()
+{
+    var expected = parseInt(location.hash.slice(1));
+    var actual = history.length;
+    if (actual === expected)
+        log("PASS: History item count should be " + expected + " and is.");
+    else
+        log("FAIL: History item count should be " + expected + " but instead is " + actual + ".");
+}
+
+window.addEventListener("load", function () {
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        testHistoryItemCount();
+        layoutTestController.dumpBackForwardList();
+        layoutTestController.notifyDone();
+    } else {
+        testHistoryItemCount();
+    }
+}, false);
+</script>
+</head>
+
+<body>
+<p>This page is the target of a redirect.</p>
+<pre id="console"></pre>
+</body>
+</html>
diff --git a/LayoutTests/fast/history/saves-state-after-fragment-nav.html b/LayoutTests/fast/history/saves-state-after-fragment-nav.html
index 0644df8..60dec93 100644
--- a/LayoutTests/fast/history/saves-state-after-fragment-nav.html
+++ b/LayoutTests/fast/history/saves-state-after-fragment-nav.html
@@ -30,8 +30,11 @@ function runTestStep() {
       layoutTestController.dumpAsText();
       layoutTestController.waitUntilDone();
     }
-    navigateToHash(field);
-    navigateAwayAndBack();
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {
+      navigateToHash(field);
+      navigateAwayAndBack();
+    }, 0);
   } else {
     document.body.innerHTML = (field.value == '') ? 'FAIL' : 'PASS';
     if (window.layoutTestController)
diff --git a/LayoutTests/fast/loader/input-element-page-cache-crash.html b/LayoutTests/fast/loader/input-element-page-cache-crash.html
index ee69355..2493272 100644
--- a/LayoutTests/fast/loader/input-element-page-cache-crash.html
+++ b/LayoutTests/fast/loader/input-element-page-cache-crash.html
@@ -13,8 +13,9 @@ function runTest()
     var input = document.getElementById("testinput");
     input.setAttribute("autocomplete", "on");
     input.parentNode.removeChild(input);
-    
-    window.location = "data:text/html,<script>history.back();</scrip" + "t>";
+
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {window.location = "data:text/html,<script>history.back();</scrip" + "t>";}, 0);
 }
 
 function pageHidden()
diff --git a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
index 7dca361..edbb1c2 100644
--- a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
+++ b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
@@ -33,9 +33,10 @@ function runThirdStageOfTest()
 
 function loaded()
 {
-    if (!sessionStorage.stage)
-        runFirstStageOfTest();
-    else if (sessionStorage.stage == 2)
+    if (!sessionStorage.stage) {
+        // Location changes need to happen outside the onload handler to generate history entries.
+        setTimeout(runFirstStageOfTest, 0);
+    } else if (sessionStorage.stage == 2)
         runSecondStageOfTest();
     else if (sessionStorage.stage == 3)
         runThirdStageOfTest();
diff --git a/LayoutTests/fast/loader/stateobjects/pushstate-clears-forward-history.html b/LayoutTests/fast/loader/stateobjects/pushstate-clears-forward-history.html
index b08c5a5..bbb4479 100644
--- a/LayoutTests/fast/loader/stateobjects/pushstate-clears-forward-history.html
+++ b/LayoutTests/fast/loader/stateobjects/pushstate-clears-forward-history.html
@@ -8,22 +8,26 @@ onload = function() {
       layoutTestController.waitUntilDone();
     }
   }
-  switch (sessionStorage.testStage++) {
-  case 0:
-    location = "?a";
-    break;
-  case 1:
-    location = "?b";
-    break;
-  case 2:
-    history.back();
-    break;
-  case 3:
-    history.pushState(null, null);
-    if (window.layoutTestController)
-      layoutTestController.notifyDone();
-    break;
-  }
+
+  // Location changes need to happen outside the onload handler to generate history entries.
+  setTimeout(function() {
+      switch (sessionStorage.testStage++) {
+      case 0:
+        location = "?a";
+        break;
+      case 1:
+        location = "?b";
+        break;
+      case 2:
+        history.back();
+        break;
+      case 3:
+        history.pushState(null, null);
+        if (window.layoutTestController)
+          layoutTestController.notifyDone();
+        break;
+      }
+    }, 0);
 }
 onunload = function() {
   // disable page cache
diff --git a/LayoutTests/fast/loader/subframe-navigate-during-main-frame-load.html b/LayoutTests/fast/loader/subframe-navigate-during-main-frame-load.html
index 2852381..2ab12cc 100644
--- a/LayoutTests/fast/loader/subframe-navigate-during-main-frame-load.html
+++ b/LayoutTests/fast/loader/subframe-navigate-during-main-frame-load.html
@@ -9,8 +9,9 @@ function runTest()
         layoutTestController.dumpBackForwardList();
         layoutTestController.waitUntilDone();
     }
-    
-    location='resources/subframe-navigate-during-main-frame-load2.html';
+
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(function() {location='resources/subframe-navigate-during-main-frame-load2.html';}, 0);
 }
 
 </script>
diff --git a/LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt b/LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt
index efbe835..062b69b 100644
--- a/LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt
+++ b/LayoutTests/http/tests/history/redirect-js-document-location-before-load-expected.txt
@@ -1,9 +1,8 @@
 This page is the target of a redirect.
 
-FAIL: History item count should be 1 but instead is 2.
+PASS: History item count should be 1 and is.
 
 
 ============== Back Forward List ==============
-        http://127.0.0.1:8000/history/redirect-js-document-location-before-load.html  **nav target**
 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
 ===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt b/LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt
index 42a1259..062b69b 100644
--- a/LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt
+++ b/LayoutTests/http/tests/history/redirect-js-location-assign-before-load-expected.txt
@@ -1,9 +1,8 @@
 This page is the target of a redirect.
 
-FAIL: History item count should be 1 but instead is 2.
+PASS: History item count should be 1 and is.
 
 
 ============== Back Forward List ==============
-        http://127.0.0.1:8000/history/redirect-js-location-assign-before-load.html  **nav target**
 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
 ===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt b/LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt
index b6daf9e..062b69b 100644
--- a/LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt
+++ b/LayoutTests/http/tests/history/redirect-js-location-before-load-expected.txt
@@ -1,9 +1,8 @@
 This page is the target of a redirect.
 
-FAIL: History item count should be 1 but instead is 2.
+PASS: History item count should be 1 and is.
 
 
 ============== Back Forward List ==============
-        http://127.0.0.1:8000/history/redirect-js-location-before-load.html  **nav target**
 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
 ===============================================
diff --git a/LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt b/LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt
index 3cc9c6b..062b69b 100644
--- a/LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt
+++ b/LayoutTests/http/tests/history/redirect-js-location-href-before-load-expected.txt
@@ -1,9 +1,8 @@
 This page is the target of a redirect.
 
-FAIL: History item count should be 1 but instead is 2.
+PASS: History item count should be 1 and is.
 
 
 ============== Back Forward List ==============
-        http://127.0.0.1:8000/history/redirect-js-location-href-before-load.html  **nav target**
 curr->  http://127.0.0.1:8000/history/resources/redirect-target.html#1  **nav target**
 ===============================================
diff --git a/LayoutTests/http/tests/navigation/resources/document-location.js b/LayoutTests/http/tests/navigation/resources/document-location.js
index 1db48cd..a0ab4d8 100644
--- a/LayoutTests/http/tests/navigation/resources/document-location.js
+++ b/LayoutTests/http/tests/navigation/resources/document-location.js
@@ -7,7 +7,8 @@ function start() {
       layoutTestController.dumpAsText();
       layoutTestController.waitUntilDone();
 
-      runTest();
+      // Location changes need to happen outside the onload handler to generate history entries.
+      setTimeout(runTest, 0);
     } else {
       // loaded the ?1 navigation
       layoutTestController.notifyDone();
diff --git a/LayoutTests/security/autocomplete-cleared-on-back.html b/LayoutTests/security/autocomplete-cleared-on-back.html
index 0801881..96c9d81 100644
--- a/LayoutTests/security/autocomplete-cleared-on-back.html
+++ b/LayoutTests/security/autocomplete-cleared-on-back.html
@@ -19,7 +19,8 @@ function runTest()
     if (!sessionStorage.secondPageReached) {
         document.getElementById("firstInput").value = "SuperSeekritValue";
         document.getElementById("secondInput").value = "SuperSeekritValue";
-        window.location = "resources/autocomplete-cleared-on-back2.html";
+        // Location changes need to happen outside the onload handler to generate history entries.
+        setTimeout(function() {window.location = "resources/autocomplete-cleared-on-back2.html";}, 0);
         return;
     }
     
diff --git a/LayoutTests/storage/hash-change-with-xhr.js b/LayoutTests/storage/hash-change-with-xhr.js
index 4290681..7f56f79 100644
--- a/LayoutTests/storage/hash-change-with-xhr.js
+++ b/LayoutTests/storage/hash-change-with-xhr.js
@@ -81,6 +81,12 @@ function invokeBack()
 
 function runTest()
 {
+    // Location changes need to happen outside the onload handler to generate history entries.
+    setTimeout(runTestsInner, 0);
+}
+
+function runTestsInner()
+{
     backIterations = 10;
     consecutiveFailures = 0;
     successes = 0;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f05549f..0f77912 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-07-30  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Session history should skip over JS redirects
+        https://bugs.webkit.org/show_bug.cgi?id=42861
+        
+        Lock the back/forward list for location changes that happen before the 
+        onload event fires that are not the result of user gestures.
+
+        Test: fast/history/gesture-before-onload.html and updated expectations 
+        for http/tests/history tests that used to fail.
+
+        * loader/RedirectScheduler.cpp:
+        (WebCore::RedirectScheduler::scheduleRedirect):
+        (WebCore::RedirectScheduler::mustLockBackForwardList):
+        (WebCore::RedirectScheduler::scheduleLocationChange):
+        (WebCore::RedirectScheduler::scheduleFormSubmission):
+        * loader/RedirectScheduler.h:
+
 2010-07-30  Matthew Delaney  <mdelaney at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp
index 3cfe61a..d86e226 100644
--- a/WebCore/loader/RedirectScheduler.cpp
+++ b/WebCore/loader/RedirectScheduler.cpp
@@ -240,17 +240,21 @@ void RedirectScheduler::scheduleRedirect(double delay, const String& url)
     if (url.isEmpty())
         return;
 
-    // We want a new history item if the refresh timeout is > 1 second.
+    // We want a new back forward list item if the refresh timeout is > 1 second.
     if (!m_redirect || delay <= m_redirect->delay())
         schedule(new ScheduledRedirect(delay, url, true, delay <= 1, false));
 }
 
-bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame)
+bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame, bool mustLockIfDuringLoad)
 {
+    // Non-user navigation before the page has loaded should not create a new back/forward item.
+    // See https://webkit.org/b/42861 for the original motivation for this.    
+    if (mustLockIfDuringLoad && targetFrame->loader()->documentLoader() && targetFrame->loader()->documentLoader()->isLoadingInAPISense())
+        return true;
+    
     // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
     // The definition of "during load" is any time before all handlers for the load event have been run.
     // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.
-
     for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {
         Document* document = ancestor->document();
         if (!ancestor->loader()->isComplete() || (document && document->processingLoadEvent()))
@@ -266,7 +270,7 @@ void RedirectScheduler::scheduleLocationChange(const String& url, const String&
     if (url.isEmpty())
         return;
 
-    lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
+    lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame, !wasUserGesture);
 
     FrameLoader* loader = m_frame->loader();
     
@@ -300,7 +304,7 @@ void RedirectScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> submis
     // to match IE and Opera.
     // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motivation for this.
 
-    bool lockBackForwardList = mustLockBackForwardList(m_frame) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
+    bool lockBackForwardList = mustLockBackForwardList(m_frame, false) || (submission->state()->formSubmissionTrigger() == SubmittedByJavaScript && m_frame->tree()->parent());
 
     schedule(new ScheduledFormSubmission(submission, lockBackForwardList, duringLoad));
 }
diff --git a/WebCore/loader/RedirectScheduler.h b/WebCore/loader/RedirectScheduler.h
index e9d04dc..ddb96e1 100644
--- a/WebCore/loader/RedirectScheduler.h
+++ b/WebCore/loader/RedirectScheduler.h
@@ -70,7 +70,7 @@ private:
     void timerFired(Timer<RedirectScheduler>*);
     void schedule(PassOwnPtr<ScheduledNavigation>);
 
-    static bool mustLockBackForwardList(Frame* targetFrame);
+    static bool mustLockBackForwardList(Frame* targetFrame, bool mustLockIfDuringLoad);
 
     Frame* m_frame;
     Timer<RedirectScheduler> m_timer;
@@ -79,4 +79,4 @@ private:
 
 } // namespace WebCore
 
-#endif // FrameLoader_h
+#endif // RedirectScheduler_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list