Changeset 204188 in webkit


Ignore:
Timestamp:
Aug 5, 2016 1:19:51 PM (8 years ago)
Author:
mitz@apple.com
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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r204135 r204188  
     12016-08-05  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WKRemoteObjectCoder doesn’t handle NSRange
     4        https://bugs.webkit.org/show_bug.cgi?id=160589
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
     9        (encodeInvocationArguments): Encode NSRange by wrapping in an NSValue.
     10        (decodeInvocationArguments): Decode wrapped NSRange.
     11
    1122016-08-04  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm

    r202242 r204188  
    206206        }
    207207
     208        // struct
     209        case '{':
     210            if (!strcmp(type, @encode(NSRange))) {
     211                NSRange value;
     212                [invocation getArgument:&value atIndex:i];
     213
     214                encodeToObjectStream(encoder, [NSValue valueWithRange:value]);
     215                break;
     216            }
     217            FALLTHROUGH;
     218
    208219        default:
    209220            [NSException raise:NSInvalidArgumentException format:@"Unsupported invocation argument type '%s'", type];
     
    538549            break;
    539550        }
     551
     552        // struct
     553        case '{':
     554            if (!strcmp(type, @encode(NSRange))) {
     555                NSRange value = [decodeObjectFromObjectStream(decoder, { [NSValue class] }) rangeValue];
     556                [invocation setArgument:&value atIndex:i];
     557                break;
     558            }
     559            FALLTHROUGH;
    540560
    541561        default:
  • trunk/Tools/ChangeLog

    r204183 r204188  
     12016-08-05  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WKRemoteObjectCoder doesn’t handle NSRange
     4        https://bugs.webkit.org/show_bug.cgi?id=160589
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
     9        (remoteObjectInterface): Fixed a mistake in the set of allowed classes in one of the reply
     10          blocks, which wasn’t caught because the test wasn’t run correctly.
     11        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
     12        (TEST): Fixed the -selectionAndClickInformationForClickAtPoint:completionHandler: test, and
     13          added a test that sends over an NSRange.
     14        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
     15        (-[RemoteObjectRegistryPlugIn takeRange:completionHandler:]): Added. Calls the completion
     16          handler with the range‘s location and length.
     17
    1182016-08-05  Enrica Casucci  <enrica@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h

    r192319 r204188  
    3535- (void)sayHello:(NSString *)hello completionHandler:(void (^)(NSString *))completionHandler;
    3636- (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler;
     37- (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler;
    3738
    3839@end
     
    4243    _WKRemoteObjectInterface *interface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(RemoteObjectProtocol)];
    4344
    44     [interface setClasses:[NSSet setWithObjects:[NSDictionary class], [NSURL class], nil] forSelector:@selector(selectionAndClickInformationForClickAtPoint:completionHandler:) argumentIndex:0 ofReply:YES];
     45    [interface setClasses:[NSSet setWithObjects:[NSDictionary class], [NSString class], [NSURL class], nil] forSelector:@selector(selectionAndClickInformationForClickAtPoint:completionHandler:) argumentIndex:0 ofReply:YES];
    4546
    4647    return interface;
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm

    r192319 r204188  
    6767            isDone = true;
    6868        }];
     69        TestWebKitAPI::Util::run(&isDone);
    6970
    7071        isDone = false;
    7172        [object selectionAndClickInformationForClickAtPoint:[NSValue valueWithPoint:NSMakePoint(12, 34)] completionHandler:^(NSDictionary *result) {
     73            EXPECT_TRUE([result isEqual:@{ @"URL": [NSURL URLWithString:@"http://www.webkit.org/"] }]);
     74            isDone = true;
     75        }];
     76        TestWebKitAPI::Util::run(&isDone);
     77
     78        isDone = false;
     79        [object takeRange:NSMakeRange(345, 123) completionHandler:^(NSUInteger location, NSUInteger length) {
     80            EXPECT_EQ(345U, location);
     81            EXPECT_EQ(123U, length);
    7282            isDone = true;
    7383        }];
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm

    r192319 r204188  
    7777}
    7878
     79- (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler
     80{
     81    completionHandler(range.location, range.length);
     82}
     83
    7984@end
    8085
Note: See TracChangeset for help on using the changeset viewer.