Title: [155099] trunk
Revision
155099
Author
zherc...@webkit.org
Date
2013-09-04 23:38:55 -0700 (Wed, 04 Sep 2013)

Log Message

<https://webkit.org/b/118553> Hash navigation doesn't affect history when the page is retrieved from appcache

Reviewed by Darin Adler.

Source/WebCore: 

A new flag called keepInHistory is added to allow keeping
certain pages in the history even if they have substitute data.

Test: http/tests/appcache/history-test.html

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::urlForHistory):
* loader/SubstituteData.h:
(WebCore::SubstituteData::SubstituteData):
(WebCore::SubstituteData::shouldRevealToSessionHistory):
(WebCore::SubstituteData::setShouldRevealToSessionHistory):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::maybeLoadMainResource):

LayoutTests: 

* http/tests/appcache/history-test-expected.txt: Added.
* http/tests/appcache/history-test.html: Added.
* http/tests/appcache/resources/history-test.html: Added.
* http/tests/appcache/resources/history-test.manifest: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (155098 => 155099)


--- trunk/LayoutTests/ChangeLog	2013-09-05 06:34:58 UTC (rev 155098)
+++ trunk/LayoutTests/ChangeLog	2013-09-05 06:38:55 UTC (rev 155099)
@@ -1,3 +1,14 @@
+2013-09-04  Zoltan Herczeg  <zherc...@webkit.org>
+
+        <https://webkit.org/b/118553> Hash navigation doesn't affect history when the page is retrieved from appcache
+
+        Reviewed by Darin Adler.
+
+        * http/tests/appcache/history-test-expected.txt: Added.
+        * http/tests/appcache/history-test.html: Added.
+        * http/tests/appcache/resources/history-test.html: Added.
+        * http/tests/appcache/resources/history-test.manifest: Added.
+
 2013-09-04  Mihai Tica  <mit...@adobe.com>
 
         Test background blend modes with animated gif background layers.

Added: trunk/LayoutTests/http/tests/appcache/history-test-expected.txt (0 => 155099)


--- trunk/LayoutTests/http/tests/appcache/history-test-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/history-test-expected.txt	2013-09-05 06:38:55 UTC (rev 155099)
@@ -0,0 +1,3 @@
+Test whether window.history.back() is supported in application cache.
+
+PASS: Returning to the original page.

Added: trunk/LayoutTests/http/tests/appcache/history-test.html (0 => 155099)


--- trunk/LayoutTests/http/tests/appcache/history-test.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/history-test.html	2013-09-05 06:38:55 UTC (rev 155099)
@@ -0,0 +1,11 @@
+<html>
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+window.location.assign("resources/history-test.html");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/appcache/resources/history-test.html (0 => 155099)


--- trunk/LayoutTests/http/tests/appcache/resources/history-test.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/resources/history-test.html	2013-09-05 06:38:55 UTC (rev 155099)
@@ -0,0 +1,23 @@
+<html manifest="history-test.manifest">
+<body>
+<p>Test whether window.history.back() is supported in application cache.</p>
+
+<script>
+
+if (document.cookie) {
+    document.write("<p>PASS: Returning to the original page.</p>");
+    if (window.testRunner)
+        testRunner.notifyDone();
+} else {
+    document.write("<p>START: Redirecting to other page.</p>");
+    document.cookie = 'cookie1=testcookie';
+
+    // Give time to the history manager to cache this page.
+    setTimeout(function () {
+        window.location.assign("/navigation/resources/go-back.html");
+    }, 200);
+}
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/appcache/resources/history-test.manifest (0 => 155099)


--- trunk/LayoutTests/http/tests/appcache/resources/history-test.manifest	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/resources/history-test.manifest	2013-09-05 06:38:55 UTC (rev 155099)
@@ -0,0 +1,5 @@
+CACHE MANIFEST
+history-test.html
+
+NETWORK:
+*

Modified: trunk/Source/WebCore/ChangeLog (155098 => 155099)


