Title: [291773] trunk/Tools
Revision
291773
Author
mmaxfi...@apple.com
Date
2022-03-23 17:03:19 -0700 (Wed, 23 Mar 2022)

Log Message

[Cocoa] Make IPCTestingAPI.CGColorInNSSecureCoding more robust
https://bugs.webkit.org/show_bug.cgi?id=238300
<rdar://problem/90124325>

Unreviewed test gardening.

Round-tripping a CGColor through CFData on iOS can turn extended sRGB color spaces
into regular sRGB color spaces, if the color is common to both.

* TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (291772 => 291773)


--- trunk/Tools/ChangeLog	2022-03-23 23:07:41 UTC (rev 291772)
+++ trunk/Tools/ChangeLog	2022-03-24 00:03:19 UTC (rev 291773)
@@ -1,3 +1,16 @@
+2022-03-23  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Make IPCTestingAPI.CGColorInNSSecureCoding more robust
+        https://bugs.webkit.org/show_bug.cgi?id=238300
+        <rdar://problem/90124325>
+
+        Unreviewed test gardening.
+
+        Round-tripping a CGColor through CFData on iOS can turn extended sRGB color spaces
+        into regular sRGB color spaces, if the color is common to both.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:
+
 2022-03-22  Jonathan Bedard  <jbed...@apple.com>
 
         [commits.webkit.org] Sync tags

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm (291772 => 291773)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm	2022-03-23 23:07:41 UTC (rev 291772)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm	2022-03-24 00:03:19 UTC (rev 291773)
@@ -548,6 +548,8 @@
         [webView stringByEvaluatingJavaScript:@"IPC.webPageProxyID.toString()"].intValue);
 }
 
+#endif
+
 TEST(IPCTestingAPI, CGColorInNSSecureCoding)
 {
     auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
@@ -555,7 +557,9 @@
     RetainPtr<id<NSKeyedArchiverDelegate, NSKeyedUnarchiverDelegate>> delegate = adoptNS([[NSClassFromString(@"WKSecureCodingArchivingDelegate") alloc] init]);
     archiver.get().delegate = delegate.get();
 
-    auto payload = @{ @"SomeString" : static_cast<id>(adoptCF(CGColorCreateSRGB(0.2, 0.3, 0.4, 0.5)).get()) };
+    NSString *key = @"SomeString";
+    auto value = adoptCF(CGColorCreateSRGB(0.2, 0.3, 0.4, 0.5));
+    auto payload = @{ key : static_cast<id>(value.get()) };
     [archiver encodeObject:payload forKey:NSKeyedArchiveRootObjectKey];
     [archiver finishEncoding];
     [archiver setDelegate:nil];
@@ -571,10 +575,19 @@
     [allowedClassSet addObject:NSString.class];
     [allowedClassSet addObject:NSClassFromString(@"WKSecureCodingCGColorWrapper")];
 
-    id result = [unarchiver decodeObjectOfClasses:allowedClassSet.get() forKey:NSKeyedArchiveRootObjectKey];
-    EXPECT_TRUE([payload isEqual:result]);
+    NSDictionary *result = [unarchiver decodeObjectOfClasses:allowedClassSet.get() forKey:NSKeyedArchiveRootObjectKey];
+    // Round-tripping the color can slightly change the representation, causing [payload isEqual:result] to report NO.
+    EXPECT_EQ(result.count, static_cast<NSUInteger>(1));
+    NSString *resultKey = result.allKeys[0];
+    EXPECT_TRUE([key isEqual:resultKey]);
+    CGColorRef resultValue = static_cast<CGColorRef>(result.allValues[0]);
+    ASSERT_EQ(CFGetTypeID(resultValue), CGColorGetTypeID());
+    auto resultValueColorSpace = adoptCF(CGColorGetColorSpace(resultValue));
+    auto resultValueColorSpaceName = adoptCF(CGColorSpaceCopyName(resultValueColorSpace.get()));
+    EXPECT_NE(CFStringFind(resultValueColorSpaceName.get(), CFSTR("SRGB"), 0).location, kCFNotFound);
+    ASSERT_EQ(CGColorGetNumberOfComponents(resultValue), CGColorGetNumberOfComponents(value.get()));
+    for (size_t i = 0; i < CGColorGetNumberOfComponents(resultValue); ++i)
+        EXPECT_EQ(CGColorGetComponents(resultValue)[i], CGColorGetComponents(value.get())[i]);
     [unarchiver finishDecoding];
     unarchiver.get().delegate = nil;
 }
-
-#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to