⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 295290 in webkit


Ignore:
Timestamp:
Jun 6, 2022, 10:36:12 AM (4 years ago)
Author:
Wenson Hsieh
Message:

REGRESSION (r291302): editing/secure-input tests fail when run while a password input is focused on the system
​https://bugs.webkit.org/show_bug.cgi?id=241324
rdar://94184618

Reviewed by Alexey Proskuryakov.

The tests in editing/secure-input fail after the removal of WebCoreTestShim in r291302, if a
secure text field is focused anywhere on the system while the tests are running. This is because we
now call into the real system IsSecureEventInputEnabled() API during these tests, instead of the
shimmed version for testing.

Since interposing these API functions apparently doesn't work on M1 Macs, we can't use this
technique to ensure that these tests are robust moving forward; instead, introduce and use testing-
only SPI (and IPI) to consult whether or not we're currently editing a secure input.

See below for more details.

  • Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
  • Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm:

(-[WKWebView _secureEventInputEnabledForTesting]):

Add testing-only SPI on WKWebView to return whether or not we're in a secure input, as an
alternative to calling into the actual IsSecureEventInputEnabled() API.

  • Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj:
  • Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:

(-[WebHTMLView _secureEventInputEnabledForTesting]):

  • Source/WebKitLegacy/mac/WebView/WebHTMLViewForTestingMac.h: Copied from Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h.

Add a testing-only header file that's internal (i.e. non-exported), but imported in DumpRenderTree
through a Source-relative header include path. At the moment, this only contains a method to check
whether or not we're currently editing a secure text input, as an alternative to calling into
IsSecureEventInputEnabled().

  • Tools/DumpRenderTree/TestRunner.cpp:

(getSecureEventInputIsEnabledCallback):
(TestRunner::isSecureEventInputEnabled const):

Adjust DumpRenderTree to consult -[WebHTMLView _secureEventInputEnabledForTesting].

  • Tools/DumpRenderTree/TestRunner.h:
  • Tools/DumpRenderTree/mac/Configurations/Base.xcconfig:

Add a relative include path on DumpRenderTree, so that we can use WebHTMLViewForTestingMac.h in
DumpRenderTree without having to introduce new WebKitLegacy SPI.

  • Tools/DumpRenderTree/mac/TestRunnerMac.mm:

(TestRunner::isSecureEventInputEnabled const):

  • Tools/WebKitTestRunner/PlatformWebView.h:

(WTR::PlatformWebView::platformView const):
(WTR::PlatformWebView::platformWindow const):
(WTR::PlatformWebView::platformView): Deleted.
(WTR::PlatformWebView::platformWindow): Deleted.

Mark platformView const so that it can be invoked from isSecureEventInputEnabled, and also mark
platformWindow const for consistency.

  • Tools/WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

  • Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:

(WTR::PlatformWebView::isSecureEventInputEnabled const):

  • Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:

(WTR::PlatformWebView::isSecureEventInputEnabled const):

  • Tools/WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp:

(WTR::PlatformWebView::isSecureEventInputEnabled const):

  • Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm:

(WTR::PlatformWebView::isSecureEventInputEnabled const):

Add a new isSecureEventInputEnabled method on the PlatformWebView, and adjust WebKitTestRunner
to consult -[WKWebView _secureEventInputEnabledForTesting].

  • Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp:

(WTR::PlatformWebView::isSecureEventInputEnabled const):

Canonical link: ​https://commits.webkit.org/251336@main

