Disabled content blockers should not block any loads
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 23:21:14 +0000 (23:21 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Oct 2015 23:21:14 +0000 (23:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150261

Reviewed by Brady Eidson.

This fix was tested manually by reloading without content blockers
on websites with iframes and content blockers that block the contents of the iframes.

* page/UserContentController.cpp:
(WebCore::UserContentController::removeAllUserContentExtensions):
(WebCore::contentExtensionsEnabled):
(WebCore::UserContentController::processContentExtensionRulesForLoad):
(WebCore::UserContentController::actionsForResourceLoad):
Check the DocumentLoader of the main frame when checking if content extensions are disabled,
because that is the DocumentLoader that has the flag from reloading without content blockers.

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

Source/WebCore/ChangeLog
Source/WebCore/page/UserContentController.cpp

index 90aa712..356531b 100644 (file)
@@ -1,3 +1,21 @@
+2015-10-16  Alex Christensen  <achristensen@webkit.org>
+
+        Disabled content blockers should not block any loads
+        https://bugs.webkit.org/show_bug.cgi?id=150261
+
+        Reviewed by Brady Eidson.
+
+        This fix was tested manually by reloading without content blockers
+        on websites with iframes and content blockers that block the contents of the iframes.
+
+        * page/UserContentController.cpp:
+        (WebCore::UserContentController::removeAllUserContentExtensions):
+        (WebCore::contentExtensionsEnabled):
+        (WebCore::UserContentController::processContentExtensionRulesForLoad):
+        (WebCore::UserContentController::actionsForResourceLoad):
+        Check the DocumentLoader of the main frame when checking if content extensions are disabled,
+        because that is the DocumentLoader that has the flag from reloading without content blockers.
+
 2015-10-16  Simon Fraser  <simon.fraser@apple.com>
 
         Make TextStream the canonical way to log classes in WebCore
index 88b6350..ff9e2da 100644 (file)
@@ -208,12 +208,24 @@ void UserContentController::removeAllUserContentExtensions()
     m_contentExtensionBackend->removeAllContentExtensions();
 }
 
+static bool contentExtensionsEnabled(const DocumentLoader& documentLoader)
+{
+    if (auto frame = documentLoader.frame()) {
+        if (frame->isMainFrame())
+            return documentLoader.userContentExtensionsEnabled();
+        if (auto mainDocumentLoader = frame->mainFrame().loader().documentLoader())
+            return mainDocumentLoader->userContentExtensionsEnabled();
+    }
+
+    return true;
+}
+    
 ContentExtensions::BlockedStatus UserContentController::processContentExtensionRulesForLoad(ResourceRequest& request, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
 {
     if (!m_contentExtensionBackend)
         return ContentExtensions::BlockedStatus::NotBlocked;
 
-    if (!initiatingDocumentLoader.userContentExtensionsEnabled())
+    if (!contentExtensionsEnabled(initiatingDocumentLoader))
         return ContentExtensions::BlockedStatus::NotBlocked;
 
     return m_contentExtensionBackend->processContentExtensionRulesForLoad(request, resourceType, initiatingDocumentLoader);
@@ -224,7 +236,7 @@ Vector<ContentExtensions::Action> UserContentController::actionsForResourceLoad(
     if (!m_contentExtensionBackend)
         return Vector<ContentExtensions::Action>();
     
-    if (!initiatingDocumentLoader.userContentExtensionsEnabled())
+    if (!contentExtensionsEnabled(initiatingDocumentLoader))
         return Vector<ContentExtensions::Action>();
 
     return m_contentExtensionBackend->actionsForResourceLoad(resourceLoadInfo);