Changeset 219378 in webkit


Ignore:
Timestamp:
Jul 11, 2017 5:25:41 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
https://bugs.webkit.org/show_bug.cgi?id=174239

Patch by Ansh Shukla <ansh_shukla@apple.com> on 2017-07-11
Reviewed by Brady Eidson.

Source/WebKit2:

Add a new private header to expose getters for window feature properties already available
in the TFB APIWindowFeatures class. These properties are necessary for Safari to adopt more
modern API.

  • UIProcess/API/Cocoa/WKWindowFeatures.mm:

(-[WKWindowFeatures _locationBarVisibility]):
(-[WKWindowFeatures _scrollbarsVisibility]):
(-[WKWindowFeatures _fullscreenDisplay]):
(-[WKWindowFeatures _dialogDisplay]):

  • UIProcess/API/Cocoa/WKWindowFeaturesInternal.h: Expose some window features as read-only

properties.

  • UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h:
  • WebKit2.xcodeproj/project.pbxproj:

Tools:

Create windows with specific features set and make sure those are properly reflected in the
WKWindowFeatures object.

  • TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:

(resetToConsistentState):
(-[CheckWindowFeaturesUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
(TEST):

Location:
trunk
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r219374 r219378  
     12017-07-11  Ansh Shukla  <ansh_shukla@apple.com>
     2
     3        WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
     4        https://bugs.webkit.org/show_bug.cgi?id=174239
     5
     6        Reviewed by Brady Eidson.
     7
     8        Add a new private header to expose getters for window feature properties already available
     9        in the TFB APIWindowFeatures class. These properties are necessary for Safari to adopt more
     10        modern API.
     11
     12        * UIProcess/API/Cocoa/WKWindowFeatures.mm:
     13        (-[WKWindowFeatures _locationBarVisibility]):
     14        (-[WKWindowFeatures _scrollbarsVisibility]):
     15        (-[WKWindowFeatures _fullscreenDisplay]):
     16        (-[WKWindowFeatures _dialogDisplay]):
     17        * UIProcess/API/Cocoa/WKWindowFeaturesInternal.h: Expose some window features as read-only
     18        properties.
     19        * UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h:
     20        * WebKit2.xcodeproj/project.pbxproj:
     21
    1222017-07-11  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeatures.mm

    r188553 r219378  
    102102@end
    103103
     104@implementation WKWindowFeatures (WKPrivate)
     105
     106- (NSNumber *)_locationBarVisibility
     107{
     108    return @(_windowFeatures->windowFeatures().locationBarVisible);
     109}
     110
     111- (NSNumber *)_scrollbarsVisibility
     112{
     113    return @(_windowFeatures->windowFeatures().scrollbarsVisible);
     114}
     115
     116- (NSNumber *)_fullscreenDisplay
     117{
     118    return @(_windowFeatures->windowFeatures().fullscreen);
     119}
     120
     121- (NSNumber *)_dialogDisplay
     122{
     123    return @(_windowFeatures->windowFeatures().dialog);
     124}
     125
     126@end
     127
    104128#endif
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeaturesInternal.h

    r188553 r219378  
    2424 */
    2525
    26 #import "WKWindowFeatures.h"
     26#import "WKWindowFeaturesPrivate.h"
    2727
    2828#if WK_API_ENABLED
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h

    r219376 r219378  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "WKWindowFeatures.h"
     26#import <WebKit/WKWindowFeatures.h>
    2727
    2828#if WK_API_ENABLED
    2929
    30 #import "APIWindowFeatures.h"
    31 #import "WKObject.h"
     30NS_ASSUME_NONNULL_BEGIN
    3231
    33 namespace WebKit {
     32@interface WKWindowFeatures (WKPrivate)
    3433
    35 inline WKWindowFeatures *wrapper(API::WindowFeatures& windowFeatures)
    36 {
    37     ASSERT([windowFeatures.wrapper() isKindOfClass:[WKWindowFeatures class]]);
     34@property (nullable, nonatomic, readonly) NSNumber *_locationBarVisibility WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     35@property (nullable, nonatomic, readonly) NSNumber *_scrollbarsVisibility WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     36@property (nullable, nonatomic, readonly) NSNumber *_fullscreenDisplay WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     37@property (nullable, nonatomic, readonly) NSNumber *_dialogDisplay WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    3838
    39     return (WKWindowFeatures *)windowFeatures.wrapper();
    40 }
    41 
    42 }
    43 @interface WKWindowFeatures () <WKObject> {
    44 @package
    45     API::ObjectStorage<API::WindowFeatures> _windowFeatures;
    46 }
    4739@end
    4840
     41NS_ASSUME_NONNULL_END
     42
    4943#endif
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r219312 r219378  
    11901190                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
    11911191                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1192                6A5080BF1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; };
    11921193                6B821DDC1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B821DDA1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.h */; };
    11931194                6B821DDD1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B821DDB1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.cpp */; };
     
    34733474                65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
    34743475                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
     3476                6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWindowFeaturesPrivate.h; sourceTree = "<group>"; };
    34753477                6B821DDA1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsTelemetry.h; sourceTree = "<group>"; };
    34763478                6B821DDB1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsTelemetry.cpp; sourceTree = "<group>"; };
     
    57415743                                26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */,
    57425744                                1AD60F5C18E20F4C0020C034 /* WKWindowFeatures.h */,
     5745                                6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */,
    57435746                                1AD60F5B18E20F4C0020C034 /* WKWindowFeatures.mm */,
    57445747                                1AD60F5F18E20F740020C034 /* WKWindowFeaturesInternal.h */,
     
    87668769                                31D5929F166E060000E6BF02 /* WebPlugInClient.h in Headers */,
    87678770                                BC5744F012638FB3006F0F12 /* WebPopupItem.h in Headers */,
     8771                                6A5080BF1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h in Headers */,
    87688772                                D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */,
    87698773                                BC574E631267D080006F0F12 /* WebPopupMenuProxy.h in Headers */,
  • trunk/Tools/ChangeLog

    r219376 r219378  
     12017-07-11  Ansh Shukla  <ansh_shukla@apple.com>
     2
     3        WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
     4        https://bugs.webkit.org/show_bug.cgi?id=174239
     5
     6        Reviewed by Brady Eidson.
     7
     8        Create windows with specific features set and make sure those are properly reflected in the
     9        WKWindowFeatures object.
     10
     11        * TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:
     12        (resetToConsistentState):
     13        (-[CheckWindowFeaturesUIDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]):
     14        (TEST):
     15
    1162017-07-11  Jonathan Bedard  <jbedard@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm

    r215598 r219378  
    3131#import <WebKit/WKWebView.h>
    3232#import <WebKit/WKWebViewConfiguration.h>
     33#import <WebKit/WKWindowFeaturesPrivate.h>
    3334#import <wtf/RetainPtr.h>
    3435
     
    3738@class OpenAndCloseWindowUIDelegate;
    3839@class OpenAndCloseWindowUIDelegateAsync;
     40@class CheckWindowFeaturesUIDelegate;
    3941
    4042static bool isDone;
    4143static RetainPtr<WKWebView> openedWebView;
     44static RetainPtr<WKWindowFeatures> openWindowFeatures;
    4245static RetainPtr<OpenAndCloseWindowUIDelegate> sharedUIDelegate;
    4346static RetainPtr<OpenAndCloseWindowUIDelegateAsync> sharedUIDelegateAsync;
     47static RetainPtr<CheckWindowFeaturesUIDelegate> sharedCheckWindowFeaturesUIDelegate;
    4448
    4549static void resetToConsistentState()
     
    4953    sharedUIDelegate = nil;
    5054    sharedUIDelegateAsync = nil;
     55    sharedCheckWindowFeaturesUIDelegate = nil;
    5156}
    5257
     
    203208//}
    204209
     210
     211@interface CheckWindowFeaturesUIDelegate : NSObject <WKUIDelegate>
     212
     213@property (nullable, nonatomic, readonly) NSNumber *menuBarVisibility;
     214@property (nullable, nonatomic, readonly) NSNumber *statusBarVisibility;
     215@property (nullable, nonatomic, readonly) NSNumber *toolbarsVisibility;
     216
     217@end
     218
     219@implementation CheckWindowFeaturesUIDelegate
     220
     221- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
     222{
     223    openWindowFeatures = windowFeatures;
     224    isDone = true;
     225
     226    return nil;
     227}
     228
     229@end
     230
     231TEST(WebKit2, OpenWindowFeatures)
     232{
     233    resetToConsistentState();
     234
     235    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     236
     237    sharedCheckWindowFeaturesUIDelegate = adoptNS([[CheckWindowFeaturesUIDelegate alloc] init]);
     238    [webView setUIDelegate:sharedCheckWindowFeaturesUIDelegate.get()];
     239    [webView configuration].preferences.javaScriptCanOpenWindowsAutomatically = YES;
     240    NSString *windowOpenFormatString = @"window.open(\"about:blank\", \"_blank\", \"%@\")";
     241
     242    [webView evaluateJavaScript:@"window.open(\"about:blank\")" completionHandler:nil];
     243    TestWebKitAPI::Util::run(&isDone);
     244    isDone = false;
     245
     246//  https://bugs.webkit.org/show_bug.cgi?id=174271 - WebCore currently doesn't distinguish between unspecified (nil) and false
     247//  for the following window features.
     248//  EXPECT_TRUE([openWindowFeatures menuBarVisibility] == nil);
     249//  EXPECT_TRUE([openWindowFeatures statusBarVisibility] == nil);
     250//  EXPECT_TRUE([openWindowFeatures toolbarsVisibility] == nil);
     251//  EXPECT_TRUE([openWindowFeatures allowsResizing] == nil);
     252//  EXPECT_TRUE([openWindowFeatures _locationBarVisibility] == nil);
     253//  EXPECT_TRUE([openWindowFeatures _scrollbarsVisibility] == nil);
     254//  EXPECT_TRUE([openWindowFeatures _fullscreenDisplay] == nil);
     255//  EXPECT_TRUE([openWindowFeatures _dialogDisplay] == nil);
     256    openWindowFeatures = nullptr;
     257
     258    NSString *featuresStringAllSpecifiedAndTrue = @"menubar=yes,status=yes,toolbar=yes,resizable=yes,location=yes,scrollbars=yes,fullscreen=yes";
     259    [webView evaluateJavaScript:[NSString stringWithFormat:windowOpenFormatString, featuresStringAllSpecifiedAndTrue] completionHandler:nil];
     260    TestWebKitAPI::Util::run(&isDone);
     261    isDone = false;
     262
     263    EXPECT_TRUE([openWindowFeatures menuBarVisibility].boolValue);
     264    EXPECT_TRUE([openWindowFeatures statusBarVisibility].boolValue);
     265    EXPECT_TRUE([openWindowFeatures toolbarsVisibility].boolValue);
     266    EXPECT_TRUE([openWindowFeatures allowsResizing].boolValue);
     267    EXPECT_TRUE([openWindowFeatures _locationBarVisibility].boolValue);
     268    EXPECT_TRUE([openWindowFeatures _scrollbarsVisibility].boolValue);
     269    EXPECT_TRUE([openWindowFeatures _fullscreenDisplay].boolValue);
     270    openWindowFeatures = nullptr;
     271
     272    NSString *featuresStringAllSpecifiedAndFalse = @"menubar=no,status=no,toolbar=no,resizable=no,location=no,scrollbars=no,fullscreen=no";
     273    [webView evaluateJavaScript:[NSString stringWithFormat:windowOpenFormatString, featuresStringAllSpecifiedAndFalse] completionHandler:nil];
     274    TestWebKitAPI::Util::run(&isDone);
     275    isDone = false;
     276
     277    EXPECT_FALSE([openWindowFeatures menuBarVisibility].boolValue);
     278    EXPECT_FALSE([openWindowFeatures statusBarVisibility ].boolValue);
     279    EXPECT_FALSE([openWindowFeatures toolbarsVisibility].boolValue);
     280//  https://bugs.webkit.org/show_bug.cgi?id=174388 - This property doesn't accurately reflect the parameters passed by the webpage.
     281//  EXPECT_FALSE([openWindowFeatures allowsResizing].boolValue);
     282    EXPECT_FALSE([openWindowFeatures _locationBarVisibility].boolValue);
     283    EXPECT_FALSE([openWindowFeatures _scrollbarsVisibility].boolValue);
     284    EXPECT_FALSE([openWindowFeatures _fullscreenDisplay].boolValue);
     285    openWindowFeatures = nullptr;
     286}
     287
    205288#endif
Note: See TracChangeset for help on using the changeset viewer.