Title: [286311] trunk
- Revision
- 286311
- Author
- [email protected]
- Date
- 2021-11-30 11:52:28 -0800 (Tue, 30 Nov 2021)
Log Message
Correct serialization error in _WKApplicationManifestIcon
https://bugs.webkit.org/show_bug.cgi?id=233602
<rdar://problem/85838843>
Reviewed by Devin Rousso.
Source/WebKit:
The 'initWithCoder' method had two mistakes: (1) It attempted to decode the 'purposes'
member as an NSArray of NSString, rather than NSNumber, and (2) it attempted to decode
the 'src' member as an NSString, when it is in fact an NSURL.
These errors caused serialization to fail (since NSSecureCoding correctly rejected the
serialization).
This patch corrects both errors and adds a new test to exercise this code path.
Tested by a new TestWebKitAPI Test: ApplicationManifest.IconCoding
* UIProcess/API/Cocoa/_WKApplicationManifest.mm:
(-[_WKApplicationManifestIcon initWithCoder:]): Correct decoding logic.
Tools:
This patch adds a new test "ApplicationManifest.IconCoding" to exercise the
NSCoder code paths.
* TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (286310 => 286311)
--- trunk/Source/WebKit/ChangeLog 2021-11-30 19:34:38 UTC (rev 286310)
+++ trunk/Source/WebKit/ChangeLog 2021-11-30 19:52:28 UTC (rev 286311)
@@ -1,3 +1,25 @@
+2021-11-30 Brent Fulgham <[email protected]>
+
+ Correct serialization error in _WKApplicationManifestIcon
+ https://bugs.webkit.org/show_bug.cgi?id=233602
+ <rdar://problem/85838843>
+
+ Reviewed by Devin Rousso.
+
+ The 'initWithCoder' method had two mistakes: (1) It attempted to decode the 'purposes'
+ member as an NSArray of NSString, rather than NSNumber, and (2) it attempted to decode
+ the 'src' member as an NSString, when it is in fact an NSURL.
+
+ These errors caused serialization to fail (since NSSecureCoding correctly rejected the
+ serialization).
+
+ This patch corrects both errors and adds a new test to exercise this code path.
+
+ Tested by a new TestWebKitAPI Test: ApplicationManifest.IconCoding
+
+ * UIProcess/API/Cocoa/_WKApplicationManifest.mm:
+ (-[_WKApplicationManifestIcon initWithCoder:]): Correct decoding logic.
+
2021-11-30 BJ Burg <[email protected]>
Web Inspector: fix IPC race between unregistering an extension and Web Inspector closing
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm (286310 => 286311)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm 2021-11-30 19:34:38 UTC (rev 286310)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm 2021-11-30 19:52:28 UTC (rev 286311)
@@ -90,10 +90,10 @@
if (!(self = [self init]))
return nil;
- _src = [[coder decodeObjectOfClass:[NSString class] forKey:@"src"] copy];
+ _src = [[coder decodeObjectOfClass:[NSURL class] forKey:@"src"] copy];
_sizes = [[coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSString class]]] forKey:@"sizes"] copy];
_type = [[coder decodeObjectOfClass:[NSString class] forKey:@"type"] copy];
- _purposes = [[coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSString class]]] forKey:@"purposes"] copy];
+ _purposes = [[coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSNumber class]]] forKey:@"purposes"] copy];
return self;
}
Modified: trunk/Tools/ChangeLog (286310 => 286311)
--- trunk/Tools/ChangeLog 2021-11-30 19:34:38 UTC (rev 286310)
+++ trunk/Tools/ChangeLog 2021-11-30 19:52:28 UTC (rev 286311)
@@ -1,3 +1,17 @@
+2021-11-30 Brent Fulgham <[email protected]>
+
+ Correct serialization error in _WKApplicationManifestIcon
+ https://bugs.webkit.org/show_bug.cgi?id=233602
+ <rdar://problem/85838843>
+
+ Reviewed by Devin Rousso.
+
+ This patch adds a new test "ApplicationManifest.IconCoding" to exercise the
+ NSCoder code paths.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm:
+ (TestWebKitAPI::TEST):
+
2021-11-30 Chris Dumez <[email protected]>
Scripting attributes are sometimes not properly stripped from elements when JS is disabled
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm (286310 => 286311)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm 2021-11-30 19:34:38 UTC (rev 286310)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm 2021-11-30 19:52:28 UTC (rev 286311)
@@ -31,9 +31,11 @@
#import "Test.h"
#import "TestNavigationDelegate.h"
#import "TestWKWebView.h"
+#import <WebCore/ApplicationManifest.h>
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import <WebKit/WKWebViewPrivate.h>
#import <WebKit/_WKApplicationManifest.h>
+#import <wtf/cocoa/VectorCocoa.h>
namespace TestWebKitAPI {
@@ -361,6 +363,34 @@
Util::run(&done);
}
+TEST(ApplicationManifest, IconCoding)
+{
+ static const char* testURL = "https://example.com/images/touch/homescreen128.jpg";
+
+ WebCore::ApplicationManifest::Icon icon = { URL(URL(), testURL), makeVector<String>(@[@"96x96", @"128x128"]), "image/jpg", { WebCore::ApplicationManifest::Icon::Purpose::Monochrome, WebCore::ApplicationManifest::Icon::Purpose::Maskable } };
+
+ IGNORE_WARNINGS_BEGIN("objc-method-access")
+ auto manifestIcon = adoptNS([[_WKApplicationManifestIcon alloc] initWithCoreIcon:&icon]);
+ IGNORE_WARNINGS_END
+
+ NSError *error = nil;
+ NSData *archiveData = [NSKeyedArchiver archivedDataWithRootObject:manifestIcon.get() requiringSecureCoding:YES error:&error];
+ EXPECT_EQ(archiveData.length, 602ull);
+ EXPECT_NULL(error);
+
+ _WKApplicationManifestIcon *decodedIcon = [NSKeyedUnarchiver unarchivedObjectOfClass:[_WKApplicationManifestIcon class] fromData:archiveData error:&error];
+ EXPECT_NULL(error);
+
+ EXPECT_TRUE([decodedIcon isKindOfClass:[_WKApplicationManifestIcon class]]);
+ EXPECT_STREQ(testURL, decodedIcon.src.absoluteString.UTF8String);
+ EXPECT_TRUE([decodedIcon.sizes[0] isEqual:@"96x96"]);
+ EXPECT_TRUE([decodedIcon.sizes[1] isEqual:@"128x128"]);
+ EXPECT_TRUE([decodedIcon.type isEqual:@"image/jpg"]);
+ EXPECT_EQ(decodedIcon.purposes.count, 2ul);
+ EXPECT_EQ(decodedIcon.purposes[0].unsignedLongValue, 2ul);
+ EXPECT_EQ(decodedIcon.purposes[1].unsignedLongValue, 4ul);
+}
+
} // namespace TestWebKitAPI
#endif // ENABLE(APPLICATION_MANIFEST)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes