Title: [280277] branches/safari-612.1.24.11-branch
Revision
280277
Author
[email protected]
Date
2021-07-23 18:14:00 -0700 (Fri, 23 Jul 2021)

Log Message

Cherry-pick r280274. rdar://problem/81044139

    Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
    https://bugs.webkit.org/show_bug.cgi?id=228253
    Source/WebKit:

    <rdar://81038849>

    Patch by Alex Christensen <[email protected]> on 2021-07-23
    Reviewed by Brian Weinstein.

    We have an unfortunate situation where an old framework is calling code in a new framework that is giving it a WKContentRuleListStore
    where it expects a _WKUserContentExtensionStore.  As one of several mitigations for this problem, make the selectors able to be called.
    Luckily it doesn't do much with the results.  It just checks if they're null or not, and it passes any errors along.  I added tests that do this.

    * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
    (-[WKContentRuleListStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]):
    (-[WKContentRuleListStore lookupContentExtensionForIdentifier:completionHandler:]):
    (-[WKContentRuleListStore removeContentExtensionForIdentifier:completionHandler:]):

    Tools:

    Patch by Alex Christensen <[email protected]> on 2021-07-23
    Reviewed by Brian Weinstein.

    * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
    (TEST_F):

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

Modified Paths

Diff

Modified: branches/safari-612.1.24.11-branch/Source/WebKit/ChangeLog (280276 => 280277)


--- branches/safari-612.1.24.11-branch/Source/WebKit/ChangeLog	2021-07-24 01:10:45 UTC (rev 280276)
+++ branches/safari-612.1.24.11-branch/Source/WebKit/ChangeLog	2021-07-24 01:14:00 UTC (rev 280277)
@@ -1,3 +1,52 @@
+2021-07-23  Alan Coon  <[email protected]>
+
+        Cherry-pick r280274. rdar://problem/81044139
+
+    Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
+    https://bugs.webkit.org/show_bug.cgi?id=228253
+    Source/WebKit:
+    
+    <rdar://81038849>
+    
+    Patch by Alex Christensen <[email protected]> on 2021-07-23
+    Reviewed by Brian Weinstein.
+    
+    We have an unfortunate situation where an old framework is calling code in a new framework that is giving it a WKContentRuleListStore
+    where it expects a _WKUserContentExtensionStore.  As one of several mitigations for this problem, make the selectors able to be called.
+    Luckily it doesn't do much with the results.  It just checks if they're null or not, and it passes any errors along.  I added tests that do this.
+    
+    * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+    (-[WKContentRuleListStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]):
+    (-[WKContentRuleListStore lookupContentExtensionForIdentifier:completionHandler:]):
+    (-[WKContentRuleListStore removeContentExtensionForIdentifier:completionHandler:]):
+    
+    Tools:
+    
+    Patch by Alex Christensen <[email protected]> on 2021-07-23
+    Reviewed by Brian Weinstein.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+    (TEST_F):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-07-23  Alex Christensen  <[email protected]>
+
+            Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
+            https://bugs.webkit.org/show_bug.cgi?id=228253
+            <rdar://81038849>
+
+            Reviewed by Brian Weinstein.
+
+            We have an unfortunate situation where an old framework is calling code in a new framework that is giving it a WKContentRuleListStore
+            where it expects a _WKUserContentExtensionStore.  As one of several mitigations for this problem, make the selectors able to be called.
+            Luckily it doesn't do much with the results.  It just checks if they're null or not, and it passes any errors along.  I added tests that do this.
+
+            * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+            (-[WKContentRuleListStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]):
+            (-[WKContentRuleListStore lookupContentExtensionForIdentifier:completionHandler:]):
+            (-[WKContentRuleListStore removeContentExtensionForIdentifier:completionHandler:]):
+
 2021-07-19  Ruben Turcios  <[email protected]>
 
         Cherry-pick r280001. rdar://problem/80788656

Modified: branches/safari-612.1.24.11-branch/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm (280276 => 280277)


--- branches/safari-612.1.24.11-branch/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm	2021-07-24 01:10:45 UTC (rev 280276)
+++ branches/safari-612.1.24.11-branch/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm	2021-07-24 01:14:00 UTC (rev 280277)
@@ -30,6 +30,7 @@
 #import "APIContentRuleListStore.h"
 #import "NetworkCacheFileSystem.h"
 #import "WKErrorInternal.h"
+#import "_WKUserContentFilterPrivate.h"
 #import <WebCore/WebCoreObjCExtras.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/CompletionHandler.h>
@@ -172,4 +173,23 @@
     return wrapper(API::ContentRuleListStore::storeWithPath(url.absoluteURL.fileSystemRepresentation));
 }
 
+- (void)compileContentExtensionForIdentifier:(NSString *)identifier encodedContentExtension:(NSString *)encodedContentExtension completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler
+{
+    [self compileContentRuleListForIdentifier:identifier encodedContentRuleList:encodedContentExtension completionHandler:[completionHandler = makeBlockPtr(completionHandler)] (WKContentRuleList *contentRuleList, NSError *error) {
+        completionHandler(contentRuleList ? adoptNS([[_WKUserContentFilter alloc] _initWithWKContentRuleList:contentRuleList]).get() : nil, error);
+    }];
+}
+
+- (void)lookupContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler
+{
+    [self lookUpContentRuleListForIdentifier:identifier completionHandler:[completionHandler = makeBlockPtr(completionHandler)] (WKContentRuleList *contentRuleList, NSError *error) {
+        completionHandler(contentRuleList ? adoptNS([[_WKUserContentFilter alloc] _initWithWKContentRuleList:contentRuleList]).get() : nil, error);
+    }];
+}
+
+- (void)removeContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(NSError *))completionHandler
+{
+    [self removeContentRuleListForIdentifier:identifier completionHandler:completionHandler];
+}
+
 @end

