Skip to content

Commit

Permalink
Add unit test for r274129
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=224021

Reviewed by Chris Dumez.

* TestWebKitAPI/SourcesCocoa.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.h:
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistryPlugIn.mm:
(-[RemoteObjectRegistryPlugIn sendAwakener:completionHandler:]):
* TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.h: Added.
* TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.mm: Added.
(-[TestAwakener awakeAfterUsingCoder:]):
(-[TestAwakener initWithValue:]):
(-[TestAwakener value]):
(+[TestAwakener supportsSecureCoding]):
(-[TestAwakener encodeWithCoder:]):
(-[TestAwakener initWithCoder:]):



Canonical link: https://commits.webkit.org/237538@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277271 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed May 10, 2021
1 parent 7d97be4 commit 8e0a5c7
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,26 @@
2021-05-10 Alex Christensen <achristensen@webkit.org>

Add unit test for r274129
https://bugs.webkit.org/show_bug.cgi?id=224021

Reviewed by Chris Dumez.

* TestWebKitAPI/SourcesCocoa.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.h:
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistryPlugIn.mm:
(-[RemoteObjectRegistryPlugIn sendAwakener:completionHandler:]):
* TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.h: Added.
* TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.mm: Added.
(-[TestAwakener awakeAfterUsingCoder:]):
(-[TestAwakener initWithValue:]):
(-[TestAwakener value]):
(+[TestAwakener supportsSecureCoding]):
(-[TestAwakener encodeWithCoder:]):
(-[TestAwakener initWithCoder:]):

2021-05-10 Devin Rousso <drousso@apple.com>

Add support for a `media` attribute on `<meta name="theme-color" content="...">`
Expand Down
1 change: 1 addition & 0 deletions Tools/TestWebKitAPI/SourcesCocoa.txt
Expand Up @@ -35,4 +35,5 @@ cocoa/TestWKWebView.mm
cocoa/UserMediaCaptureUIDelegate.mm

Tests/WebKitCocoa/EventAttribution.mm
Tests/WebKitCocoa/TestAwakener.mm
Tests/WebKitCocoa/TLSDeprecation.mm
6 changes: 6 additions & 0 deletions Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Expand Up @@ -1113,6 +1113,7 @@
CEDA12412437C9FB00C28A9E /* editable-region-composited-and-non-composited-overlap.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEDA12402437C9EA00C28A9E /* editable-region-composited-and-non-composited-overlap.html */; };
D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */; };
DF4B273921A47728009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = DF4B273821A47727009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm */; };
DFB80E38261512C1002D4771 /* TestAwakener.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFB80E362615124E002D4771 /* TestAwakener.mm */; };
DFB8FF322492F52400F00B0D /* Preconnect.mm in Sources */ = {isa = PBXBuildFile; fileRef = DFB8FF312492F51A00F00B0D /* Preconnect.mm */; };
E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
Expand Down Expand Up @@ -2915,6 +2916,8 @@
DF4B273821A47727009BD1CA /* WKNSDictionaryEmptyDictionaryCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSDictionaryEmptyDictionaryCrash.mm; sourceTree = "<group>"; };
DF6BC46F2534E120008F63CC /* TestDownloadDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = TestDownloadDelegate.mm; path = cocoa/TestDownloadDelegate.mm; sourceTree = "<group>"; };
DF6BC4702534E120008F63CC /* TestDownloadDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestDownloadDelegate.h; path = cocoa/TestDownloadDelegate.h; sourceTree = "<group>"; };
DFB80E352615124E002D4771 /* TestAwakener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestAwakener.h; sourceTree = "<group>"; };
DFB80E362615124E002D4771 /* TestAwakener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestAwakener.mm; sourceTree = "<group>"; };
DFB8FF312492F51A00F00B0D /* Preconnect.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Preconnect.mm; sourceTree = "<group>"; };
E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCacheDisableWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3549,6 +3552,8 @@
1C734B5220788C4800F430EA /* SystemColors.mm */,
31B76E4223298E2B007FED2C /* SystemPreview.mm */,
2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */,
DFB80E352615124E002D4771 /* TestAwakener.h */,
DFB80E362615124E002D4771 /* TestAwakener.mm */,
5774AA6721FBBF7800AF2A1B /* TestSOAuthorization.mm */,
F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */,
F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */,
Expand Down Expand Up @@ -5907,6 +5912,7 @@
1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,
5245178721B9F57B0082CB34 /* RenderingProgressPlugIn.mm in Sources */,
DFB80E38261512C1002D4771 /* TestAwakener.mm in Sources */,
7C882E091C80C630006BF731 /* UserContentWorldPlugIn.mm in Sources */,
7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */,
A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.h
Expand Up @@ -39,6 +39,8 @@

