Make WebKit.LinkColorWithSystemAppearance work across system versions.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2018 18:37:47 +0000 (18:37 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2018 18:37:47 +0000 (18:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187573

Reviewed by Wenson Hsieh.

* TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm:
(TestWebKitAPI.WebKit.LinkColorWithSystemAppearance): Dynamically generate the expected string.

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

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm

index d2e35de..1b0d864 100644 (file)
@@ -1,3 +1,13 @@
+2018-07-12  Timothy Hatcher  <timothy@apple.com>
+
+        Make WebKit.LinkColorWithSystemAppearance work across system versions.
+        https://bugs.webkit.org/show_bug.cgi?id=187573
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm:
+        (TestWebKitAPI.WebKit.LinkColorWithSystemAppearance): Dynamically generate the expected string.
+
 2018-07-11  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [WPE] Pass the backend library name as command line parameter to the web process
index a78e8e0..fe49e30 100644 (file)
 #import <WebKit/WKWebViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
+#if PLATFORM(MAC)
+#import <pal/spi/cocoa/NSColorSPI.h>
+#endif
+
 namespace TestWebKitAPI {
 
 TEST(WebKit, LinkColor)
@@ -52,8 +56,16 @@ TEST(WebKit, LinkColorWithSystemAppearance)
 
     [webView synchronouslyLoadHTMLString:@"<a href>Test</a>"];
 
-    NSString *linkColor = [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.links[0]).color"];
-    EXPECT_WK_STREQ("rgb(0, 104, 218)", linkColor);
+    NSColor *linkColor = [NSColor.linkColor colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
+
+    CGFloat red = linkColor.redComponent * 255;
+    CGFloat green = linkColor.greenComponent * 255;
+    CGFloat blue = linkColor.blueComponent * 255;
+
+    NSString *expectedString = [NSString stringWithFormat:@"rgb(%.0f, %.0f, %.0f)", red, green, blue];
+
+    NSString *cssLinkColor = [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.links[0]).color"];
+    EXPECT_WK_STREQ(expectedString.UTF8String, cssLinkColor);
 }
 #endif