Diff
Modified: trunk/Source/WebKit/ChangeLog (229541 => 229542)
--- trunk/Source/WebKit/ChangeLog 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Source/WebKit/ChangeLog 2018-03-12 19:25:19 UTC (rev 229542)
@@ -1,3 +1,19 @@
+2018-03-12 Wenson Hsieh <wenson_hs...@apple.com>
+
+ REGRESSION(r211643): Dismissing WKActionSheet should not also dismiss its presenting view controller
+ https://bugs.webkit.org/show_bug.cgi?id=183549
+ <rdar://problem/34960698>
+
+ Reviewed by Andy Estes.
+
+ Fixes the bug by dismissing the presented view controller (i.e. the action sheet or the view controller being
+ presented during rotation) rather than the presenting view controller.
+
+ Test: ActionSheetTests.DismissingActionSheetShouldNotDismissPresentingViewController
+
+ * UIProcess/ios/WKActionSheet.mm:
+ (-[WKActionSheet doneWithSheet:]):
+
2018-03-12 Javier Fernandez <jfernan...@igalia.com>
Remove GridLayout runtime flag
Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheet.mm (229541 => 229542)
--- trunk/Source/WebKit/UIProcess/ios/WKActionSheet.mm 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheet.mm 2018-03-12 19:25:19 UTC (rev 229542)
@@ -125,8 +125,11 @@
- (void)doneWithSheet:(BOOL)dismiss
{
- if (dismiss && _currentPresentingViewController)
- [_currentPresentingViewController dismissViewControllerAnimated:YES completion:nil];
+ if (dismiss) {
+ UIViewController *currentPresentedViewController = [_currentPresentingViewController presentedViewController];
+ if (currentPresentedViewController == self || currentPresentedViewController == _presentedViewControllerWhileRotating)
+ [currentPresentedViewController dismissViewControllerAnimated:YES completion:nil];
+ }
_currentPresentingViewController = nil;
_presentedViewControllerWhileRotating = nil;
Modified: trunk/Tools/ChangeLog (229541 => 229542)
--- trunk/Tools/ChangeLog 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/ChangeLog 2018-03-12 19:25:19 UTC (rev 229542)
@@ -1,3 +1,67 @@
+2018-03-12 Wenson Hsieh <wenson_hs...@apple.com>
+
+ REGRESSION(r211643): Dismissing WKActionSheet should not also dismiss its presenting view controller
+ https://bugs.webkit.org/show_bug.cgi?id=183549
+ <rdar://problem/34960698>
+
+ Reviewed by Andy Estes.
+
+ Add TestWebKitAPI support for testing WKWebViews embedded within presented view controllers, and use this to
+ check that dismissing an action sheet does not additionally cause the view controller being used to present the
+ web view to also dismiss.
+
+ * TestWebKitAPI/ClassMethodSwizzler.h: Added.
+ * TestWebKitAPI/ClassMethodSwizzler.mm: Added.
+ (TestWebKitAPI::ClassMethodSwizzler::ClassMethodSwizzler):
+ (TestWebKitAPI::ClassMethodSwizzler::~ClassMethodSwizzler):
+
+ Add ClassMethodSwizzler, an RAII which swizzles an Objective-C class method over its lifetime.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/ios/ActionSheetTests.mm:
+
+ Add a new API test that loads a view controller which embeds a WKWebView, and verifies that presenting and then
+ dismissing an action sheet from that web view does not cause the view controller to also dismiss.
+
+ (TestWebKitAPI::setOverrideViewControllerForFullscreenPresentation):
+ (TestWebKitAPI::overrideViewControllerForFullscreenPresentation):
+
+ Mock +[UIViewController _viewControllerForFullScreenPresentationFromView:] to return the web view. This works
+ around the fact that TestWebKitAPI is not a UI application, so certain pieces of UIKit API and SPI need to be
+ stubbed or mocked to simulate being a UI application. We can remove these workarounds once
+ https://webkit.org/b/175204 is addressed, and TestWebKitAPI becomes a UI application that can actually maintain
+ a root view controller and key window.
+
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/cocoa/TestWKWebView.h:
+ * TestWebKitAPI/cocoa/TestWKWebView.mm:
+ (-[TestWKWebView initWithFrame:configuration:addToWindow:]):
+
+ Add a new initializer for TestWKWebView that doesn't force the view to be hosted within a UIWindow. This is used
+ by TestWKWebViewController to create a TestWKWebView in -loadView.
+
+ * TestWebKitAPI/ios/TestWKWebViewController.h: Added.
+ * TestWebKitAPI/ios/TestWKWebViewController.mm: Added.
+ (-[TestWKWebViewControllerWindow _beginKeyWindowDeferral]):
+ (-[TestWKWebViewControllerWindow _endKeyWindowDeferral]):
+
+ Stub out these methods to prevent UIKit from hitting assertions when making this UIWindow the key window. This
+ can also be removed once TestWebKitAPI is a UI application.
+
+ (-[TestWKWebViewController initWithFrame:configuration:]):
+ (-[TestWKWebViewController loadView]):
+ (-[TestWKWebViewController webView]):
+ (-[TestWKWebViewController dismissViewControllerAnimated:completion:]):
+ (-[TestWKWebViewController dismissalHandler]):
+ (-[TestWKWebViewController setDismissalHandler:]):
+
+ Add a UIViewController helper subclass whose -view is a WKWebView. The new API test presents this view
+ controller. Tests may also provide a dismissalHandler, which is invoked when the view controller is being
+ dismissed. The new API test uses this hook to verify that the view controller containing the web view isn't also
+ dismissed after the action sheet goes away.
+
+ * TestWebKitAPI/ios/UIKitSPI.h:
+
2018-03-12 Basuke Suzuki <basuke.suz...@sony.com>
[webkitpy] Remove openssl command dependency.
Added: trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.h (0 => 229542)
--- trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.h (rev 0)
+++ trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.h 2018-03-12 19:25:19 UTC (rev 229542)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#pragma once
+
+#include <objc/runtime.h>
+#include <wtf/Noncopyable.h>
+
+namespace TestWebKitAPI {
+
+class ClassMethodSwizzler {
+ WTF_MAKE_NONCOPYABLE(ClassMethodSwizzler);
+public:
+ ClassMethodSwizzler(Class, SEL, IMP);
+ ~ClassMethodSwizzler();
+
+ Method m_method;
+ IMP m_originalImplementation;
+};
+
+} // namespace TestWebKitAPI
Added: trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.mm (0 => 229542)
--- trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/ClassMethodSwizzler.mm 2018-03-12 19:25:19 UTC (rev 229542)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 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 "ClassMethodSwizzler.h"
+
+namespace TestWebKitAPI {
+
+ClassMethodSwizzler::ClassMethodSwizzler(Class cls, SEL originalSelector, IMP implementation)
+ : m_method(class_getClassMethod(objc_getMetaClass(NSStringFromClass(cls).UTF8String), originalSelector))
+ , m_originalImplementation(method_setImplementation(m_method, implementation))
+{
+}
+
+ClassMethodSwizzler::~ClassMethodSwizzler()
+{
+ method_setImplementation(m_method, m_originalImplementation);
+}
+
+} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (229541 => 229542)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2018-03-12 19:25:19 UTC (rev 229542)
@@ -745,6 +745,8 @@
F44D06471F39627A001A0E29 /* EditorStateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44D06461F395C4D001A0E29 /* EditorStateTests.mm */; };
F44D064A1F3962F2001A0E29 /* EditingTestHarness.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44D06491F3962E3001A0E29 /* EditingTestHarness.mm */; };
F4512E131F60C44600BB369E /* DataTransferItem-getAsEntry.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */; };
+ F4517B672054C49500C26721 /* TestWKWebViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4517B662054C49500C26721 /* TestWKWebViewController.mm */; };
+ F4517B7F2055101B00C26721 /* ClassMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4517B692054E0AC00C26721 /* ClassMethodSwizzler.mm */; };
F4538EF71E8473E600B5C953 /* large-red-square.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4538EF01E846B4100B5C953 /* large-red-square.png */; };
F457A9B8202D5CDC00F7E9D5 /* PasteMixedContent.mm in Sources */ = {isa = PBXBuildFile; fileRef = F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */; };
F457A9D6202D68AF00F7E9D5 /* DataTransfer.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F457A9B3202D535300F7E9D5 /* DataTransfer.html */; };
@@ -1877,6 +1879,10 @@
F44D06481F3962E3001A0E29 /* EditingTestHarness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingTestHarness.h; sourceTree = "<group>"; };
F44D06491F3962E3001A0E29 /* EditingTestHarness.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditingTestHarness.mm; sourceTree = "<group>"; };
F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "DataTransferItem-getAsEntry.html"; sourceTree = "<group>"; };
+ F4517B652054C49500C26721 /* TestWKWebViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestWKWebViewController.h; sourceTree = "<group>"; };
+ F4517B662054C49500C26721 /* TestWKWebViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestWKWebViewController.mm; sourceTree = "<group>"; };
+ F4517B682054E0AC00C26721 /* ClassMethodSwizzler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClassMethodSwizzler.h; sourceTree = "<group>"; };
+ F4517B692054E0AC00C26721 /* ClassMethodSwizzler.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ClassMethodSwizzler.mm; sourceTree = "<group>"; };
F4538EF01E846B4100B5C953 /* large-red-square.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "large-red-square.png"; sourceTree = "<group>"; };
F457A9B3202D535300F7E9D5 /* DataTransfer.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DataTransfer.html; sourceTree = "<group>"; };
F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteMixedContent.mm; sourceTree = "<group>"; };
@@ -2030,6 +2036,8 @@
isa = PBXGroup;
children = (
A13EBB441B87332B00097110 /* WebProcessPlugIn */,
+ F4517B682054E0AC00C26721 /* ClassMethodSwizzler.h */,
+ F4517B692054E0AC00C26721 /* ClassMethodSwizzler.mm */,
F44D06481F3962E3001A0E29 /* EditingTestHarness.h */,
F44D06491F3962E3001A0E29 /* EditingTestHarness.mm */,
5C726D6D1D3EE06800C5E1A1 /* InstanceMethodSwizzler.h */,
@@ -2224,6 +2232,8 @@
F4D4F3B51E4E2BCB00BB2767 /* DataInteractionSimulator.h */,
F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */,
2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */,
+ F4517B652054C49500C26721 /* TestWKWebViewController.h */,
+ F4517B662054C49500C26721 /* TestWKWebViewController.mm */,
F493247C1F44DF8D006F4336 /* UIKitSPI.h */,
);
path = ios;
@@ -3397,6 +3407,7 @@
57303BCB2008376500355965 /* CBORReaderTest.cpp in Sources */,
57303BC9200824D300355965 /* CBORValueTest.cpp in Sources */,
57303BCA20082C0100355965 /* CBORWriterTest.cpp in Sources */,
+ F4517B7F2055101B00C26721 /* ClassMethodSwizzler.mm in Sources */,
7CCE7EE61A411AE600447C4C /* CloseFromWithinCreatePage.cpp in Sources */,
7CCE7EB71A411A7E00447C4C /* CloseNewWindowInNavigationPolicyDelegate.mm in Sources */,
7CCE7EE51A411AE600447C4C /* CloseThenTerminate.cpp in Sources */,
@@ -3654,6 +3665,7 @@
A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */,
7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */,
2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */,
+ F4517B672054C49500C26721 /* TestWKWebViewController.mm in Sources */,
93E6193B1F931B3A00AF245E /* TextCodec.cpp in Sources */,
CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm (229541 => 229542)
--- trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm 2018-03-12 19:25:19 UTC (rev 229542)
@@ -23,13 +23,17 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#import "config.h"
+#import "Test.h"
#if PLATFORM(IOS)
+#import "ClassMethodSwizzler.h"
#import "InstanceMethodSwizzler.h"
#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
#import "TestWKWebView.h"
+#import "TestWKWebViewController.h"
#import "UIKitSPI.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <WebKit/WKUIDelegatePrivate.h>
@@ -75,6 +79,70 @@
InstanceMethodSwizzler m_swizzler;
};
+static RetainPtr<UIViewController> gOverrideViewControllerForFullscreenPresentation;
+static void setOverrideViewControllerForFullscreenPresentation(UIViewController *viewController)
+{
+ gOverrideViewControllerForFullscreenPresentation = viewController;
+}
+
+static UIViewController *overrideViewControllerForFullscreenPresentation()
+{
+ return gOverrideViewControllerForFullscreenPresentation.get();
+}
+
+TEST(ActionSheetTests, DismissingActionSheetShouldNotDismissPresentingViewController)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+ UIApplicationInitialize();
+
+ auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
+ auto window = [[TestWKWebViewControllerWindow alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
+ auto rootViewController = adoptNS([[UIViewController alloc] init]);
+ auto navigationController = adoptNS([[UINavigationController alloc] initWithRootViewController:rootViewController.get()]);
+ auto observer = adoptNS([[ActionSheetObserver alloc] init]);
+ [window setRootViewController:navigationController.get()];
+ [window makeKeyAndVisible];
+
+ auto webViewController = adoptNS([[TestWKWebViewController alloc] initWithFrame:CGRectMake(0, 0, 1024, 768) configuration:nil]);
+ TestWKWebView *webView = [webViewController webView];
+ webView.UIDelegate = observer.get();
+ [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
+ [webView setNavigationDelegate:navigationDelegate.get()];
+ [rootViewController presentViewController:webViewController.get() animated:NO completion:nil];
+
+ // Since TestWebKitAPI is not a UI application, +[UIViewController _viewControllerForFullScreenPresentationFromView:]
+ // returns nil. To ensure that we actually present the action sheet from the web view controller, we mock this for the
+ // time being until https://webkit.org/b/175204 is fixed.
+ setOverrideViewControllerForFullscreenPresentation(webViewController.get());
+ ClassMethodSwizzler swizzler([UIViewController class], @selector(_viewControllerForFullScreenPresentationFromView:), reinterpret_cast<IMP>(overrideViewControllerForFullscreenPresentation));
+
+ [observer setPresentationHandler:^(_WKActivatedElementInfo *, NSArray *actions) {
+ // Killing the web content process should dismiss the action sheet.
+ // This should not tell the web view controller to dismiss in the process.
+ [webView _killWebContentProcess];
+ return actions;
+ }];
+
+ __block bool done = false;
+ [navigationDelegate setWebContentProcessDidTerminate:^(WKWebView *) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ done = true;
+ });
+ }];
+
+ __block bool didDismissWebViewController = false;
+ [webViewController setDismissalHandler:^{
+ didDismissWebViewController = true;
+ }];
+
+ [webView _simulateLongPressActionAtLocation:CGPointMake(100, 100)];
+ TestWebKitAPI::Util::run(&done);
+
+ EXPECT_FALSE(didDismissWebViewController);
+ EXPECT_NULL([webViewController presentedViewController]);
+ EXPECT_NOT_NULL([webViewController presentingViewController]);
+}
+
TEST(ActionSheetTests, ImageMapDoesNotDestroySelection)
{
IPadUserInterfaceSwizzler iPadUserInterface;
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (229541 => 229542)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2018-03-12 19:25:19 UTC (rev 229542)
@@ -46,6 +46,7 @@
@interface TestWKWebView : WKWebView
- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration processPoolConfiguration:(_WKProcessPoolConfiguration *)processPoolConfiguration;
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration addToWindow:(BOOL)addToWindow;
- (void)clearMessageHandlers:(NSArray *)messageNames;
- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
- (void)loadTestPageNamed:(NSString *)pageName;
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (229541 => 229542)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2018-03-12 19:25:19 UTC (rev 229542)
@@ -175,7 +175,16 @@
- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
{
- if (self = [super initWithFrame:frame configuration:configuration])
+ return [self initWithFrame:frame configuration:configuration addToWindow:YES];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration addToWindow:(BOOL)addToWindow
+{
+ self = [super initWithFrame:frame configuration:configuration];
+ if (!self)
+ return nil;
+
+ if (addToWindow)
[self _setUpTestWindow:frame];
return self;
Added: trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.h (0 => 229542)
--- trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.h (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.h 2018-03-12 19:25:19 UTC (rev 229542)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 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 "TestWKWebView.h"
+
+#if PLATFORM(IOS)
+
+#import <UIKit/UIKit.h>
+
+@interface TestWKWebViewControllerWindow : UIWindow
+
+@end
+
+@interface TestWKWebViewController : UIViewController
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration;
+
+@property (nonatomic, readonly) TestWKWebView *webView;
+@property (nonatomic, copy) dispatch_block_t dismissalHandler;
+
+@end
+
+#endif // PLATFORM(IOS)
Added: trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.mm (0 => 229542)
--- trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/TestWKWebViewController.mm 2018-03-12 19:25:19 UTC (rev 229542)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2018 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 "TestWKWebViewController.h"
+
+#if PLATFORM(IOS)
+
+#import <wtf/BlockPtr.h>
+
+@implementation TestWKWebViewControllerWindow
+
+// These internal methods need to be stubbed out to prevent UIKit from throwing inconsistency
+// exceptions when making a UIWindow the key window, since TestWebKitAPI is not a UI application.
+// These stubs and this class can be removed once https://webkit.org/b/175204 is fixed.
+- (void)_beginKeyWindowDeferral
+{
+}
+
+- (void)_endKeyWindowDeferral
+{
+}
+
+@end
+
+@implementation TestWKWebViewController {
+ RetainPtr<WKWebViewConfiguration> _configuration;
+ CGRect _initialViewFrame;
+ RetainPtr<TestWKWebView> _webView;
+ BlockPtr<void()> _dismissalHandler;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _initialViewFrame = frame;
+ _configuration = configuration ?: adoptNS([[WKWebViewConfiguration alloc] init]);
+ return self;
+}
+
+- (void)loadView
+{
+ _webView = adoptNS([[TestWKWebView alloc] initWithFrame:_initialViewFrame configuration:_configuration.get() addToWindow:NO]);
+ self.view = _webView.get();
+}
+
+- (TestWKWebView *)webView
+{
+ [self loadViewIfNeeded];
+ return _webView.get();
+}
+
+- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)())completion
+{
+ if (_dismissalHandler)
+ _dismissalHandler();
+ [super dismissViewControllerAnimated:flag completion:completion];
+}
+
+- (dispatch_block_t)dismissalHandler
+{
+ return _dismissalHandler.get();
+}
+
+- (void)setDismissalHandler:(dispatch_block_t)dismissalHandler
+{
+ _dismissalHandler = makeBlockPtr(dismissalHandler);
+}
+
+@end
+
+#endif // PLATFORM(IOS)
Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (229541 => 229542)
--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2018-03-12 18:05:36 UTC (rev 229541)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2018-03-12 19:25:19 UTC (rev 229542)
@@ -32,6 +32,7 @@
#import <UIKit/UIApplication_Private.h>
#import <UIKit/UITextInputTraits_Private.h>
#import <UIKit/UITextInput_Private.h>
+#import <UIKit/UIViewController_Private.h>
#if ENABLE(DRAG_SUPPORT)
@protocol UIDragSession;
@@ -38,7 +39,7 @@
@class UIDragInteraction;
@class UIDragItem;
#import <UIKit/UIDragInteraction_Private.h>
-#endif
+#endif // ENABLE(DRAG_SUPPORT)
#else
@@ -95,4 +96,8 @@
@property (nonatomic, copy, setter=_setTitle:) NSString *_title;
@end
+@interface UIViewController (UIKitSPI)
++ (UIViewController *)_viewControllerForFullScreenPresentationFromView:(UIView *)view;
+@end
+
#endif // PLATFORM(IOS)