Unreviewed, rolling out r222455.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 20:38:23 +0000 (20:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 20:38:23 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177460

broke iOS build (Requested by alexchristensen on #webkit).

Reverted changeset:

"Add WKContentRuleList notify action type"
https://bugs.webkit.org/show_bug.cgi?id=177013
http://trac.webkit.org/changeset/222455

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/ContentExtensionActions.h
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionError.cpp
Source/WebCore/contentextensions/ContentExtensionError.h
Source/WebCore/contentextensions/ContentExtensionParser.cpp
Source/WebCore/contentextensions/ContentExtensionRule.cpp
Source/WebCore/contentextensions/ContentExtensionRule.h
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h
Source/WebCore/page/ChromeClient.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/PingLoad.cpp
Source/WebKit/UIProcess/API/APINavigationClient.h
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/C/WKPageNavigationClient.h
Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h
Source/WebKit/UIProcess/Cocoa/NavigationState.h
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm [deleted file]

index ed7dd62..df43e33 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-25  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r222455.
+        https://bugs.webkit.org/show_bug.cgi?id=177460
+
+        broke iOS build (Requested by alexchristensen on #webkit).
+
+        Reverted changeset:
+
+        "Add WKContentRuleList notify action type"
+        https://bugs.webkit.org/show_bug.cgi?id=177013
+        http://trac.webkit.org/changeset/222455
+
 2017-09-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         Building release with -DLOG_DISABLED=0 fails
index cb02ead..27cd84a 100644 (file)
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
-#include <wtf/HashSet.h>
-#include <wtf/text/WTFString.h>
-
 namespace WebCore {
 
-class Page;
 class ResourceRequest;
 
 namespace ContentExtensions {
@@ -43,35 +39,17 @@ enum class ActionType : uint8_t {
     BlockLoad,
     BlockCookies,
     CSSDisplayNoneSelector,
-    Notify,
-    IgnorePreviousRules,
-    MakeHTTPS,
+    IgnorePreviousRules = 3,
+    MakeHTTPS = 4,
 };
 
-static inline bool hasStringArgument(ActionType actionType)
-{
-    switch (actionType) {
-    case ActionType::CSSDisplayNoneSelector:
-    case ActionType::Notify:
-        return true;
-    case ActionType::BlockLoad:
-    case ActionType::BlockCookies:
-    case ActionType::IgnorePreviousRules:
-    case ActionType::MakeHTTPS:
-        return false;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
 struct BlockedStatus {
     bool blockedLoad { false };
     bool blockedCookies { false };
     bool madeHTTPS { false };
-    HashSet<std::pair<String, String>> notifications;
 };
 
-WEBCORE_EXPORT void applyBlockedStatusToRequest(const BlockedStatus&, Page*, ResourceRequest&);
+WEBCORE_EXPORT void applyBlockedStatusToRequest(const BlockedStatus&, ResourceRequest&);
 
 } // namespace ContentExtensions
 
index 56dff6a..fbfecf5 100644 (file)
@@ -68,41 +68,48 @@ static void serializeString(Vector<SerializedActionByte>& actions, const String&
     }
 }
 
-// css-display-none combining is special because we combine the string arguments with commas because we know they are css selectors.
 struct PendingDisplayNoneActions {
-    StringBuilder combinedSelectors;
-    Vector<uint32_t> clientLocations;
+    Vector<String> selectors;
+    Vector<unsigned> clientLocations;
 };
-
 using PendingDisplayNoneActionsMap = HashMap<Trigger, PendingDisplayNoneActions, TriggerHash, TriggerHashTraits>;
 
-static void resolvePendingDisplayNoneActions(Vector<SerializedActionByte>& actions, Vector<uint32_t>& actionLocations, PendingDisplayNoneActionsMap& map)
+static void resolvePendingDisplayNoneActions(Vector<SerializedActionByte>& actions, Vector<unsigned>& actionLocations, PendingDisplayNoneActionsMap& pendingDisplayNoneActionsMap)
 {
-    for (auto& pendingDisplayNoneActions : map.values()) {
-        uint32_t actionLocation = actions.size();
+    for (auto& slot : pendingDisplayNoneActionsMap) {
+        PendingDisplayNoneActions& pendingActions = slot.value;
+
+        StringBuilder combinedSelectors;
+        for (unsigned i = 0; i < pendingActions.selectors.size(); ++i) {
+            if (i)
+                combinedSelectors.append(',');
+            combinedSelectors.append(pendingActions.selectors[i]);
+        }
+
+        unsigned actionLocation = actions.size();
         actions.append(static_cast<SerializedActionByte>(ActionType::CSSDisplayNoneSelector));
-        serializeString(actions, pendingDisplayNoneActions.combinedSelectors.toString());
-        for (uint32_t clientLocation : pendingDisplayNoneActions.clientLocations)
+        serializeString(actions, combinedSelectors.toString());
+        for (unsigned clientLocation : pendingActions.clientLocations)
             actionLocations[clientLocation] = actionLocation;
     }
-    map.clear();
+    pendingDisplayNoneActionsMap.clear();
 }
 
 static Vector<unsigned> serializeActions(const Vector<ContentExtensionRule>& ruleList, Vector<SerializedActionByte>& actions)
 {
     ASSERT(!actions.size());
 
-    Vector<uint32_t> actionLocations;
+    Vector<unsigned> actionLocations;
 
+    // Order only matters because of IgnorePreviousRules. All other identical actions can be combined between each IgnorePreviousRules
+    // and CSSDisplayNone strings can be combined if their triggers are identical.
     using ActionLocation = uint32_t;
     using ActionMap = HashMap<ResourceFlags, ActionLocation, DefaultHash<ResourceFlags>::Hash, WTF::UnsignedWithZeroKeyHashTraits<ResourceFlags>>;
-    using StringActionMap = HashMap<std::pair<String, ResourceFlags>, ActionLocation, DefaultHash<std::pair<String, ResourceFlags>>::Hash, PairHashTraits<HashTraits<String>, WTF::UnsignedWithZeroKeyHashTraits<ResourceFlags>>>;
     ActionMap blockLoadActionsMap;
     ActionMap blockCookiesActionsMap;
     PendingDisplayNoneActionsMap cssDisplayNoneActionsMap;
     ActionMap ignorePreviousRuleActionsMap;
     ActionMap makeHTTPSActionsMap;
-    StringActionMap notifyActionsMap;
 
     for (unsigned ruleIndex = 0; ruleIndex < ruleList.size(); ++ruleIndex) {
         const ContentExtensionRule& rule = ruleList[ruleIndex];
@@ -115,7 +122,6 @@ static Vector<unsigned> serializeActions(const Vector<ContentExtensionRule>& rul
             blockCookiesActionsMap.clear();
             cssDisplayNoneActionsMap.clear();
             makeHTTPSActionsMap.clear();
-            notifyActionsMap.clear();
         } else
             ignorePreviousRuleActionsMap.clear();
 
@@ -125,17 +131,16 @@ static Vector<unsigned> serializeActions(const Vector<ContentExtensionRule>& rul
             actionLocations.append(actions.size());
 
             actions.append(static_cast<SerializedActionByte>(actionType));
-            if (hasStringArgument(actionType))
+            if (actionType == ActionType::CSSDisplayNoneSelector)
                 serializeString(actions, rule.action().stringArgument());
-            else
-                ASSERT(rule.action().stringArgument().isNull());
             continue;
         }
 
         ResourceFlags flags = rule.trigger().flags;
         unsigned actionLocation = std::numeric_limits<unsigned>::max();
         
-        auto findOrMakeActionLocation = [&] (ActionMap& map) {
+        auto findOrMakeActionLocation = [&] (ActionMap& map) 
+        {
             const auto existingAction = map.find(flags);
             if (existingAction == map.end()) {
                 actionLocation = actions.size();
@@ -144,27 +149,13 @@ static Vector<unsigned> serializeActions(const Vector<ContentExtensionRule>& rul
             } else
                 actionLocation = existingAction->value;
         };
-        
-        auto findOrMakeStringActionLocation = [&] (StringActionMap& map) {
-            const String& argument = rule.action().stringArgument();
-            auto existingAction = map.find(std::make_pair(argument, flags));
-            if (existingAction == map.end()) {
-                actionLocation = actions.size();
-                actions.append(static_cast<SerializedActionByte>(actionType));
-                serializeString(actions, argument);
-                map.set(std::make_pair(argument, flags), actionLocation);
-            } else
-                actionLocation = existingAction->value;
-        };
 
         switch (actionType) {
         case ActionType::CSSDisplayNoneSelector: {
             const auto addResult = cssDisplayNoneActionsMap.add(rule.trigger(), PendingDisplayNoneActions());
-            auto& pendingStringActions = addResult.iterator->value;
-            if (!pendingStringActions.combinedSelectors.isEmpty())
-                pendingStringActions.combinedSelectors.append(',');
-            pendingStringActions.combinedSelectors.append(rule.action().stringArgument());
-            pendingStringActions.clientLocations.append(actionLocations.size());
+            PendingDisplayNoneActions& pendingDisplayNoneActions = addResult.iterator->value;
+            pendingDisplayNoneActions.selectors.append(rule.action().stringArgument());
+            pendingDisplayNoneActions.clientLocations.append(actionLocations.size());
 
             actionLocation = std::numeric_limits<unsigned>::max();
             break;
@@ -181,9 +172,6 @@ static Vector<unsigned> serializeActions(const Vector<ContentExtensionRule>& rul
         case ActionType::MakeHTTPS:
             findOrMakeActionLocation(makeHTTPSActionsMap);
             break;
-        case ActionType::Notify:
-            findOrMakeStringActionLocation(notifyActionsMap);
-            break;
         }
 
         actionLocations.append(actionLocation);
index d88d851..04b8f88 100644 (file)
@@ -87,8 +87,6 @@ const std::error_category& contentExtensionErrorCategory()
                 return "A trigger cannot have more than one condition (if-domain, unless-domain, if-top-url, or unless-top-url)";
             case ContentExtensionError::JSONTopURLAndDomainConditions:
                 return "A list cannot have if-domain and unless-domain mixed with if-top-url and unless-top-url";
-            case ContentExtensionError::JSONInvalidNotification:
-                return "A notify action must have a string notification";
             }
 
             return std::string();
index 3ff3e79..7c5c8bb 100644 (file)
@@ -58,7 +58,6 @@ enum class ContentExtensionError {
     JSONInvalidAction,
     JSONInvalidActionType,
     JSONInvalidCSSDisplayNoneActionType,
-    JSONInvalidNotification,
     JSONInvalidRegex,
 };
 
index 4bb1d74..b83c8e9 100644 (file)
@@ -248,11 +248,11 @@ static Expected<std::optional<Action>, std::error_code> loadAction(ExecState& ex
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     const JSValue actionObject = ruleObject.get(&exec, Identifier::fromString(&exec, "action"));
-    if (scope.exception() || !actionObject.isObject())
+    if (!actionObject || scope.exception() || !actionObject.isObject())
         return makeUnexpected(ContentExtensionError::JSONInvalidAction);
 
     const JSValue typeObject = actionObject.get(&exec, Identifier::fromString(&exec, "type"));
-    if (scope.exception() || !typeObject.isString())
+    if (!typeObject || scope.exception() || !typeObject.isString())
         return makeUnexpected(ContentExtensionError::JSONInvalidActionType);
 
     String actionType = asString(typeObject)->value(&exec);
@@ -265,7 +265,7 @@ static Expected<std::optional<Action>, std::error_code> loadAction(ExecState& ex
         return {{ ActionType::BlockCookies }};
     if (actionType == "css-display-none") {
         JSValue selector = actionObject.get(&exec, Identifier::fromString(&exec, "selector"));
-        if (scope.exception() || !selector.isString())
+        if (!selector || scope.exception() || !selector.isString())
             return makeUnexpected(ContentExtensionError::JSONInvalidCSSDisplayNoneActionType);
 
         String selectorString = asString(selector)->value(&exec);
@@ -277,12 +277,6 @@ static Expected<std::optional<Action>, std::error_code> loadAction(ExecState& ex
     }
     if (actionType == "make-https")
         return {{ ActionType::MakeHTTPS }};
-    if (actionType == "notify") {
-        JSValue notification = actionObject.get(&exec, Identifier::fromString(&exec, "notification"));
-        if (scope.exception() || !notification.isString())
-            return makeUnexpected(ContentExtensionError::JSONInvalidNotification);
-        return { Action(ActionType::Notify, asString(notification)->value(&exec)) };
-    }
     return makeUnexpected(ContentExtensionError::JSONInvalidActionType);
 }
 
index 145b6f2..4a258de 100644 (file)
@@ -66,7 +66,6 @@ Action Action::deserialize(const SerializedActionByte* actions, const uint32_t a
     case ActionType::MakeHTTPS:
         return Action(actionType, location);
     case ActionType::CSSDisplayNoneSelector:
-    case ActionType::Notify:
         return Action(actionType, deserializeString(actions, actionsLength, location + sizeof(ActionType)), location);
     }
     RELEASE_ASSERT_NOT_REACHED();
@@ -79,7 +78,6 @@ ActionType Action::deserializeType(const SerializedActionByte* actions, const ui
     switch (type) {
     case ActionType::BlockCookies:
     case ActionType::BlockLoad:
-    case ActionType::Notify:
     case ActionType::IgnorePreviousRules:
     case ActionType::CSSDisplayNoneSelector:
     case ActionType::MakeHTTPS:
@@ -97,7 +95,6 @@ uint32_t Action::serializedLength(const SerializedActionByte* actions, const uin
     case ActionType::IgnorePreviousRules:
     case ActionType::MakeHTTPS:
         return sizeof(ActionType);
-    case ActionType::Notify:
     case ActionType::CSSDisplayNoneSelector: {
         uint32_t prefixLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool);
         uint32_t stringStartIndex = location + prefixLength;
index c686748..78a97b8 100644 (file)
@@ -135,14 +135,14 @@ struct Action {
         , m_actionID(actionID)
         , m_stringArgument(stringArgument)
     {
-        ASSERT(hasStringArgument(type));
+        ASSERT(type == ActionType::CSSDisplayNoneSelector);
     }
 
     Action(ActionType type, uint32_t actionID = std::numeric_limits<uint32_t>::max())
         : m_type(type)
         , m_actionID(actionID)
     {
-        ASSERT(!hasStringArgument(type));
+        ASSERT(type != ActionType::CSSDisplayNoneSelector);
     }
 
     bool operator==(const Action& other) const
index 3072101..b7d2fe6 100644 (file)
@@ -28,8 +28,6 @@
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
-#include "Chrome.h"
-#include "ChromeClient.h"
 #include "CompiledContentExtension.h"
 #include "ContentExtension.h"
 #include "ContentExtensionsDebugging.h"
@@ -40,7 +38,6 @@
 #include "Frame.h"
 #include "FrameLoaderClient.h"
 #include "MainFrame.h"
-#include "Page.h"
 #include "ResourceLoadInfo.h"
 #include "URL.h"
 #include "UserContentController.h"
@@ -173,7 +170,6 @@ BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(cons
     bool willBlockLoad = false;
     bool willBlockCookies = false;
     bool willMakeHTTPS = false;
-    HashSet<std::pair<String, String>> notifications;
     for (const auto& action : actions.first) {
         switch (action.type()) {
         case ContentExtensions::ActionType::BlockLoad:
@@ -188,9 +184,6 @@ BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(cons
             else if (currentDocument)
                 currentDocument->extensionStyleSheets().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
             break;
-        case ContentExtensions::ActionType::Notify:
-            notifications.add(std::make_pair(action.extensionIdentifier(), action.stringArgument()));
-            break;
         case ContentExtensions::ActionType::MakeHTTPS: {
             if ((url.protocolIs("http") || url.protocolIs("ws"))
                 && (!url.port() || isDefaultPortForProtocol(url.port().value(), url.protocol())))
@@ -220,7 +213,7 @@ BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(cons
         if (willBlockLoad)
             currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", url.string()));
     }
-    return { willBlockLoad, willBlockCookies, willMakeHTTPS, WTFMove(notifications) };
+    return { willBlockLoad, willBlockCookies, willMakeHTTPS };
 }
 
 BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForPingLoad(const URL& url, const URL& mainDocumentURL)
@@ -247,14 +240,13 @@ BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForPingLoad(
                 willMakeHTTPS = true;
             break;
         case ContentExtensions::ActionType::CSSDisplayNoneSelector:
-        case ContentExtensions::ActionType::Notify:
             break;
         case ContentExtensions::ActionType::IgnorePreviousRules:
             RELEASE_ASSERT_NOT_REACHED();
         }
     }
 
-    return { willBlockLoad, willBlockCookies, willMakeHTTPS, { } };
+    return { willBlockLoad, willBlockCookies, willMakeHTTPS };
 }
 
 const String& ContentExtensionsBackend::displayNoneCSSRule()
@@ -263,11 +255,8 @@ const String& ContentExtensionsBackend::displayNoneCSSRule()
     return rule;
 }
 
-void applyBlockedStatusToRequest(const BlockedStatus& status, Page* page, ResourceRequest& request)
+void applyBlockedStatusToRequest(const BlockedStatus& status, ResourceRequest& request)
 {
-    if (page && !status.notifications.isEmpty())
-        page->chrome().client().contentRuleListNotification(request.url(), status.notifications);
-
     if (status.blockedCookies)
         request.setAllowCookies(false);
 
index d09933f..4b80c10 100644 (file)
@@ -2780,7 +2780,7 @@ unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& requ
         if (auto* page = m_frame.page()) {
             if (m_documentLoader) {
                 auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(newRequest.url(), ResourceType::Raw, *m_documentLoader);
-                applyBlockedStatusToRequest(blockedStatus, page, newRequest);
+                applyBlockedStatusToRequest(blockedStatus, newRequest);
                 if (blockedStatus.blockedLoad) {
                     newRequest = { };
                     error = ResourceError(errorDomainWebKitInternal, 0, initialRequest.url(), emptyString());
index 80d67e3..53aa257 100644 (file)
@@ -75,7 +75,7 @@ static bool processContentExtensionRulesForLoad(const Frame& frame, ResourceRequ
     if (!page)
         return false;
     auto status = page->userContentProvider().processContentExtensionRulesForLoad(request.url(), resourceType, *documentLoader);
-    applyBlockedStatusToRequest(status, page, request);
+    applyBlockedStatusToRequest(status, request);
     return status.blockedLoad;
 }
 
index a52cc32..d7e2547 100644 (file)
@@ -345,11 +345,11 @@ void ResourceLoader::willSendRequestInternal(ResourceRequest& request, const Res
     }
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    if (!redirectResponse.isNull() && frameLoader()) {
+    if (frameLoader()) {
         Page* page = frameLoader()->frame().page();
         if (page && m_documentLoader) {
             auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(request.url(), m_resourceType, *m_documentLoader);
-            applyBlockedStatusToRequest(blockedStatus, page, request);
+            applyBlockedStatusToRequest(blockedStatus, request);
             if (blockedStatus.blockedLoad) {
                 request = { };
                 didFail(blockedByContentBlockerError());
index 64fa73e..0a678cc 100644 (file)
@@ -725,9 +725,8 @@ ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requ
 #if ENABLE(CONTENT_EXTENSIONS)
     if (frame() && frame()->mainFrame().page() && m_documentLoader) {
         const auto& resourceRequest = request.resourceRequest();
-        auto* page = frame()->mainFrame().page();
-        auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(resourceRequest.url(), toResourceType(type), *m_documentLoader);
-        request.applyBlockedStatus(blockedStatus, page);
+        auto blockedStatus = frame()->mainFrame().page()->userContentProvider().processContentExtensionRulesForLoad(resourceRequest.url(), toResourceType(type), *m_documentLoader);
+        request.applyBlockedStatus(blockedStatus);
         if (blockedStatus.blockedLoad) {
             RELEASE_LOG_IF_ALLOWED("requestResource: Resource blocked by content blocker (frame = %p)", frame());
             if (type == CachedResource::Type::MainResource) {
index 7daed7c..1362c33 100644 (file)
@@ -212,9 +212,9 @@ void CachedResourceRequest::removeFragmentIdentifierIfNeeded()
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
-void CachedResourceRequest::applyBlockedStatus(const ContentExtensions::BlockedStatus& blockedStatus, Page* page)
+void CachedResourceRequest::applyBlockedStatus(const ContentExtensions::BlockedStatus& blockedStatus)
 {
-    ContentExtensions::applyBlockedStatusToRequest(blockedStatus, page, m_resourceRequest);
+    ContentExtensions::applyBlockedStatusToRequest(blockedStatus, m_resourceRequest);
 }
 
 #endif
index 5c8df13..f507fcc 100644 (file)
@@ -76,7 +76,7 @@ public:
     void updateAccordingCacheMode();
     void removeFragmentIdentifierIfNeeded();
 #if ENABLE(CONTENT_EXTENSIONS)
-    void applyBlockedStatus(const ContentExtensions::BlockedStatus&, Page*);
+    void applyBlockedStatus(const ContentExtensions::BlockedStatus&);
 #endif
     void setDomainForCachePartition(Document&);
     void setDomainForCachePartition(const String&);
index 2b69ff9..dcd400a 100644 (file)
@@ -370,8 +370,6 @@ public:
     virtual void enableSuddenTermination() { }
     virtual void disableSuddenTermination() { }
 
-    virtual void contentRuleListNotification(const WebCore::URL&, const HashSet<std::pair<String, String>>&) { };
-
 #if PLATFORM(WIN)
     virtual void setLastSetCursorToCurrentCursor() = 0;
     virtual void AXStartFrameLoad() = 0;
index 8f9eaf6..4880e31 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-25  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r222455.
+        https://bugs.webkit.org/show_bug.cgi?id=177460
+
+        broke iOS build (Requested by alexchristensen on #webkit).
+
+        Reverted changeset:
+
+        "Add WKContentRuleList notify action type"
+        https://bugs.webkit.org/show_bug.cgi?id=177013
+        http://trac.webkit.org/changeset/222455
+
 2017-09-25  Alex Christensen  <achristensen@webkit.org>
 
         Separate form submission from PolicyChecker infrastructure
index d184fff..0942e80 100644 (file)
@@ -324,7 +324,7 @@ ContentExtensions::ContentExtensionsBackend& PingLoad::contentExtensionsBackend(
 ContentExtensions::BlockedStatus PingLoad::processContentExtensionRulesForLoad(ResourceRequest& request)
 {
     auto status = contentExtensionsBackend().processContentExtensionRulesForPingLoad(request.url(), m_parameters.mainDocumentURL);
-    applyBlockedStatusToRequest(status, nullptr, request);
+    applyBlockedStatusToRequest(status, request);
     return status;
 }
 
index e02eb99..61dc71d 100644 (file)
@@ -106,8 +106,6 @@ public:
         listener->use({ });
     }
     
-    virtual void contentRuleListNotification(WebKit::WebPageProxy&, WebCore::URL&&, Vector<WTF::String>&&, Vector<WTF::String>&&) { };
-    
 #if ENABLE(NETSCAPE_PLUGIN_API)
     virtual WebKit::PluginModuleLoadPolicy decidePolicyForPluginLoad(WebKit::WebPageProxy&, WebKit::PluginModuleLoadPolicy currentPluginLoadPolicy, Dictionary*, WTF::String&)
     {
index cc7f6f7..1088612 100644 (file)
@@ -102,7 +102,7 @@ template<> struct ClientTraits<WKPageLoaderClientBase> {
 };
 
 template<> struct ClientTraits<WKPageNavigationClientBase> {
-    typedef std::tuple<WKPageNavigationClientV0, WKPageNavigationClientV1, WKPageNavigationClientV2> Versions;
+    typedef std::tuple<WKPageNavigationClientV0, WKPageNavigationClientV1> Versions;
 };
 
 template<> struct ClientTraits<WKPagePolicyClientBase> {
@@ -2295,21 +2295,6 @@ void WKPageSetPageNavigationClient(WKPageRef pageRef, const WKPageNavigationClie
             m_client.didRemoveNavigationGestureSnapshot(toAPI(&page), m_client.base.clientInfo);
         }
         
-        void contentRuleListNotification(WebPageProxy& page, URL&& url, Vector<String>&& listIdentifiers, Vector<String>&& notifications) final
-        {
-            if (!m_client.contentRuleListNotification)
-                return;
-
-            Vector<RefPtr<API::Object>> apiListIdentifiers;
-            for (const auto& identifier : listIdentifiers)
-                apiListIdentifiers.append(API::String::create(identifier));
-
-            Vector<RefPtr<API::Object>> apiNotifications;
-            for (const auto& notification : notifications)
-                apiNotifications.append(API::String::create(notification));
-
-            m_client.contentRuleListNotification(toAPI(&page), toURLRef(url.string().impl()), toAPI(API::Array::create(WTFMove(apiListIdentifiers)).ptr()), toAPI(API::Array::create(WTFMove(apiNotifications)).ptr()), m_client.base.clientInfo);
-        }
 #if ENABLE(NETSCAPE_PLUGIN_API)
         PluginModuleLoadPolicy decidePolicyForPluginLoad(WebPageProxy& page, PluginModuleLoadPolicy currentPluginLoadPolicy, API::Dictionary* pluginInformation, String& unavailabilityDescription) override
         {
index 14843d2..ed1548f 100644 (file)
@@ -80,7 +80,6 @@ typedef void (*WKPageNavigationDidEndNavigationGesture)(WKPageRef page, WKBackFo
 
 typedef void (*WKPageNavigationDidRemoveNavigationGestureSnapshot)(WKPageRef page, const void* clientInfo);
 
-typedef void (*WKPageNavigationContentRuleListNotificationCallback)(WKPageRef, WKURLRef, WKArrayRef, WKArrayRef, const void* clientInfo);
 
 typedef struct WKPageNavigationClientBase {
     int version;
@@ -144,39 +143,6 @@ typedef struct WKPageNavigationClientV1 {
     WKPageNavigationWebProcessDidTerminateCallback webProcessDidTerminate;
 } WKPageNavigationClientV1;
 
-typedef struct WKPageNavigationClientV2 {
-    WKPageNavigationClientBase base;
-    
-    // Version 0.
-    WKPageNavigationDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
-    WKPageNavigationDecidePolicyForNavigationResponseCallback decidePolicyForNavigationResponse;
-    WKPageNavigationDecidePolicyForPluginLoadCallback decidePolicyForPluginLoad;
-    WKPageNavigationDidStartProvisionalNavigationCallback didStartProvisionalNavigation;
-    WKPageNavigationDidReceiveServerRedirectForProvisionalNavigationCallback didReceiveServerRedirectForProvisionalNavigation;
-    WKPageNavigationDidFailProvisionalNavigationCallback didFailProvisionalNavigation;
-    WKPageNavigationDidCommitNavigationCallback didCommitNavigation;
-    WKPageNavigationDidFinishNavigationCallback didFinishNavigation;
-    WKPageNavigationDidFailNavigationCallback didFailNavigation;
-    WKPageNavigationDidFailProvisionalLoadInSubframeCallback didFailProvisionalLoadInSubframe;
-    WKPageNavigationDidFinishDocumentLoadCallback didFinishDocumentLoad;
-    WKPageNavigationDidSameDocumentNavigationCallback didSameDocumentNavigation;
-    WKPageNavigationRenderingProgressDidChangeCallback renderingProgressDidChange;
-    WKPageNavigationCanAuthenticateAgainstProtectionSpaceCallback canAuthenticateAgainstProtectionSpace;
-    WKPageNavigationDidReceiveAuthenticationChallengeCallback didReceiveAuthenticationChallenge;
-    WKPageNavigationWebProcessDidCrashCallback webProcessDidCrash;
-    WKPageNavigationCopyWebCryptoMasterKeyCallback copyWebCryptoMasterKey;
-    WKPageNavigationDidBeginNavigationGesture didBeginNavigationGesture;
-    WKPageNavigationWillEndNavigationGesture willEndNavigationGesture;
-    WKPageNavigationDidEndNavigationGesture didEndNavigationGesture;
-    WKPageNavigationDidRemoveNavigationGestureSnapshot didRemoveNavigationGestureSnapshot;
-    
-    // Version 1.
-    WKPageNavigationWebProcessDidTerminateCallback webProcessDidTerminate;
-
-    // Version 2.
-    WKPageNavigationContentRuleListNotificationCallback contentRuleListNotification;
-} WKPageNavigationClientV2;
-
 #ifdef __cplusplus
 }
 #endif
index 1dcfd28..c74a2e8 100644 (file)
@@ -78,8 +78,6 @@ static const WKNavigationResponsePolicy _WKNavigationResponsePolicyBecomeDownloa
 - (void)_webViewDidRemoveNavigationGestureSnapshot:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
 
-- (void)_webView:(WKWebView *)webView URL:(NSURL *)url contentRuleListIdentifiers:(NSArray<NSString *> *)identifiers notifications:(NSArray<NSString *> *)notifications WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-
 #if TARGET_OS_IPHONE
 - (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti;
 - (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData;
index 4b4b720..807860b 100644 (file)
@@ -121,7 +121,6 @@ private:
         void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
 #endif
 
-        void contentRuleListNotification(WebPageProxy&, WebCore::URL&&, Vector<String>&&, Vector<String>&&) final;
         void decidePolicyForNavigationAction(WebPageProxy&, Ref<API::NavigationAction>&&, Ref<WebFramePolicyListenerProxy>&&, API::Object* userData) override;
         void decidePolicyForNavigationResponse(WebPageProxy&, API::NavigationResponse&, Ref<WebFramePolicyListenerProxy>&&, API::Object* userData) override;
 
@@ -202,7 +201,6 @@ private:
         bool webViewDidEndNavigationGestureWithNavigationToBackForwardListItem : 1;
         bool webViewWillSnapshotBackForwardListItem : 1;
         bool webViewNavigationGestureSnapshotWasRemoved : 1;
-        bool webViewURLContentRuleListIdentifiersNotifications : 1;
 #if USE(QUICK_LOOK)
         bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
         bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;
index aa79fcd..a91afb4 100644 (file)
@@ -168,7 +168,6 @@ void NavigationState::setNavigationDelegate(id <WKNavigationDelegate> delegate)
     m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewDidEndNavigationGesture:withNavigationToBackForwardListItem:)];
     m_navigationDelegateMethods.webViewWillSnapshotBackForwardListItem = [delegate respondsToSelector:@selector(_webView:willSnapshotBackForwardListItem:)];
     m_navigationDelegateMethods.webViewNavigationGestureSnapshotWasRemoved = [delegate respondsToSelector:@selector(_webViewDidRemoveNavigationGestureSnapshot:)];
-    m_navigationDelegateMethods.webViewURLContentRuleListIdentifiersNotifications = [delegate respondsToSelector:@selector(_webView:URL:contentRuleListIdentifiers:notifications:)];
 #if USE(QUICK_LOOK)
     m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:)];
     m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didFinishLoadForQuickLookDocumentInMainFrame:)];
@@ -459,28 +458,6 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
     }
 }
 
-void NavigationState::NavigationClient::contentRuleListNotification(WebPageProxy&, WebCore::URL&& url, Vector<String>&& listIdentifiers, Vector<String>&& notifications)
-{
-    if (!m_navigationState.m_navigationDelegateMethods.webViewURLContentRuleListIdentifiersNotifications)
-        return;
-
-    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
-    if (!navigationDelegate)
-        return;
-
-    ASSERT(listIdentifiers.size() == notifications.size());
-
-    auto identifiers = adoptNS([[NSMutableArray alloc] initWithCapacity:listIdentifiers.size()]);
-    for (auto& identifier : listIdentifiers)
-        [identifiers addObject:identifier];
-
-    auto nsNotifications = adoptNS([[NSMutableArray alloc] initWithCapacity:notifications.size()]);
-    for (auto& notification : notifications)
-        [nsNotifications addObject:notification];
-    
-    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView URL:url contentRuleListIdentifiers:identifiers.get() notifications:nsNotifications.get()];
-}
-    
 void NavigationState::NavigationClient::decidePolicyForNavigationResponse(WebPageProxy&, API::NavigationResponse& navigationResponse, Ref<WebFramePolicyListenerProxy>&& listener, API::Object* userData)
 {
     if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationResponseDecisionHandler) {
index 3692650..2a7f605 100644 (file)
@@ -3787,12 +3787,6 @@ void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, cons
     });
 }
 
-void WebPageProxy::contentRuleListNotification(WebCore::URL&& url, Vector<String>&& identifiers, Vector<String>&& notifications)
-{
-    if (m_navigationClient)
-        m_navigationClient->contentRuleListNotification(*this, WTFMove(url), WTFMove(identifiers), WTFMove(notifications));
-}
-    
 void WebPageProxy::didNavigateWithNavigationData(const WebNavigationDataStore& store, uint64_t frameID) 
 {
     PageClientProtector protector(m_pageClient);
index 02f7299..7152822 100644 (file)
@@ -1286,8 +1286,6 @@ private:
     void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, const UserData&);
 
     void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData&);
-        
-    void contentRuleListNotification(WebCore::URL&&, Vector<String>&& identifiers, Vector<String>&& notifications);
 
     // History client
     void didNavigateWithNavigationData(const WebNavigationDataStore&, uint64_t frameID);
index ccb1254..ca2a0f2 100644 (file)
@@ -458,7 +458,6 @@ messages -> WebPageProxy {
     HandleSynchronousMessage(String messageName, WebKit::UserData messageBody) -> (WebKit::UserData returnData) WantsConnection
 
     HandleAutoFillButtonClick(WebKit::UserData userData);
-    ContentRuleListNotification(WebCore::URL url, Vector<String> identifiers, Vector<String> notifications)
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
     AddPlaybackTargetPickerClient(uint64_t contextId)
index 295fbb1..05c8f87 100644 (file)
@@ -874,20 +874,6 @@ void WebChromeClient::scheduleCompositingLayerFlush()
         m_page.drawingArea()->scheduleCompositingLayerFlush();
 }
 
-void WebChromeClient::contentRuleListNotification(const URL& url, const HashSet<std::pair<String, String>>& notificationPairs)
-{
-    Vector<String> identifiers;
-    Vector<String> notifications;
-    identifiers.reserveInitialCapacity(notificationPairs.size());
-    notifications.reserveInitialCapacity(notificationPairs.size());
-    for (auto& notification : notificationPairs) {
-        identifiers.uncheckedAppend(notification.first);
-        notifications.uncheckedAppend(notification.second);
-    }
-
-    m_page.send(Messages::WebPageProxy::ContentRuleListNotification(url, identifiers, notifications));
-}
-
 bool WebChromeClient::adjustLayerFlushThrottling(LayerFlushThrottleState::Flags flags)
 {
     return m_page.drawingArea() && m_page.drawingArea()->adjustLayerFlushThrottling(flags);
index d95e8ca..d44afd8 100644 (file)
@@ -208,8 +208,6 @@ private:
     void scheduleCompositingLayerFlush() final;
     bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) final;
 
-    void contentRuleListNotification(const WebCore::URL&, const HashSet<std::pair<String, String>>&) final;
-    
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) const final;
 #endif
index de17d59..aeb4fee 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-25  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r222455.
+        https://bugs.webkit.org/show_bug.cgi?id=177460
+
+        broke iOS build (Requested by alexchristensen on #webkit).
+
+        Reverted changeset:
+
+        "Add WKContentRuleList notify action type"
+        https://bugs.webkit.org/show_bug.cgi?id=177013
+        http://trac.webkit.org/changeset/222455
+
 2017-09-25  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] run-api-tests is failing.
index ce10be9..ae89428 100644 (file)
                5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */; };
                5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */; };
                5CA1DEC81F71F70100E71BD3 /* HTTPHeaderField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CA1DEC71F71F40700E71BD3 /* HTTPHeaderField.cpp */; };
-               5CA1DED91F74A91A00E71BD3 /* ContentRuleListNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CA1DED81F74A87100E71BD3 /* ContentRuleListNotification.mm */; };
                5CB18BA81F5645E300EE23C4 /* ClickAutoFillButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */; };
                5CB40B4E1F4B98D3007DC7B9 /* UIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */; };
                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
                5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ApplicationCache.db-shm"; sourceTree = "<group>"; };
                5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ApplicationCache.db-wal"; sourceTree = "<group>"; };
                5CA1DEC71F71F40700E71BD3 /* HTTPHeaderField.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderField.cpp; sourceTree = "<group>"; };
-               5CA1DED81F74A87100E71BD3 /* ContentRuleListNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentRuleListNotification.mm; sourceTree = "<group>"; };
                5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClickAutoFillButton.mm; sourceTree = "<group>"; };
                5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIDelegate.mm; sourceTree = "<group>"; };
                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
                                A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */,
                                A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
                                A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
-                               5CA1DED81F74A87100E71BD3 /* ContentRuleListNotification.mm */,
                                5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */,
                                9999108A1F393C8B008AD455 /* Copying.mm */,
                                2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */,
                                7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */,
                                A1146A8D1D2D7115000FE710 /* ContentFiltering.mm in Sources */,
                                A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */,
-                               5CA1DED91F74A91A00E71BD3 /* ContentRuleListNotification.mm in Sources */,
                                7CCE7EB81A411A7E00447C4C /* ContextMenuCanCopyURL.mm in Sources */,
                                37FB72971DB2E82F00E41BE4 /* ContextMenuDefaultItemsHaveTags.mm in Sources */,
                                8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
index dcce468..ea079ac 100644 (file)
@@ -56,8 +56,6 @@ inline std::ostream& operator<<(std::ostream& os, const ActionType& action)
         return os << "ActionType::BlockCookies";
     case ActionType::CSSDisplayNoneSelector:
         return os << "ActionType::CSSDisplayNone";
-    case ActionType::Notify:
-        return os << "ActionType::Notify";
     case ActionType::IgnorePreviousRules:
         return os << "ActionType::IgnorePreviousRules";
     case ActionType::MakeHTTPS:
@@ -99,7 +97,6 @@ public:
         EXPECT_EQ(data.topURLFilters.size(), 0ull);
     }
 
-private:
     void writeSource(const String&) final { }
 
     void writeActions(Vector<ContentExtensions::SerializedActionByte>&& actions, bool conditionsApplyOnlyToDomain) final
@@ -140,27 +137,35 @@ private:
         finalized = true;
     }
 
+private:
     CompiledContentExtensionData& m_data;
     bool finalized { false };
 };
 
 class InMemoryCompiledContentExtension : public ContentExtensions::CompiledContentExtension {
 public:
-    static Ref<InMemoryCompiledContentExtension> create(String&& filter)
+    static Ref<InMemoryCompiledContentExtension> createFromFilter(String&& filter)
     {
         CompiledContentExtensionData extensionData;
         InMemoryContentExtensionCompilationClient client(extensionData);
         auto compilerError = ContentExtensions::compileRuleList(client, WTFMove(filter));
+        if (compilerError) {
+            // Compiling should always succeed here. We have other tests for compile failures.
+            EXPECT_TRUE(false);
+        }
 
-        // Compiling should always succeed here. We have other tests for compile failures.
-        EXPECT_FALSE(compilerError);
+        return InMemoryCompiledContentExtension::create(WTFMove(extensionData));
+    }
 
-        return adoptRef(*new InMemoryCompiledContentExtension(WTFMove(extensionData)));
+    static Ref<InMemoryCompiledContentExtension> create(CompiledContentExtensionData&& data)
+    {
+        return adoptRef(*new InMemoryCompiledContentExtension(WTFMove(data)));
     }
 
-    const CompiledContentExtensionData& data() { return m_data; };
+    virtual ~InMemoryCompiledContentExtension()
+    {
+    }
 
-private:
     const ContentExtensions::SerializedActionByte* actions() const final { return m_data.actions.data(); }
     unsigned actionsLength() const final { return m_data.actions.size(); }
     const ContentExtensions::DFABytecode* filtersWithoutConditionsBytecode() const final { return m_data.filtersWithoutConditions.data(); }
@@ -171,9 +176,11 @@ private:
     unsigned topURLFiltersBytecodeLength() const final { return m_data.topURLFilters.size(); }
     bool conditionsApplyOnlyToDomain() const final { return m_data.conditionsApplyOnlyToDomain; }
 
+private:
     InMemoryCompiledContentExtension(CompiledContentExtensionData&& data)
         : m_data(WTFMove(data))
-    { }
+    {
+    }
 
     CompiledContentExtensionData m_data;
 };
@@ -204,7 +211,7 @@ static ResourceLoadInfo subResourceRequest(const char* url, const char* mainDocu
 ContentExtensions::ContentExtensionsBackend makeBackend(const char* json)
 {
     AtomicString::init();
-    auto extension = InMemoryCompiledContentExtension::create(json);
+    auto extension = InMemoryCompiledContentExtension::createFromFilter(json);
     ContentExtensions::ContentExtensionsBackend backend;
     backend.addContentExtension("testFilter", WTFMove(extension));
     return backend;
@@ -849,8 +856,8 @@ TEST_F(ContentExtensionTest, TopURL)
 
 TEST_F(ContentExtensionTest, MultipleExtensions)
 {
-    auto extension1 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"block_load\"}}]");
-    auto extension2 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}}]");
+    auto extension1 = InMemoryCompiledContentExtension::createFromFilter("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"block_load\"}}]");
+    auto extension2 = InMemoryCompiledContentExtension::createFromFilter("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}}]");
     ContentExtensions::ContentExtensionsBackend backend;
     backend.addContentExtension("testFilter1", WTFMove(extension1));
     backend.addContentExtension("testFilter2", WTFMove(extension2));
@@ -861,9 +868,9 @@ TEST_F(ContentExtensionTest, MultipleExtensions)
     testRequest(backend, mainDocumentRequest("http://webkit.org/block_load/block_cookies.html"), { ContentExtensions::ActionType::BlockCookies, ContentExtensions::ActionType::BlockLoad }, 2);
     testRequest(backend, mainDocumentRequest("http://webkit.org/block_cookies/block_load.html"), { ContentExtensions::ActionType::BlockCookies, ContentExtensions::ActionType::BlockLoad }, 2);
     
-    auto ignoreExtension1 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"block_load\"}},"
+    auto ignoreExtension1 = InMemoryCompiledContentExtension::createFromFilter("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"block_load\"}},"
         "{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"ignore1\"}}]");
-    auto ignoreExtension2 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}},"
+    auto ignoreExtension2 = InMemoryCompiledContentExtension::createFromFilter("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}},"
         "{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"ignore2\"}}]");
     ContentExtensions::ContentExtensionsBackend backendWithIgnore;
     backendWithIgnore.addContentExtension("testFilter1", WTFMove(ignoreExtension1));
@@ -877,121 +884,6 @@ TEST_F(ContentExtensionTest, MultipleExtensions)
     testRequest(backendWithIgnore, mainDocumentRequest("http://webkit.org/block_load/block_cookies/ignore1/ignore2.html"), { }, 0);
 }
 
-static bool actionsEqual(const std::pair<Vector<WebCore::ContentExtensions::Action>, Vector<String>>& actual, Vector<WebCore::ContentExtensions::Action>&& expected, bool ignorePreviousRules = false)
-{
-    if (ignorePreviousRules) {
-        if (actual.second.size())
-            return false;
-    } else {
-        if (actual.second.size() != 1)
-            return false;
-        if (actual.second[0] != "testFilter")
-            return false;
-    }
-
-    if (actual.first.size() != expected.size())
-        return false;
-    for (size_t i = 0; i < expected.size(); ++i) {
-        if (actual.first[i].type() != expected[i].type())
-            return false;
-        if (actual.first[i].stringArgument() != expected[i].stringArgument())
-            return false;
-    }
-    return true;
-}
-
-static const char* jsonWithStringsToCombine = "["
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"A\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"A\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"BBB\"},\"trigger\":{\"url-filter\":\"B\"}},"
-    "{\"action\":{\"type\":\"css-display-none\",\"selector\":\"CCC\"},\"trigger\":{\"url-filter\":\"C\"}},"
-    "{\"action\":{\"type\":\"css-display-none\",\"selector\":\"selectorCombinedWithC\"},\"trigger\":{\"url-filter\":\"C\"}},"
-    "{\"action\":{\"type\":\"css-display-none\",\"selector\":\"DDD\"},\"trigger\":{\"url-filter\":\"D\"}},"
-    "{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"E\"}},"
-    "{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"F\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"GGG\"},\"trigger\":{\"url-filter\":\"G\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"GGG\"},\"trigger\":{\"url-filter\":\"I\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"J\"}},"
-    "{\"action\":{\"type\":\"notify\",\"notification\":\"GGG\"},\"trigger\":{\"url-filter\":\"K\"}}"
-"]";
-
-TEST_F(ContentExtensionTest, StringParameters)
-{
-    auto backend1 = makeBackend("[{\"action\":{\"type\":\"notify\",\"notification\":\"testnotification\"},\"trigger\":{\"url-filter\":\"matches\"}}]");
-    ASSERT_TRUE(actionsEqual(backend1.actionsForResourceLoad(mainDocumentRequest("test:///matches")), {{ ContentExtensions::ActionType::Notify, "testnotification" }}));
-
-    auto backend2 = makeBackend(jsonWithStringsToCombine);
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://A")), {{ ContentExtensions::ActionType::Notify, "AAA" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://B")), {{ ContentExtensions::ActionType::Notify, "BBB" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://C")), {{ ContentExtensions::ActionType::CSSDisplayNoneSelector, "CCC,selectorCombinedWithC" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://D")), {{ ContentExtensions::ActionType::CSSDisplayNoneSelector, "DDD" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://E")), { }, true));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://F")), { ContentExtensions::ActionType::BlockLoad }));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://G")), {{ ContentExtensions::ActionType::Notify, "GGG" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://GIK")), {{ ContentExtensions::ActionType::Notify, "GGG" }}));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://AJ")), {
-        { ContentExtensions::ActionType::Notify, "AAA" },
-        { ContentExtensions::ActionType::Notify, "AAA" } // ignore-previous-rules makes the AAA actions need to be unique.
-    }));
-    // FIXME: Add a test that matches actions with AAA with ignore-previous-rules between them and makes sure we only get one notification.
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://AE")), { }, true));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://ABCDE")), { }, true));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://ABCDEFG")), {
-        { ContentExtensions::ActionType::Notify, "GGG" },
-        { ContentExtensions::ActionType::BlockLoad }
-    }, true));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://FG")), {
-        { ContentExtensions::ActionType::Notify, "GGG" },
-        { ContentExtensions::ActionType::BlockLoad }
-    }));
-    ASSERT_TRUE(actionsEqual(backend2.actionsForResourceLoad(mainDocumentRequest("http://EFG")), {
-        { ContentExtensions::ActionType::Notify, "GGG" },
-        { ContentExtensions::ActionType::BlockLoad }
-    }, true));
-}
-
-template<typename T, size_t cStringLength>
-static int sequenceInstances(const Vector<T> vector, const char (&sequence)[cStringLength])
-{
-    static_assert(sizeof(T) == sizeof(char), "sequenceInstances should only be used for various byte vectors.");
-
-    size_t sequenceLength = cStringLength - 1;
-    size_t instances = 0;
-    for (size_t i = 0; i <= vector.size() - sequenceLength; ++i) {
-        for (size_t j = 0; j < sequenceLength; j++) {
-            if (vector[i + j] != sequence[j])
-                break;
-            if (j == sequenceLength - 1)
-                instances++;
-        }
-    }
-    return instances;
-}
-
-TEST_F(ContentExtensionTest, StringCombining)
-{
-    auto extension = InMemoryCompiledContentExtension::create(jsonWithStringsToCombine);
-    const auto& data = extension->data();
-
-    ASSERT_EQ(sequenceInstances(data.actions, "AAA"), 2);
-    ASSERT_EQ(sequenceInstances(data.actions, "GGG"), 1);
-
-    ASSERT_EQ(data.actions.size(), 78u);
-    ASSERT_EQ(data.filtersWithoutConditions.size(),  313u);
-    ASSERT_EQ(data.filtersWithConditions.size(),  5u);
-    ASSERT_EQ(data.topURLFilters.size(),  5u);
-    ASSERT_FALSE(data.conditionsApplyOnlyToDomain);
-
-    auto extensionWithFlags = InMemoryCompiledContentExtension::create("["
-        "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"A\"}},"
-        "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"C\"}},"
-        "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"A\",\"resource-type\":[\"document\"]}},"
-        "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"A\",\"resource-type\":[\"document\",\"font\"]}},"
-        "{\"action\":{\"type\":\"notify\",\"notification\":\"AAA\"},\"trigger\":{\"url-filter\":\"B\",\"resource-type\":[\"document\"]}}"
-    "]");
-    ASSERT_EQ(sequenceInstances(extensionWithFlags->data().actions, "AAA"), 3); // There are 3 sets of unique flags for AAA actions.
-}
-
 TEST_F(ContentExtensionTest, TermsKnownToMatchAnything)
 {
     auto backend = makeBackend("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"^pre1.*post1$\"}},"
@@ -1485,12 +1377,6 @@ TEST_F(ContentExtensionTest, InvalidJSON)
     checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"resource-type\":false}}]",
         ContentExtensions::ContentExtensionError::JSONInvalidTriggerFlagsArray);
     
-    checkCompilerError("[{\"action\":{\"type\":\"notify\"},\"trigger\":{\"url-filter\":\".*\"}}]", ContentExtensions::ContentExtensionError::JSONInvalidNotification);
-    checkCompilerError("[{\"action\":{\"type\":\"notify\",\"notification\":5},\"trigger\":{\"url-filter\":\".*\"}}]", ContentExtensions::ContentExtensionError::JSONInvalidNotification);
-    checkCompilerError("[{\"action\":{\"type\":\"notify\",\"notification\":[]},\"trigger\":{\"url-filter\":\".*\"}}]", ContentExtensions::ContentExtensionError::JSONInvalidNotification);
-    checkCompilerError("[{\"action\":{\"type\":\"notify\",\"notification\":\"here's my notification\"},\"trigger\":{\"url-filter\":\".*\"}}]", { });
-    checkCompilerError("[{\"action\":{\"type\":\"notify\",\"notification\":\"\\u1234\"},\"trigger\":{\"url-filter\":\".*\"}}]", { });
-    
     StringBuilder rules;
     rules.append("[");
     for (unsigned i = 0; i < 49999; ++i)
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm
deleted file mode 100644 (file)
index aa0e483..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#if WK_API_ENABLED
-
-#import "PlatformUtilities.h"
-#import <WebKit/WKContentRuleListStore.h>
-#import <WebKit/WKNavigationDelegatePrivate.h>
-#import <WebKit/WKURLSchemeHandler.h>
-#import <WebKit/WKUserContentController.h>
-#import <WebKit/WKWebView.h>
-#import <wtf/RetainPtr.h>
-
-static bool receivedNotification;
-static bool receivedAlert;
-
-@interface ContentRuleListNotificationDelegate : NSObject <WKNavigationDelegatePrivate, WKURLSchemeHandler, WKUIDelegate>
-@end
-
-@implementation ContentRuleListNotificationDelegate
-
-- (void)_webView:(WKWebView *)webView URL:(NSURL *)url contentRuleListIdentifiers:(NSArray<NSString *> *)identifiers notifications:(NSArray<NSString *> *)notifications
-{
-    EXPECT_STREQ(url.absoluteString.UTF8String, "apitest:///match");
-    EXPECT_EQ(identifiers.count, 1u);
-    EXPECT_STREQ([identifiers objectAtIndex:0].UTF8String, "testidentifier");
-    EXPECT_EQ(notifications.count, 1u);
-    EXPECT_STREQ([notifications objectAtIndex:0].UTF8String, "testnotification");
-    receivedNotification = true;
-}
-
-- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
-{
-    [urlSchemeTask didReceiveResponse:[[[NSURLResponse alloc] initWithURL:urlSchemeTask.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil] autorelease]];
-    [urlSchemeTask didFinish];
-}
-
-- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
-{
-}
-
-- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
-{
-    receivedAlert = true;
-    completionHandler();
-}
-
-@end
-
-static RetainPtr<WKContentRuleList> makeWarnContentRuleList()
-{
-    __block bool doneCompiling = false;
-    __block RetainPtr<WKContentRuleList> contentRuleList;
-    [[WKContentRuleListStore defaultStore] compileContentRuleListForIdentifier:@"testidentifier" encodedContentRuleList:@"[{\"action\":{\"type\":\"notify\",\"notification\":\"testnotification\"},\"trigger\":{\"url-filter\":\"match\"}}]" completionHandler:^(WKContentRuleList *list, NSError *error) {
-        EXPECT_TRUE(list);
-        contentRuleList = list;
-        doneCompiling = true;
-    }];
-    TestWebKitAPI::Util::run(&doneCompiling);
-    return contentRuleList;
-}
-
-TEST(WebKit, ContentRuleListNotificationMainResource)
-{
-    auto delegate = adoptNS([[ContentRuleListNotificationDelegate alloc] init]);
-    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    [[configuration userContentController] addContentRuleList:makeWarnContentRuleList().get()];
-    [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"apitest"];
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    [webView setNavigationDelegate:delegate.get()];
-    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"apitest:///match"]]];
-    TestWebKitAPI::Util::run(&receivedNotification);
-}
-
-TEST(WebKit, ContentRuleListNotificationSubresource)
-{
-    auto delegate = adoptNS([[ContentRuleListNotificationDelegate alloc] init]);
-    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    [[configuration userContentController] addContentRuleList:makeWarnContentRuleList().get()];
-    [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"apitest"];
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-    [webView setNavigationDelegate:delegate.get()];
-    [webView setUIDelegate:delegate.get()];
-    [webView loadHTMLString:@"<script>fetch('match').then(function(response){alert('fetch complete')})</script>" baseURL:[NSURL URLWithString:@"apitest:///"]];
-    TestWebKitAPI::Util::run(&receivedAlert);
-    EXPECT_TRUE(receivedNotification);
-}
-
-#endif // WK_API_ENABLED