Modified: branches/safari-612.1.24.11-branch/Tools/ChangeLog (280276 => 280277)


--- branches/safari-612.1.24.11-branch/Tools/ChangeLog	2021-07-24 01:10:45 UTC (rev 280276)
+++ branches/safari-612.1.24.11-branch/Tools/ChangeLog	2021-07-24 01:14:00 UTC (rev 280277)
@@ -1,3 +1,45 @@
+2021-07-23  Alan Coon  <[email protected]>
+
+        Cherry-pick r280274. rdar://problem/81044139
+
+    Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
+    https://bugs.webkit.org/show_bug.cgi?id=228253
+    Source/WebKit:
+    
+    <rdar://81038849>
+    
+    Patch by Alex Christensen <[email protected]> on 2021-07-23
+    Reviewed by Brian Weinstein.
+    
+    We have an unfortunate situation where an old framework is calling code in a new framework that is giving it a WKContentRuleListStore
+    where it expects a _WKUserContentExtensionStore.  As one of several mitigations for this problem, make the selectors able to be called.
+    Luckily it doesn't do much with the results.  It just checks if they're null or not, and it passes any errors along.  I added tests that do this.
+    
+    * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
+    (-[WKContentRuleListStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]):
+    (-[WKContentRuleListStore lookupContentExtensionForIdentifier:completionHandler:]):
+    (-[WKContentRuleListStore removeContentExtensionForIdentifier:completionHandler:]):
+    
+    Tools:
+    
+    Patch by Alex Christensen <[email protected]> on 2021-07-23
+    Reviewed by Brian Weinstein.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+    (TEST_F):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-07-23  Alex Christensen  <[email protected]>
+
+            Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
+            https://bugs.webkit.org/show_bug.cgi?id=228253
+
+            Reviewed by Brian Weinstein.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+            (TEST_F):
+
 2021-07-14  Kevin Neal  <[email protected]>
 
         [Tools] linkify first line of commit message in tooltip

Modified: branches/safari-612.1.24.11-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm (280276 => 280277)


--- branches/safari-612.1.24.11-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm	2021-07-24 01:10:45 UTC (rev 280276)
+++ branches/safari-612.1.24.11-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm	2021-07-24 01:14:00 UTC (rev 280277)
@@ -30,6 +30,8 @@
 #import "Test.h"
 #import <WebKit/WKContentRuleList.h>
 #import <WebKit/WKContentRuleListStorePrivate.h>
+#import <WebKit/_WKUserContentExtensionStore.h>
+#import <WebKit/_WKUserContentFilter.h>
 #import <wtf/RetainPtr.h>
 
 class WKContentRuleListStoreTest : public testing::Test {
@@ -434,3 +436,41 @@
     TestWebKitAPI::Util::run(&doneRemoving);
 }
 #endif // PLATFORM(IOS_FAMILY)
+
+TEST_F(WKContentRuleListStoreTest, _WKUserContentExtensionStoreSelectors)
+{
+    [[WKContentRuleListStore defaultStore] _removeAllContentRuleLists];
+    NSString *identifier = @"TestOldSPIMixup";
+
+    __block bool doneCompiling = false;
+    [(_WKUserContentExtensionStore *)[WKContentRuleListStore defaultStore] compileContentExtensionForIdentifier:identifier encodedContentExtension:basicFilter completionHandler:^(_WKUserContentFilter *filter, NSError *error) {
+        EXPECT_NULL(error);
+        EXPECT_NOT_NULL(filter);
+        doneCompiling = true;
+    }];
+    TestWebKitAPI::Util::run(&doneCompiling);
+
+    __block bool doneLookingUp = false;
+    [(_WKUserContentExtensionStore *)[WKContentRuleListStore defaultStore] lookupContentExtensionForIdentifier:identifier completionHandler:^(_WKUserContentFilter *filter, NSError *error) {
+        EXPECT_NULL(error);
+        EXPECT_NOT_NULL(filter);
+        doneLookingUp = true;
+    }];
+    TestWebKitAPI::Util::run(&doneLookingUp);
+
+    __block bool domeRemoving = false;
+    [(_WKUserContentExtensionStore *)[WKContentRuleListStore defaultStore] removeContentExtensionForIdentifier:identifier completionHandler:^(NSError *error) {
+        EXPECT_NULL(error);
+        domeRemoving = true;
+    }];
+    TestWebKitAPI::Util::run(&domeRemoving);
+
+    doneLookingUp = false;
+    [(_WKUserContentExtensionStore *)[WKContentRuleListStore defaultStore] lookupContentExtensionForIdentifier:identifier completionHandler:^(_WKUserContentFilter *filter, NSError *error) {
+        EXPECT_WK_STREQ(error.domain, WKErrorDomain);
+        EXPECT_EQ(error.code, WKErrorContentRuleListStoreLookUpFailed);
+        EXPECT_NULL(filter);
+        doneLookingUp = true;
+    }];
+    TestWebKitAPI::Util::run(&doneLookingUp);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to