Title: [291774] branches/safari-613-branch/Tools
Revision
291774
Author
alanc...@apple.com
Date
2022-03-23 17:11:09 -0700 (Wed, 23 Mar 2022)

Log Message

Cherry-pick r291773. rdar://problem/90716064

    [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:

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

Modified Paths

Diff

Modified: branches/safari-613-branch/Tools/ChangeLog (291773 => 291774)


--- branches/safari-613-branch/Tools/ChangeLog	2022-03-24 00:03:19 UTC (rev 291773)
+++ branches/safari-613-branch/Tools/ChangeLog	2022-03-24 00:11:09 UTC (rev 291774)
@@ -1,3 +1,33 @@
+2022-03-23  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r291773. rdar://problem/90716064
+
+    [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:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291773 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-21  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r291518. rdar://problem/90124325

Modified: branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm (291773 => 291774)


--- branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm	2022-03-24 00:03:19 UTC (rev 291773)
+++ branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm	2022-03-24 00:11:09 UTC (rev 291774)
@@ -577,6 +577,8 @@
         [webView stringByEvaluatingJavaScript:@"IPC.webPageProxyID.toString()"].intValue);
 }
 
+#endif
+
 TEST(IPCTestingAPI, CGColorInNSSecureCoding)
 {
     auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
@@ -584,7 +586,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];
@@ -600,10 +604,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