Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
browser(webkit): refresh embedder UI on macOS (#5957)
Pavel Feldman6c1d3f65b5bd
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBERindex 84772226f1..f6bc9fe8ab 100644--- a/browser_patches/webkit/BUILD_NUMBER+++ b/browser_patches/webkit/BUILD_NUMBER@@ -1,2 +1,2 @@-1449-Changed: [email protected] Tue 23 Mar 2021 11:19:43 AM PDT+1450+Changed: [email protected] Thu Mar 25 22:36:32 PDT 2021diff --git a/browser_patches/webkit/embedder/Playwright/Playwright.xcodeproj/project.pbxproj b/browser_patches/webkit/embedder/Playwright/Playwright.xcodeproj/project.pbxprojindex 75a945e72d..913b63c812 100644--- a/browser_patches/webkit/embedder/Playwright/Playwright.xcodeproj/project.pbxproj+++ b/browser_patches/webkit/embedder/Playwright/Playwright.xcodeproj/project.pbxproj@@ -9,6 +9,7 @@/* Begin PBXBuildFile section */256AC3DA0F4B6AC300CF336A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF336A /* AppDelegate.m */; };51E244FA11EFCE07008228D2 /* MBToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 51E244F911EFCE07008228D2 /* MBToolbarItem.m */; };+ 5C9332AF24C1349C0036DECF /* SecurityInterface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C9332AE24C1349C0036DECF /* SecurityInterface.framework */; };BC329487116A92E2008635D1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329486116A92E2008635D1 /* main.m */; };BC329498116A941B008635D1 /* BrowserWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC329497116A941B008635D1 /* BrowserWindowController.m */; };BC72B89511E57E07001EB4EB /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58150DA1D0A300B3202A /* MainMenu.xib */; };@@ -27,6 +28,7 @@37BAF90620218053000EA87A /* Playwright.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Playwright.entitlements; sourceTree = "<group>"; };51E244F811EFCE07008228D2 /* MBToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBToolbarItem.h; sourceTree = "<group>"; };51E244F911EFCE07008228D2 /* MBToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBToolbarItem.m; sourceTree = "<group>"; };+ 5C9332AE24C1349C0036DECF /* SecurityInterface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SecurityInterface.framework; path = System/Library/Frameworks/SecurityInterface.framework; sourceTree = SDKROOT; };8D1107320486CEB800E47091 /* Playwright.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Playwright.app; sourceTree = BUILT_PRODUCTS_DIR; };A1B89B95221E027A00EB4CEB /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };BC329486116A92E2008635D1 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = mac/main.m; sourceTree = "<group>"; };@@ -44,6 +46,7 @@isa = PBXFrameworksBuildPhase;buildActionMask = 2147483647;files = (+ 5C9332AF24C1349C0036DECF /* SecurityInterface.framework in Frameworks */,);runOnlyForDeploymentPostprocessing = 0;};@@ -111,6 +114,7 @@children = (1058C7A2FEA54F0111CA2CBC /* Other Frameworks */,1AFFEF761860EE6800DA465F /* Cocoa.framework */,+ 5C9332AE24C1349C0036DECF /* SecurityInterface.framework */,);name = Frameworks;sourceTree = "<group>";diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xibindex f6f3d8e3a0..3634203bf2 100644--- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib+++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib@@ -1,8 +1,8 @@<?xml version="1.0" encoding="UTF-8"?>-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11191" systemVersion="16D17a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"><dependencies>- <deployment identifier="macosx"/>- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11191"/>+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/></dependencies><objects><customObject id="-2" userLabel="File's Owner" customClass="BrowserWindowController">@@ -10,6 +10,7 @@<outlet property="backButton" destination="40" id="46"/><outlet property="containerView" destination="9" id="37"/><outlet property="forwardButton" destination="42" id="47"/>+ <outlet property="lockButton" destination="mWN-r5-XQb" id="49"/><outlet property="progressIndicator" destination="21" id="33"/><outlet property="reloadButton" destination="23" id="34"/><outlet property="share" destination="1hB-AH-eUl" id="si4-8e-DsM"/>@@ -21,16 +22,16 @@</customObject><customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/><customObject id="-3" userLabel="Application" customClass="NSObject"/>- <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" frameAutosaveName="Main Window" animationBehavior="default" id="1">- <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" unifiedTitleAndToolbar="YES" fullSizeContentView="YES"/>+ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" frameAutosaveName="Main Window" animationBehavior="default" id="1">+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/><windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/><rect key="contentRect" x="517" y="330" width="776" height="608"/>- <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>+ <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/><view key="contentView" id="2"><rect key="frame" x="0.0" y="0.0" width="776" height="608"/>- <autoresizingMask key="autoresizingMask"/>+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/><subviews>- <customView id="9">+ <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9"><rect key="frame" x="0.0" y="0.0" width="776" height="608"/><autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/></customView>@@ -40,7 +41,7 @@<allowedToolbarItems><toolbarItem implicitItemIdentifier="73DE9F4B-73E2-4036-A134-2D9E029DA980" label="Go Back" paletteLabel="Go Back" image="NSGoLeftTemplate" id="56" customClass="MBToolbarItem"><nil key="toolTip"/>- <size key="minSize" width="32" height="27"/>+ <size key="minSize" width="32" height="25"/><size key="maxSize" width="32" height="25"/><button key="view" verticalHuggingPriority="750" id="40"><rect key="frame" x="10" y="14" width="32" height="25"/>@@ -56,7 +57,7 @@</toolbarItem><toolbarItem implicitItemIdentifier="E1A9D32A-59E3-467B-9ABA-A95780416E69" label="Go Forward" paletteLabel="Go Forward" image="NSGoRightTemplate" id="57" customClass="MBToolbarItem"><nil key="toolTip"/>- <size key="minSize" width="32" height="27"/>+ <size key="minSize" width="32" height="25"/><size key="maxSize" width="32" height="27"/><button key="view" verticalHuggingPriority="750" id="42"><rect key="frame" x="18" y="14" width="32" height="25"/>@@ -72,7 +73,7 @@</toolbarItem><toolbarItem implicitItemIdentifier="88C16109-D40F-4682-BCE4-CBEE2EDE32D2" label="Refresh" paletteLabel="Refresh" image="NSRefreshTemplate" id="58" customClass="MBToolbarItem"><nil key="toolTip"/>- <size key="minSize" width="29" height="27"/>+ <size key="minSize" width="29" height="25"/><size key="maxSize" width="29" height="27"/><button key="view" verticalHuggingPriority="750" id="23"><rect key="frame" x="10" y="14" width="29" height="25"/>@@ -86,9 +87,41 @@</connections></button></toolbarItem>+ <toolbarItem implicitItemIdentifier="F9C3B2C4-B22D-4E12-92BC-EA326711BBC1" label="Lock" paletteLabel="Lock" image="NSLockUnlockedTemplate" id="Ky3-6Y-3U1" userLabel="Lock" customClass="MBToolbarItem">+ <nil key="toolTip"/>+ <size key="minSize" width="29" height="25"/>+ <size key="maxSize" width="29" height="27"/>+ <button key="view" verticalHuggingPriority="750" id="mWN-r5-XQb">+ <rect key="frame" x="2" y="14" width="29" height="25"/>+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>+ <buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSLockUnlockedTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iRv-ey-QZe">+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>+ <font key="font" metaFont="system"/>+ </buttonCell>+ <connections>+ <action selector="showCertificate:" target="-2" id="LjW-s0-oJ2"/>+ </connections>+ </button>+ </toolbarItem>+ <toolbarItem implicitItemIdentifier="76DCF2B0-1DDE-47D2-9212-705E6E310CCE" label="Use Shrink To Fit" paletteLabel="Use Shrink To Fit" image="NSEnterFullScreenTemplate" id="81" customClass="MBToolbarItem">+ <nil key="toolTip"/>+ <size key="minSize" width="29" height="25"/>+ <size key="maxSize" width="29" height="27"/>+ <button key="view" verticalHuggingPriority="750" id="82">+ <rect key="frame" x="34" y="14" width="29" height="25"/>+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>+ <buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSEnterFullScreenTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="83">+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>+ <font key="font" metaFont="system"/>+ </buttonCell>+ <connections>+ <action selector="toggleShrinkToFit:" target="-2" id="gp7-Vk-KTI"/>+ </connections>+ </button>+ </toolbarItem><toolbarItem implicitItemIdentifier="F1738B7F-895C-48F7-955D-0915E150BE1B" label="Share" paletteLabel="Share" image="NSShareTemplate" id="dJx-dw-gcC" customClass="MBToolbarItem"><nil key="toolTip"/>- <size key="minSize" width="29" height="27"/>+ <size key="minSize" width="29" height="25"/><size key="maxSize" width="29" height="27"/><button key="view" verticalHuggingPriority="750" id="1hB-AH-eUl"><rect key="frame" x="5" y="14" width="29" height="25"/>@@ -111,7 +144,7 @@<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/><textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="11"><font key="font" metaFont="system"/>- <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/><color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/></textFieldCell><connections>@@ -119,10 +152,8 @@</connections></textField></toolbarItem>- <toolbarItem implicitItemIdentifier="86912BAA-B8D0-400F-BFEE-71FC166986E6" label="Progress" paletteLabel="Progress" tag="-1" id="60">+ <toolbarItem implicitItemIdentifier="86912BAA-B8D0-400F-BFEE-71FC166986E6" label="Progress" paletteLabel="Progress" tag="-1" sizingBehavior="auto" id="60"><nil key="toolTip"/>- <size key="minSize" width="16" height="16"/>- <size key="maxSize" width="16" height="16"/><progressIndicator key="view" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="1" displayedWhenStopped="NO" bezeled="NO" controlSize="small" style="spinning" id="21"><rect key="frame" x="19" y="14" width="16" height="16"/><autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>@@ -133,20 +164,23 @@<toolbarItem reference="56"/><toolbarItem reference="57"/><toolbarItem reference="58"/>+ <toolbarItem reference="Ky3-6Y-3U1"/><toolbarItem reference="59"/>- <toolbarItem reference="60"/><toolbarItem reference="dJx-dw-gcC"/>+ <toolbarItem reference="60"/></defaultToolbarItems></toolbar><connections><outlet property="delegate" destination="-2" id="4"/></connections>+ <point key="canvasLocation" x="-136" y="158"/></window></objects><resources><image name="NSEnterFullScreenTemplate" width="15" height="15"/><image name="NSGoLeftTemplate" width="9" height="12"/><image name="NSGoRightTemplate" width="9" height="12"/>+ <image name="NSLockUnlockedTemplate" width="10" height="14"/><image name="NSRefreshTemplate" width="11" height="15"/><image name="NSShareTemplate" width="11" height="16"/></resources>diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.hindex 4dbf13c8fb..ff9779c52a 100644--- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h+++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h@@ -29,6 +29,7 @@- (IBAction)goBack:(id)sender;- (IBAction)goForward:(id)sender;+- (IBAction)toggleFullWindowWebView:(id)sender;- (IBAction)reload:(id)sender;- (IBAction)saveAsPDF:(id)sender;- (IBAction)saveAsWebArchive:(id)sender;diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.mindex f5ef03729e..81cdec869b 100644--- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m+++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m@@ -26,6 +26,7 @@#import "BrowserWindowController.h"#import "AppDelegate.h"+#import <SecurityInterface/SFCertificateTrustPanel.h>#import <WebKit/WKFrameInfo.h>#import <WebKit/WKNavigationActionPrivate.h>#import <WebKit/WKNavigationDelegatePrivate.h>@@ -68,6 +69,7 @@ static void* keyValueObservingContext = &keyValueObservingContext;@implementation BrowserWindowController {IBOutlet NSProgressIndicator *progressIndicator;IBOutlet NSButton *reloadButton;+ IBOutlet NSButton *lockButton;IBOutlet NSButton *backButton;IBOutlet NSButton *forwardButton;IBOutlet NSButton *share;@@ -97,6 +99,18 @@ static void* keyValueObservingContext = &keyValueObservingContext;- (void)windowDidLoad{+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000+ // FIXME: We should probably adopt the default unified style, but we'd need+ // somewhere to put the window/page title.+ self.window.toolbarStyle = NSWindowToolbarStyleExpanded;++ reloadButton.image = [NSImage imageWithSystemSymbolName:@"arrow.clockwise" accessibilityDescription:@"Reload"];+ // FIXME: Should these be localized?+ backButton.image = [NSImage imageWithSystemSymbolName:@"chevron.left" accessibilityDescription:@"Go back"];+ forwardButton.image = [NSImage imageWithSystemSymbolName:@"chevron.right" accessibilityDescription:@"Go forward"];+ share.image = [NSImage imageWithSystemSymbolName:@"square.and.arrow.up" accessibilityDescription:@"Share"];+ toggleUseShrinkToFitButton.image = [NSImage imageWithSystemSymbolName:@"arrow.up.left.and.arrow.down.right" accessibilityDescription:@"Use Shrink to fit"];+#endif[share sendActionOn:NSEventMaskLeftMouseDown];[super windowDidLoad];}@@ -149,7 +163,6 @@ static void* keyValueObservingContext = &keyValueObservingContext;- (void)awakeFromNib{_webView = [[WKWebView alloc] initWithFrame:[containerView bounds] configuration:_configuration];- _webView._windowOcclusionDetectionEnabled = NO;_webView.allowsMagnification = YES;_webView.allowsBackForwardNavigationGestures = YES;@@ -162,6 +175,7 @@ static void* keyValueObservingContext = &keyValueObservingContext;[_webView addObserver:self forKeyPath:@"title" options:0 context:keyValueObservingContext];[_webView addObserver:self forKeyPath:@"URL" options:0 context:keyValueObservingContext];+ [_webView addObserver:self forKeyPath:@"hasOnlySecureContent" options:0 context:keyValueObservingContext];_webView.navigationDelegate = self;_webView.UIDelegate = self;@@ -202,6 +216,9 @@ static void* keyValueObservingContext = &keyValueObservingContext;- (void)dealloc{[[NSNotificationCenter defaultCenter] removeObserver:self];+ [_webView removeObserver:self forKeyPath:@"title"];+ [_webView removeObserver:self forKeyPath:@"URL"];+ [_webView removeObserver:self forKeyPath:@"hasOnlySecureContent"];[progressIndicator unbind:NSHiddenBinding];[progressIndicator unbind:NSValueBinding];@@ -282,7 +299,9 @@ static BOOL areEssentiallyEqual(double a, double b)if (action == @selector(resetZoom:))return [self canResetZoom];- if (action == @selector(toggleZoomMode:))+ if (action == @selector(toggleFullWindowWebView:))+ [menuItem setTitle:[self webViewFillsWindow] ? @"Inset Web View" : @"Fit Web View to Window"];+ else if (action == @selector(toggleZoomMode:))[menuItem setState:_zoomTextOnly ? NSControlStateValueOn : NSControlStateValueOff];else if (action == @selector(showHideWebInspector:))[menuItem setTitle:_webView._inspector.isVisible ? @"Close Web Inspector" : @"Show Web Inspector"];@@ -301,6 +320,12 @@ static BOOL areEssentiallyEqual(double a, double b)[_webView reload];}+- (IBAction)showCertificate:(id)sender+{+ if (_webView.serverTrust)+ [[SFCertificateTrustPanel sharedCertificateTrustPanel] beginSheetForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:NULL trust:_webView.serverTrust message:@"TLS Certificate Details"];+}+- (IBAction)goBack:(id)sender{[_webView goBack];@@ -311,6 +336,30 @@ static BOOL areEssentiallyEqual(double a, double b)[_webView goForward];}+- (IBAction)toggleFullWindowWebView:(id)sender+{+ BOOL newFillWindow = ![self webViewFillsWindow];+ [self setWebViewFillsWindow:newFillWindow];+}++- (BOOL)webViewFillsWindow+{+ return NSEqualRects(containerView.bounds, self.mainContentView.frame);+}++- (void)setWebViewFillsWindow:(BOOL)fillWindow+{+ if (fillWindow)+ [self.mainContentView setFrame:containerView.bounds];+ else {+ const CGFloat viewInset = 100.0f;+ NSRect viewRect = NSInsetRect(containerView.bounds, viewInset, viewInset);+ // Make it not vertically centered, to reveal y-flipping bugs.+ viewRect = NSOffsetRect(viewRect, 0, -25);+ [self.mainContentView setFrame:viewRect];+ }+}+- (IBAction)toggleZoomMode:(id)sender{if (_zoomTextOnly) {@@ -342,6 +391,13 @@ static BOOL areEssentiallyEqual(double a, double b)return _zoomTextOnly ? (_webView._textZoomFactor != 1) : (_webView.pageZoom != 1);}+- (IBAction)toggleShrinkToFit:(id)sender+{+ _useShrinkToFit = !_useShrinkToFit;+ toggleUseShrinkToFitButton.image = _useShrinkToFit ? [NSImage imageNamed:@"NSExitFullScreenTemplate"] : [NSImage imageNamed:@"NSEnterFullScreenTemplate"];+ [_webView _setLayoutMode:_useShrinkToFit ? _WKLayoutModeDynamicSizeComputedFromMinimumDocumentSize : _WKLayoutModeViewSize];+}+- (IBAction)showHideWebInspector:(id)sender{_WKInspector *inspector = _webView._inspector;@@ -489,6 +545,8 @@ static BOOL areEssentiallyEqual(double a, double b)[self updateTitle:_webView.title];else if ([keyPath isEqualToString:@"URL"])[self updateTextFieldFromURL:_webView.URL];+ else if ([keyPath isEqualToString:@"hasOnlySecureContent"])+ [self updateLockButtonIcon:_webView.hasOnlySecureContent];}- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures@@ -617,6 +675,14 @@ static BOOL areEssentiallyEqual(double a, double b)urlText.stringValue = [URL _web_userVisibleString];}+- (void)updateLockButtonIcon:(BOOL)hasOnlySecureContent+{+ if (hasOnlySecureContent)+ [lockButton setImage:[NSImage imageNamed:NSImageNameLockLockedTemplate]];+ else+ [lockButton setImage:[NSImage imageNamed:NSImageNameLockUnlockedTemplate]];+}+- (void)loadURLString:(NSString *)urlString{// FIXME: We shouldn't have to set the url text here.