@end

@class TestAwakener;

@protocol RemoteObjectProtocol <BaseRemoteObjectProtocol, OtherBaseRemoteObjectProtocol>

- (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler;
Expand All @@ -53,6 +55,7 @@
- (void)sendRequest:(NSURLRequest *)request response:(NSURLResponse *)response challenge:(NSURLAuthenticationChallenge *)challenge error:(NSError *)error completionHandler:(void (^)(NSURLRequest *, NSURLResponse *, NSURLAuthenticationChallenge *, NSError *))completionHandler;
- (void)callUIProcessMethodWithReplyBlock;
- (void)sendError:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
- (void)sendAwakener:(TestAwakener *)awakener completionHandler:(void (^)(TestAwakener *))completionHandler;

@end

Expand Down
9 changes: 9 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm
Expand Up @@ -29,6 +29,7 @@
#import "PlatformUtilities.h"
#import "RemoteObjectRegistry.h"
#import "Test.h"
#import "TestAwakener.h"
#import "TestNavigationDelegate.h"
#import "WKWebViewConfigurationExtras.h"
#import <WebKit/WKProcessPoolPrivate.h>
Expand Down Expand Up @@ -86,6 +87,14 @@
}];
TestWebKitAPI::Util::run(&isDone);

isDone = false;
auto initialAwakener = adoptNS([[TestAwakener alloc] initWithValue:42]);
[object sendAwakener:initialAwakener.get() completionHandler:^(TestAwakener *awakener) {
EXPECT_EQ(awakener.value, 42);
isDone = true;
}];
TestWebKitAPI::Util::run(&isDone);

isDone = false;
[object takeSize:CGSizeMake(123.45, 678.91) completionHandler:^(CGFloat width, CGFloat height) {
EXPECT_EQ(123.45, width);
Expand Down
Expand Up @@ -123,6 +123,11 @@ - (void)sendError:(NSError *)error completionHandler:(void (^)(NSError *))comple
completionHandler(error);
}

- (void)sendAwakener:(TestAwakener *)awakener completionHandler:(void (^)(TestAwakener *))completionHandler
{
completionHandler(awakener);
}

- (void)callUIProcessMethodWithReplyBlock
{
id <LocalObjectProtocol> localObject = [[_browserContextController _remoteObjectRegistry] remoteObjectProxyWithInterface:localObjectInterface()];
Expand Down
31 changes: 31 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.h
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import <Foundation/Foundation.h>

@interface TestAwakener : NSObject<NSSecureCoding>
- (instancetype)initWithValue:(int)value;
@property (nonatomic, readonly) int value;
@end
72 changes: 72 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/TestAwakener.mm
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "TestAwakener.h"

@implementation TestAwakener {
int _value;
}

- (id)awakeAfterUsingCoder:(NSCoder *)coder
{
// Note: This memory management, although unusual in WebKit, matches NS_REPLACES_RECEIVER.
TestAwakener *replacement = [[TestAwakener alloc] initWithValue:self.value];
[self release];
return replacement;
}

- (instancetype)initWithValue:(int)value
{
if (!(self = [super init]))
return nil;
_value = value;
return self;
}

- (int)value
{
return _value;
}

+ (BOOL)supportsSecureCoding
{
return YES;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeInt:_value forKey:@"value"];
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
if (!(self = [super init]))
return nil;
_value = [coder decodeIntForKey:@"value"];
return self;
}

@end

0 comments on commit 8e0a5c7

Please sign in to comment.