Title: [191588] trunk
Revision
191588
Author
[email protected]
Date
2015-10-26 11:24:55 -0700 (Mon, 26 Oct 2015)

Log Message

Don't expose the whitelist/blacklist in _WKUserStyleSheet
https://bugs.webkit.org/show_bug.cgi?id=150566

Reviewed by Anders Carlsson.

Source/WebKit2:

* UIProcess/API/Cocoa/_WKUserStyleSheet.h:
* UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
(-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]):
(toWTFStrings): Deleted.
(-[_WKUserStyleSheet initWithSource:whitelistedURLPatterns:blacklistedURLPatterns:forMainFrameOnly:]): Deleted.
(-[_WKUserStyleSheet whitelistedURLPatterns]): Deleted.
(-[_WKUserStyleSheet blacklistedURLPatterns]): Deleted.

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (191587 => 191588)


--- trunk/Source/WebKit2/ChangeLog	2015-10-26 18:08:50 UTC (rev 191587)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-26 18:24:55 UTC (rev 191588)
@@ -1,3 +1,18 @@
+2015-10-26  Tim Horton  <[email protected]>
+
+        Don't expose the whitelist/blacklist in _WKUserStyleSheet
+        https://bugs.webkit.org/show_bug.cgi?id=150566
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/Cocoa/_WKUserStyleSheet.h:
+        * UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
+        (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]):
+        (toWTFStrings): Deleted.
+        (-[_WKUserStyleSheet initWithSource:whitelistedURLPatterns:blacklistedURLPatterns:forMainFrameOnly:]): Deleted.
+        (-[_WKUserStyleSheet whitelistedURLPatterns]): Deleted.
+        (-[_WKUserStyleSheet blacklistedURLPatterns]): Deleted.
+
 2015-10-25  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK+ build after r191543.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.h (191587 => 191588)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.h	2015-10-26 18:08:50 UTC (rev 191587)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.h	2015-10-26 18:24:55 UTC (rev 191588)
@@ -36,12 +36,9 @@
 
 @property (nonatomic, readonly, copy) NSString *source;
 
-@property (nonatomic, readonly, copy) WK_ARRAY(NSString *) *whitelistedURLPatterns;
-@property (nonatomic, readonly, copy) WK_ARRAY(NSString *) *blacklistedURLPatterns;
-
 @property (nonatomic, readonly, getter=isForMainFrameOnly) BOOL forMainFrameOnly;
 
-- (instancetype)initWithSource:(NSString *)source whitelistedURLPatterns:(WK_ARRAY(NSString *) *)whitelistedURLPatterns blacklistedURLPatterns:(WK_ARRAY(NSString *) *)blacklistedURLPatterns forMainFrameOnly:(BOOL)forMainFrameOnly;
+- (instancetype)initWithSource:(NSString *)source forMainFrameOnly:(BOOL)forMainFrameOnly;
 
 @end
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.mm (191587 => 191588)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.mm	2015-10-26 18:08:50 UTC (rev 191587)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKUserStyleSheet.mm	2015-10-26 18:24:55 UTC (rev 191588)
@@ -34,26 +34,15 @@
 
 @implementation _WKUserStyleSheet
 
-static Vector<String> toWTFStrings(NSArray *strings)
+- (instancetype)initWithSource:(NSString *)source forMainFrameOnly:(BOOL)forMainFrameOnly
 {
-    Vector<String> result;
-    result.reserveInitialCapacity(strings.count);
-
-    for (NSString *string in strings)
-        result.uncheckedAppend(string);
-
-    return result;
-}
-
-- (instancetype)initWithSource:(NSString *)source whitelistedURLPatterns:(NSArray *)whitelistedURLPatterns blacklistedURLPatterns:(NSArray *)blacklistedURLPatterns forMainFrameOnly:(BOOL)forMainFrameOnly
-{
     if (!(self = [super init]))
         return nil;
 
     // FIXME: In the API test, we can use generateUniqueURL below before the API::Object constructor has done this... where should this really be?
     WebKit::InitializeWebKit2();
 
-    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), toWTFStrings(whitelistedURLPatterns), toWTFStrings(blacklistedURLPatterns), forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel });
+    API::Object::constructInWrapper<API::UserStyleSheet>(self, WebCore::UserStyleSheet { WTF::String(source), API::UserStyleSheet::generateUniqueURL(), { }, { }, forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames, WebCore::UserStyleUserLevel });
 
     return self;
 }
@@ -63,16 +52,6 @@
     return _userStyleSheet->userStyleSheet().source();
 }
 
