Diff
Modified: trunk/LayoutTests/ChangeLog (180632 => 180633)
--- trunk/LayoutTests/ChangeLog 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/LayoutTests/ChangeLog 2015-02-25 20:42:28 UTC (rev 180633)
@@ -1,3 +1,15 @@
+2015-02-25 Brady Eidson <beid...@apple.com>
+
+ Layout test support for user content filters
+ https://bugs.webkit.org/show_bug.cgi?id=142018
+
+ Reviewed by Tim Horton.
+
+ * TestExpectations:
+ * http/tests/usercontentfilter/basic-filter.html: Added.
+ * http/tests/usercontentfilter/basic-filter.html.json: Added.
+ * platform/mac-wk2/TestExpectations:
+
2015-02-25 Brent Fulgham <bfulg...@apple.com>
[Win] Skip new <attachment> test since it's not working on Windows.
Modified: trunk/LayoutTests/TestExpectations (180632 => 180633)
--- trunk/LayoutTests/TestExpectations 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/LayoutTests/TestExpectations 2015-02-25 20:42:28 UTC (rev 180633)
@@ -485,3 +485,6 @@
webkit.org/b/141488 fast/replaced/pdf-as-object-and-embed.html [ Skip ]
webkit.org/b/141695 [ Debug ] fast/selectors/nth-last-child-of-register-requirement.html [ Slow ]
+
+# UserContentFilters are Mac-WK2-only for now
+http/tests/usercontentfilter [ Skip ]
Added: trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html (0 => 180633)
--- trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html (rev 0)
+++ trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html 2015-02-25 20:42:28 UTC (rev 180633)
@@ -0,0 +1,4 @@
+<body>
+The image below should not actually load.<br>
+<img src=""
+</body>
Added: trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html.json (0 => 180633)
--- trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html.json (rev 0)
+++ trunk/LayoutTests/http/tests/usercontentfilter/basic-filter.html.json 2015-02-25 20:42:28 UTC (rev 180633)
@@ -0,0 +1,10 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": "http://localhost"
+ }
+ }
+]
\ No newline at end of file
Added: trunk/LayoutTests/platform/mac/http/tests/usercontentfilter/basic-filter-expected.txt (0 => 180633)
--- trunk/LayoutTests/platform/mac/http/tests/usercontentfilter/basic-filter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/http/tests/usercontentfilter/basic-filter-expected.txt 2015-02-25 20:42:28 UTC (rev 180633)
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderText {#text} at (0,0) size 273x18
+ text run at (0,0) width 273: "The image below should not actually load."
+ RenderBR {BR} at (272,14) size 1x0
+ RenderImage {IMG} at (0,18) size 0x0
+ RenderText {#text} at (0,0) size 0x0
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (180632 => 180633)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2015-02-25 20:42:28 UTC (rev 180633)
@@ -521,3 +521,7 @@
### END OF (7) New WebKit2-only failures in Yosemite
########################################
+
+# UserContentFilters are skipped globally, but work on mac-wk2
+http/tests/usercontentfilter [ Pass ]
+
Modified: trunk/Tools/ChangeLog (180632 => 180633)
--- trunk/Tools/ChangeLog 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/Tools/ChangeLog 2015-02-25 20:42:28 UTC (rev 180633)
@@ -1,3 +1,17 @@
+2015-02-25 Brady Eidson <beid...@apple.com>
+
+ Layout test support for user content filters
+ https://bugs.webkit.org/show_bug.cgi?id=142018
+
+ Reviewed by Tim Horton.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::resetStateToConsistentValues): Clear all user content filters between tests.
+
+ * WebKitTestRunner/mac/TestControllerMac.mm:
+ (WTR::TestController::platformConfigureViewForTest): For all tests with usercontentfilter/ in their path try to load a matching .json
+ file before loading the test itself.
+
2015-02-24 Sam Weinig <s...@webkit.org>
Convert WebEditingTester to use xcconfig files
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (180632 => 180633)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2015-02-25 20:42:28 UTC (rev 180633)
@@ -668,6 +668,8 @@
m_shouldLogHistoryClientCallbacks = false;
+ WKPageGroupRemoveAllUserContentFilters(WKPageGetPageGroup(m_mainWebView->page()));
+
// Reset main page back to about:blank
m_doneResetting = false;
Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (180632 => 180633)
--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2015-02-25 18:56:48 UTC (rev 180632)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2015-02-25 20:42:28 UTC (rev 180633)
@@ -32,7 +32,9 @@
#import "TestInvocation.h"
#import "WebKitTestRunnerPasteboard.h"
#import <WebKit/WKStringCF.h>
-#import <mach-o/dyld.h>
+#import <WebKit/WKURLCF.h>
+#import <WebKit/WKUserContentFilterRef.h>
+#import <mach-o/dyld.h>
@interface NSSound (Details)
+ (void)_setAlertType:(NSUInteger)alertType;
@@ -94,6 +96,28 @@
WKDictionarySetItem(viewOptions.get(), useRemoteLayerTreeKey.get(), useRemoteLayerTreeValue.get());
ensureViewSupportsOptions(viewOptions.get());
+
+ WKURLRef url = ""
+ WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url));
+
+ char urlCString[16384];
+ WKStringGetUTF8CString(urlString.get(), urlCString, 16384);
+ if (!strstr(urlCString, "usercontentfilter/"))
+ return;
+
+ RetainPtr<CFURLRef> testURL = adoptCF(WKURLCopyCFURL(kCFAllocatorDefault, url));
+ NSURL *filterURL = [(NSURL *)testURL.get() URLByAppendingPathExtension:@"json"];
+
+ NSStringEncoding encoding;
+ NSString *contentFilterString = [NSString stringWithContentsOfURL:filterURL usedEncoding:&encoding error:NULL];
+ if (!contentFilterString)
+ return;
+
+ WKRetainPtr<WKStringRef> name = adoptWK(WKStringCreateWithUTF8CString("TestContentFilter"));
+ WKRetainPtr<WKStringRef> contentFilterStringWK = adoptWK(WKStringCreateWithCFString((CFStringRef)contentFilterString));
+ WKRetainPtr<WKUserContentFilterRef> filter = adoptWK(WKUserContentFilterCreate(name.get(), contentFilterStringWK.get()));
+
+ WKPageGroupAddUserContentFilter(WKPageGetPageGroup(TestController::singleton().mainWebView()->page()), filter.get());
}
void TestController::platformRunUntil(bool& done, double timeout)