Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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. Source/WebKit: 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:]): Tools: 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: Canonical link: https://commits.webkit.org/199236@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229542 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
410 additions
and 5 deletions.
- +16 −0 Source/WebKit/ChangeLog
- +5 −2 Source/WebKit/UIProcess/ios/WKActionSheet.mm
- +64 −0 Tools/ChangeLog
- +43 −0 Tools/TestWebKitAPI/ClassMethodSwizzler.h
- +42 −0 Tools/TestWebKitAPI/ClassMethodSwizzler.mm
- +12 −0 Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
- +69 −1 Tools/TestWebKitAPI/Tests/ios/ActionSheetTests.mm
- +1 −0 Tools/TestWebKitAPI/cocoa/TestWKWebView.h
- +10 −1 Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
- +45 −0 Tools/TestWebKitAPI/ios/TestWKWebViewController.h
- +97 −0 Tools/TestWebKitAPI/ios/TestWKWebViewController.mm
- +6 −1 Tools/TestWebKitAPI/ios/UIKitSPI.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.