--- trunk/Source/WebCore/ChangeLog	2013-09-05 06:34:58 UTC (rev 155098)
+++ trunk/Source/WebCore/ChangeLog	2013-09-05 06:38:55 UTC (rev 155099)
@@ -1,3 +1,23 @@
+2013-09-04  Zoltan Herczeg  <zherc...@webkit.org>
+
+        <https://webkit.org/b/118553> Hash navigation doesn't affect history when the page is retrieved from appcache
+
+        Reviewed by Darin Adler.
+
+        A new flag called keepInHistory is added to allow keeping
+        certain pages in the history even if they have substitute data.
+
+        Test: http/tests/appcache/history-test.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::urlForHistory):
+        * loader/SubstituteData.h:
+        (WebCore::SubstituteData::SubstituteData):
+        (WebCore::SubstituteData::shouldRevealToSessionHistory):
+        (WebCore::SubstituteData::setShouldRevealToSessionHistory):
+        * loader/appcache/ApplicationCacheHost.cpp:
+        (WebCore::ApplicationCacheHost::maybeLoadMainResource):
+
 2013-09-04  Grzegorz Czajkowski  <g.czajkow...@samsung.com>
 
         Remove deprecated markersForNode(Node* node).

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (155098 => 155099)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-09-05 06:34:58 UTC (rev 155098)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-09-05 06:38:55 UTC (rev 155099)
@@ -1213,9 +1213,9 @@
 KURL DocumentLoader::urlForHistory() const
 {
     // Return the URL to be used for history and B/F list.
-    // Returns nil for WebDataProtocol URLs that aren't alternates 
+    // Returns nil for WebDataProtocol URLs that aren't alternates
     // for unreachable URLs, because these can't be stored in history.
-    if (m_substituteData.isValid())
+    if (m_substituteData.isValid() && !m_substituteData.shouldRevealToSessionHistory())
         return unreachableURL();
 
     return m_originalRequestCopy.url();

Modified: trunk/Source/WebCore/loader/SubstituteData.h (155098 => 155099)


--- trunk/Source/WebCore/loader/SubstituteData.h	2013-09-05 06:34:58 UTC (rev 155098)
+++ trunk/Source/WebCore/loader/SubstituteData.h	2013-09-05 06:38:55 UTC (rev 155099)
@@ -35,18 +35,27 @@
 
     class SubstituteData {
     public:
-        SubstituteData() { }
+        SubstituteData()
+            : m_shouldRevealToSessionHistory(false)
+        {
+        }
 
-        SubstituteData(PassRefPtr<SharedBuffer> content, const String& mimeType, const String& textEncoding, const KURL& failingURL, const KURL& responseURL = KURL())
+        SubstituteData(PassRefPtr<SharedBuffer> content, const String& mimeType,
+                       const String& textEncoding, const KURL& failingURL,
+                       const KURL& responseURL = KURL(), bool shouldRevealToSessionHistory = false)
             : m_content(content)
             , m_mimeType(mimeType)
             , m_textEncoding(textEncoding)
             , m_failingURL(failingURL)
             , m_responseURL(responseURL)
+            , m_shouldRevealToSessionHistory(shouldRevealToSessionHistory)
         {
         }
 
+        static const bool ShouldRevealToSessionHistory = true;
+
         bool isValid() const { return m_content != 0; }
+        bool shouldRevealToSessionHistory() const { return m_shouldRevealToSessionHistory; }
 
         const SharedBuffer* content() const { return m_content.get(); }
         const String& mimeType() const { return m_mimeType; }
@@ -60,6 +69,7 @@
         String m_textEncoding;
         KURL m_failingURL;
         KURL m_responseURL;
+        bool m_shouldRevealToSessionHistory;
     };
 
 }

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp (155098 => 155099)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2013-09-05 06:34:58 UTC (rev 155098)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2013-09-05 06:38:55 UTC (rev 155099)
@@ -83,9 +83,12 @@
         if (m_mainResourceApplicationCache) {
             // Get the resource from the application cache. By definition, cacheForMainRequest() returns a cache that contains the resource.
             ApplicationCacheResource* resource = m_mainResourceApplicationCache->resourceForRequest(request);
-            substituteData = SubstituteData(resource->data(), 
+            substituteData = SubstituteData(resource->data(),
                                             resource->response().mimeType(),
-                                            resource->response().textEncodingName(), KURL());
+                                            resource->response().textEncodingName(),
+                                            KURL(),
+                                            KURL(),
+                                            SubstituteData::ShouldRevealToSessionHistory);
         }
     }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to