- Revision
- 204188
- Author
- m...@apple.com
- Date
- 2016-08-05 13:19:51 -0700 (Fri, 05 Aug 2016)
Log Message
[Cocoa] WKRemoteObjectCoder doesn’t handle NSRange
https://bugs.webkit.org/show_bug.cgi?id=160589
Reviewed by Tim Horton.
Source/WebKit2:
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeInvocationArguments): Encode NSRange by wrapping in an NSValue.
(decodeInvocationArguments): Decode wrapped NSRange.
Tools:
* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
(remoteObjectInterface): Fixed a mistake in the set of allowed classes in one of the reply
blocks, which wasn’t caught because the test wasn’t run correctly.
* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
(TEST): Fixed the -selectionAndClickInformationForClickAtPoint:completionHandler: test, and
added a test that sends over an NSRange.
* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
(-[RemoteObjectRegistryPlugIn takeRange:completionHandler:]): Added. Calls the completion
handler with the range‘s location and length.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (204187 => 204188)
--- trunk/Source/WebKit2/ChangeLog 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Source/WebKit2/ChangeLog 2016-08-05 20:19:51 UTC (rev 204188)
@@ -1,3 +1,14 @@
+2016-08-05 Dan Bernstein <m...@apple.com>
+
+ [Cocoa] WKRemoteObjectCoder doesn’t handle NSRange
+ https://bugs.webkit.org/show_bug.cgi?id=160589
+
+ Reviewed by Tim Horton.
+
+ * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+ (encodeInvocationArguments): Encode NSRange by wrapping in an NSValue.
+ (decodeInvocationArguments): Decode wrapped NSRange.
+
2016-08-04 Chris Dumez <cdu...@apple.com>
Crash under NavigationState::NavigationClient::processDidCrash()
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (204187 => 204188)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2016-08-05 20:19:51 UTC (rev 204188)
@@ -205,6 +205,17 @@
break;
}
+ // struct
+ case '{':
+ if (!strcmp(type, @encode(NSRange))) {
+ NSRange value;
+ [invocation getArgument:&value atIndex:i];
+
+ encodeToObjectStream(encoder, [NSValue valueWithRange:value]);
+ break;
+ }
+ FALLTHROUGH;
+
default:
[NSException raise:NSInvalidArgumentException format:@"Unsupported invocation argument type '%s'", type];
}
@@ -538,6 +549,15 @@
break;
}
+ // struct
+ case '{':
+ if (!strcmp(type, @encode(NSRange))) {
+ NSRange value = [decodeObjectFromObjectStream(decoder, { [NSValue class] }) rangeValue];
+ [invocation setArgument:&value atIndex:i];
+ break;
+ }
+ FALLTHROUGH;
+
default:
[NSException raise:NSInvalidArgumentException format:@"Unsupported invocation argument type '%s' for argument %zu", type, (unsigned long)i];
}
Modified: trunk/Tools/ChangeLog (204187 => 204188)
--- trunk/Tools/ChangeLog 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Tools/ChangeLog 2016-08-05 20:19:51 UTC (rev 204188)
@@ -1,3 +1,20 @@
+2016-08-05 Dan Bernstein <m...@apple.com>
+
+ [Cocoa] WKRemoteObjectCoder doesn’t handle NSRange
+ https://bugs.webkit.org/show_bug.cgi?id=160589
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
+ (remoteObjectInterface): Fixed a mistake in the set of allowed classes in one of the reply
+ blocks, which wasn’t caught because the test wasn’t run correctly.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
+ (TEST): Fixed the -selectionAndClickInformationForClickAtPoint:completionHandler: test, and
+ added a test that sends over an NSRange.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
+ (-[RemoteObjectRegistryPlugIn takeRange:completionHandler:]): Added. Calls the completion
+ handler with the range‘s location and length.
+
2016-08-05 Enrica Casucci <enr...@apple.com>
Fixing tests failing after r204175.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h (204187 => 204188)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h 2016-08-05 20:19:51 UTC (rev 204188)
@@ -34,6 +34,7 @@
- (void)sayHello:(NSString *)hello;
- (void)sayHello:(NSString *)hello completionHandler:(void (^)(NSString *))completionHandler;
- (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler;
+- (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler;
@end
@@ -41,7 +42,7 @@
{
_WKRemoteObjectInterface *interface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(RemoteObjectProtocol)];
- [interface setClasses:[NSSet setWithObjects:[NSDictionary class], [NSURL class], nil] forSelector:@selector(selectionAndClickInformationForClickAtPoint:completionHandler:) argumentIndex:0 ofReply:YES];
+ [interface setClasses:[NSSet setWithObjects:[NSDictionary class], [NSString class], [NSURL class], nil] forSelector:@selector(selectionAndClickInformationForClickAtPoint:completionHandler:) argumentIndex:0 ofReply:YES];
return interface;
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm (204187 => 204188)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm 2016-08-05 20:19:51 UTC (rev 204188)
@@ -66,12 +66,22 @@
EXPECT_WK_STREQ(result, @"Your string was 'Hello Again!'");
isDone = true;
}];
+ TestWebKitAPI::Util::run(&isDone);
isDone = false;
[object selectionAndClickInformationForClickAtPoint:[NSValue valueWithPoint:NSMakePoint(12, 34)] completionHandler:^(NSDictionary *result) {
+ EXPECT_TRUE([result isEqual:@{ @"URL": [NSURL URLWithString:@"http://www.webkit.org/"] }]);
isDone = true;
}];
TestWebKitAPI::Util::run(&isDone);
+
+ isDone = false;
+ [object takeRange:NSMakeRange(345, 123) completionHandler:^(NSUInteger location, NSUInteger length) {
+ EXPECT_EQ(345U, location);
+ EXPECT_EQ(123U, length);
+ isDone = true;
+ }];
+ TestWebKitAPI::Util::run(&isDone);
}
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm (204187 => 204188)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm 2016-08-05 20:19:27 UTC (rev 204187)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm 2016-08-05 20:19:51 UTC (rev 204188)
@@ -76,6 +76,11 @@
completionHandler(result);
}
+- (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler
+{
+ completionHandler(range.location, range.length);
+}
+
@end
#endif // WK_API_ENABLED