2010-08-19 Mihai Parparita <mihaip@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Aug 2010 03:57:13 +0000 (03:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Aug 2010 03:57:13 +0000 (03:57 +0000)
        Reviewed by Brady Eidson.

        Assertion failure when going back inside frame during onload
        https://bugs.webkit.org/show_bug.cgi?id=44217

        Adds a test that does a history.back() within the main frame during
        onload of a child frame. If HISTORY_ALWAYS_ASYNC was set to 0, this
        would crash the DRT with an assertion failure, since we hadn't called
        updateForFrameLoadCompleted in the main frame yet.

        (renames history-back-within-subframe to history-back-within-subframe-hash
        to differentiate between the two otherwise similar tests)

        * fast/history/history-back-within-subframe-hash-expected.txt: Renamed from LayoutTests/fast/history/history-back-within-subframe-expected.txt.
        * fast/history/history-back-within-subframe-hash.html: Renamed from LayoutTests/fast/history/history-back-within-subframe.html.
        * fast/history/history-back-within-subframe-url-expected.txt: Added
        * fast/history/history-back-within-subframe-url.html: Added.
        * fast/history/resources/history-back-within-subframe-hash-2.html: Renamed from LayoutTests/fast/history/resources/history-back-within-subframe-2.html.
        * fast/history/resources/history-back-within-subframe-url-2.html: Added.
        * fast/history/resources/history-back-within-subframe-url-3.html: Added.
2010-08-19  Mihai Parparita  <mihaip@chromium.org>

        Reviewed by Brady Eidson.

        Assertion failure when going back inside frame during onload
        https://bugs.webkit.org/show_bug.cgi?id=44217

        Fix assertion failure when doing a history.back() within the main frame
        during onload of a child frame. This would happen when
        HISTORY_ALWAYS_ASYNC was set to 0, because we would only compare the
        current frame document sequence numbers when determining if we're in the
        same document, instead of also recursing over child frames.

        Test: fast/history/history-back-within-subframe-hash.html

        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::hasSameDocuments):
        * history/HistoryItem.h:
        * loader/RedirectScheduler.cpp:
        (WebCore::RedirectScheduler::scheduleHistoryNavigation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@65724 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/history/history-back-within-subframe-hash-expected.txt [moved from LayoutTests/fast/history/history-back-within-subframe-expected.txt with 100% similarity]
LayoutTests/fast/history/history-back-within-subframe-hash.html [moved from LayoutTests/fast/history/history-back-within-subframe.html with 73% similarity]
LayoutTests/fast/history/history-back-within-subframe-url-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/history-back-within-subframe-url.html [new file with mode: 0644]
LayoutTests/fast/history/resources/history-back-within-subframe-hash-2.html [moved from LayoutTests/fast/history/resources/history-back-within-subframe-2.html with 100% similarity]
LayoutTests/fast/history/resources/history-back-within-subframe-url-2.html [new file with mode: 0644]
LayoutTests/fast/history/resources/history-back-within-subframe-url-3.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/history/HistoryItem.cpp
WebCore/history/HistoryItem.h
WebCore/loader/RedirectScheduler.cpp

index 1ea39da..c1be129 100644 (file)
@@ -1,3 +1,26 @@
+2010-08-19  Mihai Parparita  <mihaip@chromium.org>
+
+        Reviewed by Brady Eidson.
+
+        Assertion failure when going back inside frame during onload
+        https://bugs.webkit.org/show_bug.cgi?id=44217
+
+        Adds a test that does a history.back() within the main frame during
+        onload of a child frame. If HISTORY_ALWAYS_ASYNC was set to 0, this
+        would crash the DRT with an assertion failure, since we hadn't called
+        updateForFrameLoadCompleted in the main frame yet.
+
+        (renames history-back-within-subframe to history-back-within-subframe-hash
+        to differentiate between the two otherwise similar tests)
+
+        * fast/history/history-back-within-subframe-hash-expected.txt: Renamed from LayoutTests/fast/history/history-back-within-subframe-expected.txt.
+        * fast/history/history-back-within-subframe-hash.html: Renamed from LayoutTests/fast/history/history-back-within-subframe.html.
+        * fast/history/history-back-within-subframe-url-expected.txt: Added
+        * fast/history/history-back-within-subframe-url.html: Added.
+        * fast/history/resources/history-back-within-subframe-hash-2.html: Renamed from LayoutTests/fast/history/resources/history-back-within-subframe-2.html.
+        * fast/history/resources/history-back-within-subframe-url-2.html: Added.
+        * fast/history/resources/history-back-within-subframe-url-3.html: Added.
+
 2010-08-19  Kenichi Ishibashi  <bashi@google.com>
 
         Reviewed by Kent Tamura.
@@ -7,6 +7,6 @@ onload = function() {
   }
 }
 </script>
-<iframe src="resources/history-back-within-subframe-2.html"></iframe>
+<iframe src="resources/history-back-within-subframe-hash-2.html"></iframe>
 <div id="result">FAIL</div>
 </body>
diff --git a/LayoutTests/fast/history/history-back-within-subframe-url-expected.txt b/LayoutTests/fast/history/history-back-within-subframe-url-expected.txt
new file mode 100644 (file)
index 0000000..aa44e7c
--- /dev/null
@@ -0,0 +1,2 @@
+
+PASS
diff --git a/LayoutTests/fast/history/history-back-within-subframe-url.html b/LayoutTests/fast/history/history-back-within-subframe-url.html
new file mode 100644 (file)
index 0000000..508264e
--- /dev/null
@@ -0,0 +1,24 @@
+<body>
+<script>
+onload = function() {
+  if (window.layoutTestController)
+  {
+      layoutTestController.dumpAsText();
+      layoutTestController.waitUntilDone();
+  }
+}
+
+wentBack = false;
+
+function onFrameLoaded()
+{
+    wentBack = true;
+    history.back();
+    document.getElementById('result').innerText = 'PASS';
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();      
+}
+</script>
+<iframe src="resources/history-back-within-subframe-url-2.html"></iframe>
+<div id="result">FAIL</div>
+</body>
diff --git a/LayoutTests/fast/history/resources/history-back-within-subframe-url-2.html b/LayoutTests/fast/history/resources/history-back-within-subframe-url-2.html
new file mode 100644 (file)
index 0000000..bf3e1a1
--- /dev/null
@@ -0,0 +1,10 @@
+<body onload="init()">
+<script>
+function init()
+{
+    if (!parent.wentBack)
+        setTimeout(function() {window.location.href = 'history-back-within-subframe-url-3.html';}, 0);
+}
+</script>
+frame 2
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/history/resources/history-back-within-subframe-url-3.html b/LayoutTests/fast/history/resources/history-back-within-subframe-url-3.html
new file mode 100644 (file)
index 0000000..4678be2
--- /dev/null
@@ -0,0 +1,3 @@
+<body onload="parent.onFrameLoaded()">
+frame 3
+</body>
\ No newline at end of file
index 8c05ea4..96d81d3 100644 (file)
@@ -1,3 +1,24 @@
+2010-08-19  Mihai Parparita  <mihaip@chromium.org>
+
+        Reviewed by Brady Eidson.
+
+        Assertion failure when going back inside frame during onload
+        https://bugs.webkit.org/show_bug.cgi?id=44217
+
+        Fix assertion failure when doing a history.back() within the main frame
+        during onload of a child frame. This would happen when
+        HISTORY_ALWAYS_ASYNC was set to 0, because we would only compare the
+        current frame document sequence numbers when determining if we're in the
+        same document, instead of also recursing over child frames.
+
+        Test: fast/history/history-back-within-subframe-hash.html
+
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::hasSameDocuments):
+        * history/HistoryItem.h:
+        * loader/RedirectScheduler.cpp:
+        (WebCore::RedirectScheduler::scheduleHistoryNavigation):
+
 2010-08-19  Balazs Kelemen  <kb@inf.u-szeged.hu>
 
         Reviewed by Antonio Gomes.
index 3ee423b..3409f81 100644 (file)
@@ -480,6 +480,22 @@ void HistoryItem::clearChildren()
     m_children.clear();
 }
 
+bool HistoryItem::hasSameDocuments(HistoryItem* otherItem)
+{
+    if (documentSequenceNumber() != otherItem->documentSequenceNumber())
+        return false;
+        
+    if (children().size() != otherItem->children().size())
+        return false;
+    
+    for (size_t i = 0; i < children().size(); i++) {
+        if (!children()[i]->hasSameDocuments(otherItem->children()[i].get()))
+            return false;
+    }
+    
+    return true;
+}
+
 String HistoryItem::formContentType() const
 {
     return m_formContentType;
index ef73c5e..dfdbc43 100644 (file)
@@ -159,6 +159,8 @@ public:
     const HistoryItemVector& children() const;
     bool hasChildren() const;
     void clearChildren();
+    
+    bool hasSameDocuments(HistoryItem* otherItem);
 
     // This should not be called directly for HistoryItems that are already included
     // in GlobalHistory. The WebKit api for this is to use -[WebHistory setLastVisitedTimeInterval:forItem:] instead.
index d969f30..26d7787 100644 (file)
@@ -342,10 +342,10 @@ void RedirectScheduler::scheduleHistoryNavigation(int steps)
     }
     
 #if !ENABLE(HISTORY_ALWAYS_ASYNC)
-    // If the specified entry and the current entry have the same document, this is either a state object traversal or a fragment 
-    // traversal (or both) and should be performed synchronously.
+    // If the specified entry and the current entry have the same document (or documents, in there are frames), this is either a 
+    // state object traversal or a fragment traversal (or both) and should be performed synchronously.
     HistoryItem* currentEntry = m_frame->loader()->history()->currentItem();
-    if (currentEntry != specifiedEntry && currentEntry->documentSequenceNumber() == specifiedEntry->documentSequenceNumber()) {
+    if (currentEntry != specifiedEntry && currentEntry->hasSameDocuments(specifiedEntry)) {
         m_frame->loader()->history()->goToItem(specifiedEntry, FrameLoadTypeIndexedBackForward);
         return;
     }