-- (NSArray *)whitelistedURLPatterns
-{
-    return wrapper(API::Array::createStringArray(_userStyleSheet->userStyleSheet().whitelist()));
-}
-
-- (NSArray *)blacklistedURLPatterns
-{
-    return wrapper(API::Array::createStringArray(_userStyleSheet->userStyleSheet().blacklist()));
-}
-
 - (BOOL)isForMainFrameOnly
 {
     return _userStyleSheet->userStyleSheet().injectedFrames() == WebCore::InjectInTopFrameOnly;

Modified: trunk/Tools/ChangeLog (191587 => 191588)


--- trunk/Tools/ChangeLog	2015-10-26 18:08:50 UTC (rev 191587)
+++ trunk/Tools/ChangeLog	2015-10-26 18:24:55 UTC (rev 191588)
@@ -1,3 +1,13 @@
+2015-10-26  Tim Horton  <[email protected]>
+
+        Don't expose the whitelist/blacklist in _WKUserStyleSheet
+        https://bugs.webkit.org/show_bug.cgi?id=150566
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm:
+        (TEST):
+
 2015-10-26  Philippe Normand  <[email protected]>
 
         Unreviewed, rolling out r191576.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm (191587 => 191588)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm	2015-10-26 18:08:50 UTC (rev 191587)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserContentController.mm	2015-10-26 18:24:55 UTC (rev 191588)
@@ -239,7 +239,7 @@
 {
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
 
-    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource whitelistedURLPatterns:@[ ] blacklistedURLPatterns:@[ ] forMainFrameOnly:YES]);
+    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource forMainFrameOnly:YES]);
     [[configuration userContentController] _addUserStyleSheet:styleSheet.get()];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -267,62 +267,17 @@
 
     expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, redInRGB);
 
-    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource whitelistedURLPatterns:@[ ] blacklistedURLPatterns:@[ ] forMainFrameOnly:YES]);
+    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource forMainFrameOnly:YES]);
     [[webView configuration].userContentController _addUserStyleSheet:styleSheet.get()];
 
     expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, greenInRGB);
 }
 
-TEST(WKUserContentController, UserStyleSheetWhiteAndBlackList)
-{
-    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-
-    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource whitelistedURLPatterns:@[ @"http://happy.example.com/", @"http://*.example2.com/" ] blacklistedURLPatterns:@[ @"http://sad.example.com/" ] forMainFrameOnly:YES]);
-    [[configuration userContentController] _addUserStyleSheet:styleSheet.get()];
-
-    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-
-    RetainPtr<SimpleNavigationDelegate> delegate = adoptNS([[SimpleNavigationDelegate alloc] init]);
-    [webView setNavigationDelegate:delegate.get()];
-
-    // Try something on the whitelist:
-
-    [webView loadHTMLString:@"<body style='background-color: red;'></body>" baseURL:[NSURL URLWithString:@"http://happy.example.com/"]];
-    TestWebKitAPI::Util::run(&isDoneWithNavigation);
-    isDoneWithNavigation = false;
-
-    expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, greenInRGB);
-
-    // Try something on the blacklist:
-
-    [webView loadHTMLString:@"<body style='background-color: red;'></body>" baseURL:[NSURL URLWithString:@"http://sad.example.com/"]];
-    TestWebKitAPI::Util::run(&isDoneWithNavigation);
-    isDoneWithNavigation = false;
-
-    expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, redInRGB);
-
-    // Try something on neither list:
-
-    [webView loadHTMLString:@"<body style='background-color: red;'></body>" baseURL:[NSURL URLWithString:@"http://mediocre.example.com/"]];
-    TestWebKitAPI::Util::run(&isDoneWithNavigation);
-    isDoneWithNavigation = false;
-
-    expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, redInRGB);
-
-    // Try something that matches the globbing pattern in the whitelist:
-
-    [webView loadHTMLString:@"<body style='background-color: red;'></body>" baseURL:[NSURL URLWithString:@"http://anything.example2.com/"]];
-    TestWebKitAPI::Util::run(&isDoneWithNavigation);
-    isDoneWithNavigation = false;
-
-    expectScriptEvaluatesToColor(webView.get(), backgroundColorScript, greenInRGB);
-}
-
 TEST(WKUserContentController, UserStyleSheetAffectingOnlyMainFrame)
 {
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
 
-    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource whitelistedURLPatterns:@[ ] blacklistedURLPatterns:@[ ] forMainFrameOnly:YES]);
+    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource forMainFrameOnly:YES]);
     [[configuration userContentController] _addUserStyleSheet:styleSheet.get()];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -345,7 +300,7 @@
 {
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
 
-    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource whitelistedURLPatterns:@[ ] blacklistedURLPatterns:@[ ] forMainFrameOnly:NO]);
+    RetainPtr<_WKUserStyleSheet> styleSheet = adoptNS([[_WKUserStyleSheet alloc] initWithSource:styleSheetSource forMainFrameOnly:NO]);
     [[configuration userContentController] _addUserStyleSheet:styleSheet.get()];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to