Title: [163914] trunk
Revision
163914
Author
jp...@apple.com
Date
2014-02-11 15:07:49 -0800 (Tue, 11 Feb 2014)

Log Message

Bring third-party app cache blocking behavior in line with private browsing app cache blocking behavior
https://bugs.webkit.org/show_bug.cgi?id=128557

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::cacheForMainRequest):
(WebCore::ApplicationCacheGroup::selectCache):
(WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL):
(WebCore::ApplicationCacheGroup::update):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::maybeLoadMainResource):
(WebCore::ApplicationCacheHost::maybeLoadFallbackForMainResponse):
(WebCore::ApplicationCacheHost::maybeLoadFallbackForMainError):
(WebCore::ApplicationCacheHost::maybeLoadResource):
(WebCore::ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache):
(WebCore::ApplicationCacheHost::isApplicationCacheBlockedForRequest):
* loader/appcache/ApplicationCacheHost.h:

LayoutTests:

* http/tests/security/resources/cross-origin-iframe-for-appcache-allowed.html:
* http/tests/security/resources/cross-origin-iframe-for-appcache.html:
* http/tests/security/resources/same-origin-iframe-for-appcache-blocked.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (163913 => 163914)


--- trunk/LayoutTests/ChangeLog	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/LayoutTests/ChangeLog	2014-02-11 23:07:49 UTC (rev 163914)
@@ -1,3 +1,14 @@
+2014-02-10  Jeffrey Pfau  <jp...@apple.com>
+
+        Bring third-party app cache blocking behavior in line with private browsing app cache blocking behavior
+        https://bugs.webkit.org/show_bug.cgi?id=128557
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/security/resources/cross-origin-iframe-for-appcache-allowed.html:
+        * http/tests/security/resources/cross-origin-iframe-for-appcache.html:
+        * http/tests/security/resources/same-origin-iframe-for-appcache-blocked.html:
+
 2014-02-11  Brady Eidson  <beid...@apple.com>
 
         IDB: The test after storage/indexeddb/mozilla/object-identity.html fails in cleanup code

Modified: trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache-allowed.html (163913 => 163914)


--- trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache-allowed.html	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache-allowed.html	2014-02-11 23:07:49 UTC (rev 163914)
@@ -6,25 +6,19 @@
 	cleanup();
 }
 