Location:
trunk
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h

    r294285 r295290  
    5656- (void)_retrieveAccessibilityTreeData:(void (^)(NSData *, NSError *))completionHandler;
    5757
     58@property (nonatomic, readonly) BOOL _secureEventInputEnabledForTesting;
     59
    5860@end
    5961
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm

    r294285 r295290  
    134134}
    135135
     136- (BOOL)_secureEventInputEnabledForTesting
     137{
     138    return _impl->inSecureInputState();
     139}
     140
    136141@end
    137142
  • trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj

    r292959 r295290  
    44        classes = {
    55        };
    6         objectVersion = 51;
     6        objectVersion = 52;
    77        objects = {
    88
    … …  
    670670                ED5B9524111B725A00472298 /* WebLocalizableStrings.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED5B9523111B725A00472298 /* WebLocalizableStrings.mm */; };
    671671                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     672                F439B1A1284D8C39003DE041 /* WebHTMLViewForTestingMac.h in Headers */ = {isa = PBXBuildFile; fileRef = F439B1A0284D8C39003DE041 /* WebHTMLViewForTestingMac.h */; };
    672673                F4C98E5D1DD6476F0012FDEC /* DOMHTMLElementPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F4C98E5C1DD6476F0012FDEC /* DOMHTMLElementPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    673674                F4F665C21DD67672007714B4 /* WebAutocapitalizeTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = F4F665C11DD67672007714B4 /* WebAutocapitalizeTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    … …  
    15311532                EDD1A5C705C83987008E3150 /* WebNSPrintOperationExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSPrintOperationExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    15321533                EDE850CD06ECC79E005FAB05 /* WebPreferenceKeysPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferenceKeysPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     1534                F439B1A0284D8C39003DE041 /* WebHTMLViewForTestingMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebHTMLViewForTestingMac.h; sourceTree = "<group>"; };
    15331535                F4C98E5C1DD6476F0012FDEC /* DOMHTMLElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLElementPrivate.h; sourceTree = "<group>"; };
    15341536                F4F665C11DD67672007714B4 /* WebAutocapitalizeTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutocapitalizeTypes.h; sourceTree = "<group>"; };
    … …  
    22052207                                35081D9402B6D4D80ACA2ACA /* WebHTMLView.h */,
    22062208                                35081D9502B6D4D80ACA2ACA /* WebHTMLView.mm */,
     2209                                F439B1A0284D8C39003DE041 /* WebHTMLViewForTestingMac.h */,
    22072210                                93185DB506679F42005D5E7E /* WebHTMLViewInternal.h */,
    22082211                                35081D9602B6D4D80ACA2ACA /* WebHTMLViewPrivate.h */,
    … …  
    30253028                                939810560824BF01008DF038 /* WebHTMLRepresentationPrivate.h in Headers */,
    30263029                                939810570824BF01008DF038 /* WebHTMLView.h in Headers */,
     3030                                F439B1A1284D8C39003DE041 /* WebHTMLViewForTestingMac.h in Headers */,
    30273031                                939810A10824BF01008DF038 /* WebHTMLViewInternal.h in Headers */,
    30283032                                939810580824BF01008DF038 /* WebHTMLViewPrivate.h in Headers */,
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r295270 r295290  
    71047104@end
    71057105
     7106#if PLATFORM(MAC)
     7107
     7108@implementation WebHTMLView (TestingSupportMac)
     7109
     7110- (BOOL)_secureEventInputEnabledForTesting
     7111{
     7112    return _private->isInSecureInputState;
     7113}
     7114
     7115@end
     7116
     7117#endif // PLATFORM(MAC)
     7118
    71067119// This is used by AppKit/TextKit. It should be possible to remove this once
    71077120// -[NSAttributedString _documentFromRange:document:documentAttributes:subresources:] is removed.
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLViewForTestingMac.h

    r295289 r295290  
    11/*
    2  * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2424 */
    2525
    26 #import <WebKit/WKBase.h>
    27 #import <WebKit/WKWebView.h>
     26#pragma once
    2827
    29 #if !TARGET_OS_IPHONE
     28#if PLATFORM(MAC)
    3029
    31 @class _WKFrameHandle;
     30#import <WebKit/WebHTMLView.h>
    3231
    33 @interface WKWebView (WKTestingMac)
    34 
    35 @property (nonatomic, readonly) BOOL _hasActiveVideoForControlsManager;
    36 @property (nonatomic, readonly) BOOL _shouldRequestCandidates;
    37 @property (nonatomic, readonly) NSMenu *_activeMenu;
    38 
    39 - (void)_requestControlledElementID;
    40 - (void)_handleControlledElementIDResponse:(NSString *)identifier;
    41 
    42 - (void)_handleAcceptedCandidate:(NSTextCheckingResult *)candidate;
    43 - (void)_didHandleAcceptedCandidate;
    44 
    45 - (void)_forceRequestCandidates;
    46 - (void)_didUpdateCandidateListVisibility:(BOOL)visible;
    47 
    48 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange;
    49 - (NSRect)_candidateRect;
    50 
    51 - (void)_setHeaderBannerHeight:(int)height;
    52 - (void)_setFooterBannerHeight:(int)height;
    53 - (NSSet<NSView *> *)_pdfHUDs;
    54 
    55 - (void)_simulateMouseMove:(NSEvent *)event;
    56 - (void)_retrieveAccessibilityTreeData:(void (^)(NSData *, NSError *))completionHandler;
    57 
     32@interface WebHTMLView (TestingSupportMac)
     33@property (nonatomic, readonly) BOOL _secureEventInputEnabledForTesting;
    5834@end
    5935
    60 #endif // !TARGET_OS_IPHONE
     36#endif // PLATFORM(MAC)
  • trunk/Tools/DumpRenderTree/TestRunner.cpp

    r292929 r295290  
    16351635{
    16361636#if PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
    1637     return JSValueMakeBoolean(context, IsSecureEventInputEnabled());
     1637    return JSValueMakeBoolean(context, static_cast<TestRunner*>(JSObjectGetPrivate(thisObject))->isSecureEventInputEnabled());
    16381638#else
    16391639    return JSValueMakeBoolean(context, false);
    … …  
    23732373    }
    23742374}
     2375
     2376#if !PLATFORM(MAC)
     2377
     2378bool TestRunner::isSecureEventInputEnabled() const
     2379{
     2380    return false;
     2381}
     2382
     2383#endif
  • trunk/Tools/DumpRenderTree/TestRunner.h

    r290098 r295290  
    386386    void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
    387387
     388    bool isSecureEventInputEnabled() const;
     389
    388390private:
    389391    TestRunner(const std::string& testURL, const std::string& expectedPixelHash);
  • trunk/Tools/DumpRenderTree/mac/Configurations/Base.xcconfig

    r293043 r295290  
    152152
    153153HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(BUILT_PRODUCTS_DIR)/WebCoreTestSupport ForwardingHeaders $(HEADER_SEARCH_PATHS_$(WK_COCOA_TOUCH));
    154 HEADER_SEARCH_PATHS_ = mac/InternalHeaders $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport;
     154HEADER_SEARCH_PATHS_ = mac/InternalHeaders $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport $(SRCROOT)/../../Source/WebKitLegacy/mac/WebView;
    155155HEADER_SEARCH_PATHS_cocoatouch = $(SDKROOT)/usr/local/include $(SDKROOT)/usr/local/include/WebCoreTestSupport $(SRCROOT)/../../Source/WebKit/Platform/spi/ios;
  • trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm

    r290098 r295290  
    8686#endif
    8787
     88#if PLATFORM(MAC)
     89#import "WebHTMLViewForTestingMac.h"
     90#endif
     91
    8892#if !PLATFORM(IOS_FAMILY)
    8993
    … …  
    11981202    return imagesArray.count;
    11991203}
     1204
     1205#if PLATFORM(MAC)
     1206
     1207bool TestRunner::isSecureEventInputEnabled() const
     1208{
     1209    return dynamic_objc_cast<WebHTMLView>(mainFrame.frameView.documentView)._secureEventInputEnabledForTesting;
     1210}
     1211
     1212#endif // PLATFORM(MAC)
  • trunk/Tools/WebKitTestRunner/PlatformWebView.h

    r289887 r295290  
    7777
    7878    WKPageRef page();
    79     PlatformWKView platformView() { return m_view; }
    80     PlatformWindow platformWindow() { return m_window; }
     79    PlatformWKView platformView() const { return m_view; }
     80    PlatformWindow platformWindow() const { return m_window; }
    8181    static PlatformWindow keyWindow();
    8282
    … …  
    103103    void selectChromeInputField();
    104104    String getSelectedTextInChromeInputField();
     105
     106    bool isSecureEventInputEnabled() const;
    105107
    106108    bool drawsBackground() const;
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r294852 r295290  
    909909    }
    910910
    911     if (WKStringIsEqualToUTF8CString(messageName, "SecureEventInputIsEnabled")) {
    912 #if PLATFORM(MAC)
    913         return adoptWK(WKBooleanCreate(IsSecureEventInputEnabled()));
    914 #else
    915         return adoptWK(WKBooleanCreate(false));
    916 #endif
    917     }
     911    if (WKStringIsEqualToUTF8CString(messageName, "SecureEventInputIsEnabled"))
     912        return adoptWK(WKBooleanCreate(TestController::singleton().mainWebView()->isSecureEventInputEnabled()));
    918913
    919914    if (WKStringIsEqualToUTF8CString(messageName, "SetCustomUserAgent")) {
  • trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp

    r280288 r295290  
    300300}
    301301
     302bool PlatformWebView::isSecureEventInputEnabled() const
     303{
     304    return false;
     305}
     306
    302307} // namespace WTR
    303308
  • trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm

    r280288 r295290  
    439439}
    440440
     441bool PlatformWebView::isSecureEventInputEnabled() const
     442{
     443    return false;
     444}
     445
    441446} // namespace WTR
  • trunk/Tools/WebKitTestRunner/libwpe/PlatformWebViewLibWPE.cpp

    r289887 r295290  
    158158}
    159159
     160bool PlatformWebView::isSecureEventInputEnabled() const
     161{
     162    return false;
     163}
     164
    160165} // namespace WTR
  • trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

    r281461 r295290  
    3535#import <WebKit/WKWebViewConfiguration.h>
    3636#import <WebKit/WKWebViewPrivate.h>
     37#import <WebKit/WKWebViewPrivateForTesting.h>
    3738#import <wtf/RetainPtr.h>
    3839#import <wtf/text/WTFString.h>
    … …  
    255256}
    256257
     258bool PlatformWebView::isSecureEventInputEnabled() const
     259{
     260    return platformView()._secureEventInputEnabledForTesting;
     261}
     262
    257263} // namespace WTR
  • trunk/Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp

    r288784 r295290  
    279279}
    280280
     281bool PlatformWebView::isSecureEventInputEnabled() const
     282{
     283    return false;
     284}
     285
    281286} // namespace WTR
Note: See TracChangeset for help on using the changeset viewer.