-function timedOut() {
-	try {
-		applicationCache.update();
-		timer = setTimeout(cleanup, 5000);
-	} catch (e) {
-		document.write('Cache not found');
-		cleanup();
-	}
+function error() {
+	document.write('Cache not found');
+	cleanup();
 }
 
 function cleanup() {
-	clearTimeout(timer);
 	top.postMessage('done', '*');
 }
 
 try {
-	timer = setTimeout(timedOut, 5000);
 	applicationCache.addEventListener('noupdate', complete, false);
 	applicationCache.addEventListener('cached', complete, false);
+	applicationCache.addEventListener('error', error, false);
 } catch (e) {
 	document.write('Cache not found');
 	cleanup();

Modified: trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache.html (163913 => 163914)


--- trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache.html	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/LayoutTests/http/tests/security/resources/cross-origin-iframe-for-appcache.html	2014-02-11 23:07:49 UTC (rev 163914)
@@ -6,25 +6,19 @@
 	cleanup();
 }
 
-function timedOut() {
-	try {
-		applicationCache.update();
-		timer = setTimeout(cleanup, 5000);
-	} catch (e) {
-		document.write('Cache not found');
-		cleanup();
-	}
+function error() {
+	document.write('Cache not found');
+	cleanup();
 }
 
 function cleanup() {
-	clearTimeout(timer);
 	top.postMessage('done', '*');
 }
 
 try {
-	timer = setTimeout(timedOut, 5000);
 	applicationCache.addEventListener('noupdate', complete, false);
 	applicationCache.addEventListener('cached', complete, false);
+	applicationCache.addEventListener('error', error, false);
 } catch (e) {
 	document.write('Cache not found');
 	cleanup();

Modified: trunk/LayoutTests/http/tests/security/resources/same-origin-iframe-for-appcache-blocked.html (163913 => 163914)


--- trunk/LayoutTests/http/tests/security/resources/same-origin-iframe-for-appcache-blocked.html	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/LayoutTests/http/tests/security/resources/same-origin-iframe-for-appcache-blocked.html	2014-02-11 23:07:49 UTC (rev 163914)
@@ -6,25 +6,19 @@
 	cleanup();
 }
 
-function timedOut() {
-	try {
-		applicationCache.update();
-		timer = setTimeout(cleanup, 5000);
-	} catch (e) {
-		document.write('Cache not found');
-		cleanup();
-	}
+function error() {
+	document.write('Cache not found');
+	cleanup();
 }
 
 function cleanup() {
-	clearTimeout(timer);
 	top.postMessage('done', '*');
 }
 
 try {
-	timer = setTimeout(timedOut, 5000);
 	applicationCache.addEventListener('noupdate', complete, false);
 	applicationCache.addEventListener('cached', complete, false);
+	applicationCache.addEventListener('error', error, false);
 } catch (e) {
 	document.write('Cache not found');
 	cleanup();

Modified: trunk/Source/WebCore/ChangeLog (163913 => 163914)


--- trunk/Source/WebCore/ChangeLog	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/Source/WebCore/ChangeLog	2014-02-11 23:07:49 UTC (rev 163914)
@@ -1,3 +1,24 @@
+2014-02-10  Jeffrey Pfau  <jp...@apple.com>
+
+        Bring third-party app cache blocking behavior in line with private browsing app cache blocking behavior
+        https://bugs.webkit.org/show_bug.cgi?id=128557
+
+        Reviewed by Alexey Proskuryakov.
+
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::cacheForMainRequest):
+        (WebCore::ApplicationCacheGroup::selectCache):
+        (WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL):
+        (WebCore::ApplicationCacheGroup::update):
+        * loader/appcache/ApplicationCacheHost.cpp:
+        (WebCore::ApplicationCacheHost::maybeLoadMainResource):
+        (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainResponse):
+        (WebCore::ApplicationCacheHost::maybeLoadFallbackForMainError):
+        (WebCore::ApplicationCacheHost::maybeLoadResource):
+        (WebCore::ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache):
+        (WebCore::ApplicationCacheHost::isApplicationCacheBlockedForRequest):
+        * loader/appcache/ApplicationCacheHost.h:
+
 2014-02-11  Brady Eidson  <beid...@apple.com>
 
         IDB: The test after storage/indexeddb/mozilla/object-identity.html fails in cleanup code

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp (163913 => 163914)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2014-02-11 23:07:49 UTC (rev 163914)
@@ -105,7 +105,7 @@
     if (url.hasFragmentIdentifier())
         url.removeFragmentIdentifier();
 
-    if (documentLoader->frame() && documentLoader->frame()->settings().privateBrowsingEnabled())
+    if (documentLoader->frame() && (documentLoader->frame()->settings().privateBrowsingEnabled() || !documentLoader->frame()->document()->securityOrigin()->canAccessApplicationCache(documentLoader->frame()->tree().top().document()->securityOrigin())))
         return 0;
 
     if (ApplicationCacheGroup* group = cacheStorage().cacheGroupForURL(url)) {
@@ -143,9 +143,6 @@
     
     if (!frame->settings().offlineWebApplicationCacheEnabled())
         return;
-
-    if (!frame->document()->securityOrigin()->canAccessApplicationCache(frame->tree().top().document()->securityOrigin()))
-        return;
     
     DocumentLoader* documentLoader = frame->loader().documentLoader();
     ASSERT(!documentLoader->applicationCacheHost()->applicationCache());
@@ -156,7 +153,7 @@
     }
 
     // Don't access anything on disk if private browsing is enabled.
-    if (frame->settings().privateBrowsingEnabled()) {
+    if (frame->settings().privateBrowsingEnabled() || !frame->document()->securityOrigin()->canAccessApplicationCache(frame->tree().top().document()->securityOrigin())) {
         postListenerTask(ApplicationCacheHost::CHECKING_EVENT, documentLoader);
         postListenerTask(ApplicationCacheHost::ERROR_EVENT, documentLoader);
         return;
@@ -220,14 +217,11 @@
     if (!frame->settings().offlineWebApplicationCacheEnabled())
         return;
 
-    if (!frame->document()->securityOrigin()->canAccessApplicationCache(frame->tree().top().document()->securityOrigin()))
-        return;
-
     DocumentLoader* documentLoader = frame->loader().documentLoader();
     ASSERT(!documentLoader->applicationCacheHost()->applicationCache());
 
     // Don't access anything on disk if private browsing is enabled.
-    if (frame->settings().privateBrowsingEnabled()) {
+    if (frame->settings().privateBrowsingEnabled() || !frame->document()->securityOrigin()->canAccessApplicationCache(frame->tree().top().document()->securityOrigin())) {
         postListenerTask(ApplicationCacheHost::CHECKING_EVENT, documentLoader);
         postListenerTask(ApplicationCacheHost::ERROR_EVENT, documentLoader);
         return;
@@ -442,7 +436,7 @@
     }
 
     // Don't access anything on disk if private browsing is enabled.
-    if (frame->settings().privateBrowsingEnabled()) {
+    if (frame->settings().privateBrowsingEnabled() || !frame->document()->securityOrigin()->canAccessApplicationCache(frame->tree().top().document()->securityOrigin())) {
         ASSERT(m_pendingMasterResourceLoaders.isEmpty());
         ASSERT(m_pendingEntries.isEmpty());
         ASSERT(!m_cacheBeingUpdated);

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp (163913 => 163914)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp	2014-02-11 23:07:49 UTC (rev 163914)
@@ -75,7 +75,7 @@
 void ApplicationCacheHost::maybeLoadMainResource(ResourceRequest& request, SubstituteData& substituteData)
 {
     // Check if this request should be loaded from the application cache
-    if (!substituteData.isValid() && isApplicationCacheEnabled()) {
+    if (!substituteData.isValid() && isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request)) {
         ASSERT(!m_mainResourceApplicationCache);
 
         m_mainResourceApplicationCache = ApplicationCacheGroup::cacheForMainRequest(request, m_documentLoader);
@@ -103,7 +103,7 @@
 {
     if (r.httpStatusCode() / 100 == 4 || r.httpStatusCode() / 100 == 5) {
         ASSERT(!m_mainResourceApplicationCache);
-        if (isApplicationCacheEnabled()) {
+        if (isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request)) {
             m_mainResourceApplicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request, documentLoader());
 
             if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader(), m_mainResourceApplicationCache.get()))
@@ -117,7 +117,7 @@
 {
     if (!error.isCancellation()) {
         ASSERT(!m_mainResourceApplicationCache);
-        if (isApplicationCacheEnabled()) {
+        if (isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request)) {
             m_mainResourceApplicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request, m_documentLoader);
 
             if (scheduleLoadFallbackResourceFromApplicationCache(documentLoader()->mainResourceLoader(), m_mainResourceApplicationCache.get()))
@@ -159,7 +159,7 @@
 
 bool ApplicationCacheHost::maybeLoadResource(ResourceLoader* loader, ResourceRequest& request, const URL& originalURL)
 {
-    if (!isApplicationCacheEnabled())
+    if (!isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(request))
         return false;
     
     if (request.url() != originalURL)
@@ -391,7 +391,7 @@
 
 bool ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache(ResourceLoader* loader, ApplicationCache* cache)
 {
-    if (!isApplicationCacheEnabled())
+    if (!isApplicationCacheEnabled() && !isApplicationCacheBlockedForRequest(loader->request()))
         return false;
 
     ApplicationCacheResource* resource;
@@ -479,4 +479,10 @@
     return m_documentLoader->frame() && m_documentLoader->frame()->settings().offlineWebApplicationCacheEnabled() && !m_documentLoader->frame()->settings().privateBrowsingEnabled();
 }
 
+bool ApplicationCacheHost::isApplicationCacheBlockedForRequest(const ResourceRequest& request)
+{
+    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(request.url());
+    return m_documentLoader->frame() && !origin->canAccessApplicationCache(m_documentLoader->frame()->document()->topOrigin());
+}
+
 }  // namespace WebCore

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h (163913 => 163914)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h	2014-02-11 23:05:06 UTC (rev 163913)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.h	2014-02-11 23:07:49 UTC (rev 163914)
@@ -155,6 +155,7 @@
 
     private:
         bool isApplicationCacheEnabled();
+        bool isApplicationCacheBlockedForRequest(const ResourceRequest&);
         DocumentLoader* documentLoader() const { return m_documentLoader; }
 
         struct DeferredEvent {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to