Diff
Modified: trunk/LayoutTests/ChangeLog (246117 => 246118)
--- trunk/LayoutTests/ChangeLog 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/ChangeLog 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,22 @@
+2019-06-05 Wenson Hsieh <[email protected]>
+
+ Upstream content mode support into open source from WebKitAdditions
+ https://bugs.webkit.org/show_bug.cgi?id=198484
+ <rdar://problem/51355671>
+
+ Reviewed by Andy Estes.
+
+ Explicitly opt a few tests into desktop or mobile content mode.
+
+ * fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html:
+ * fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode-expected.html:
+ * fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode.html:
+ * media/modern-media-controls/media-controller/ios/media-controller-ios-layout-traits-modern-compatibility-mode.html:
+ * platform/ipad/fast/css/webkit-overflow-scrolling-parsing-modern-compatibility-mode.html:
+ * platform/ipad/fast/viewport/empty-meta.html:
+ * platform/ipad/fast/viewport/viewport-unchanged-by-minimum-effective-width-if-not-ignore-meta-viewport.html:
+ * platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html:
+
2019-06-05 Shawn Roberts <[email protected]>
imported/w3c/web-platform-tests/IndexedDB/keypath-special-identifiers.htm is a flaky failure
Modified: trunk/LayoutTests/fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html (246117 => 246118)
--- trunk/LayoutTests/fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true ] -->
+<!-- webkit-test-runner [ contentMode=desktop ] -->
<!DOCTYPE html>
<html>
<head>
Modified: trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode-expected.html (246117 => 246118)
--- trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode-expected.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode-expected.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true internal:AsyncOverflowScrollingEnabled=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=desktop internal:AsyncOverflowScrollingEnabled=true ] -->
<html>
<head>
<style>
Modified: trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode.html (246117 => 246118)
--- trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/fast/scrolling/ipad/overflow-scrolling-touch-enabled-stacking-modern-compatibility-mode.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true internal:AsyncOverflowScrollingEnabled=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=desktop internal:AsyncOverflowScrollingEnabled=true ] -->
<html>
<head>
<style>
Modified: trunk/LayoutTests/media/modern-media-controls/media-controller/ios/media-controller-ios-layout-traits-modern-compatibility-mode.html (246117 => 246118)
--- trunk/LayoutTests/media/modern-media-controls/media-controller/ios/media-controller-ios-layout-traits-modern-compatibility-mode.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/media/modern-media-controls/media-controller/ios/media-controller-ios-layout-traits-modern-compatibility-mode.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=desktop ] -->
<script src=""
<script src="" type="text/_javascript_"></script>
<body>
Modified: trunk/LayoutTests/platform/ipad/fast/css/webkit-overflow-scrolling-parsing-modern-compatibility-mode.html (246117 => 246118)
--- trunk/LayoutTests/platform/ipad/fast/css/webkit-overflow-scrolling-parsing-modern-compatibility-mode.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/platform/ipad/fast/css/webkit-overflow-scrolling-parsing-modern-compatibility-mode.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=desktop ] -->
<html>
<head>
<script src=""
Modified: trunk/LayoutTests/platform/ipad/fast/viewport/empty-meta.html (246117 => 246118)
--- trunk/LayoutTests/platform/ipad/fast/viewport/empty-meta.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/platform/ipad/fast/viewport/empty-meta.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=mobile ] -->
<html>
<head>
Modified: trunk/LayoutTests/platform/ipad/fast/viewport/viewport-unchanged-by-minimum-effective-width-if-not-ignore-meta-viewport.html (246117 => 246118)
--- trunk/LayoutTests/platform/ipad/fast/viewport/viewport-unchanged-by-minimum-effective-width-if-not-ignore-meta-viewport.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/platform/ipad/fast/viewport/viewport-unchanged-by-minimum-effective-width-if-not-ignore-meta-viewport.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=mobile ] -->
<html>
<head>
<style>
Modified: trunk/LayoutTests/platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html (246117 => 246118)
--- trunk/LayoutTests/platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/LayoutTests/platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,4 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ contentMode=mobile ] -->
<script src=""
<meta name="viewport" content="width=device-width, initial-scale=1">
<body>
Modified: trunk/Source/WebCore/ChangeLog (246117 => 246118)
--- trunk/Source/WebCore/ChangeLog 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/ChangeLog 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,24 @@
+2019-06-05 Wenson Hsieh <[email protected]>
+
+ Upstream content mode support into open source from WebKitAdditions
+ https://bugs.webkit.org/show_bug.cgi?id=198484
+ <rdar://problem/51355671>
+
+ Reviewed by Andy Estes.
+
+ * Modules/modern-media-controls/media/media-controller.js:
+ (MediaController.prototype.get layoutTraits):
+
+ Adjust modern media controls code to use iOS-style controls on PLATFORM(IOS_FAMILY), instead of depending on the
+ navigator's platform name or the presence of touch events.
+
+ * page/Quirks.cpp:
+ (WebCore::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost):
+ (WebCore::shouldEmulateUndoRedoInHiddenEditableAreasForHost):
+ * page/SettingsBase.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::mediaControlsScript):
+
2019-06-05 Saam Barati <[email protected]>
[WHLSL] checkDuplicateFunctions() should not be O(n^2)
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (246117 => 246118)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2019-06-05 18:23:06 UTC (rev 246118)
@@ -99,8 +99,7 @@
if (this.host && this.host.compactMode)
return LayoutTraits.Compact;
- // The window.navigator.platform !== "MacIntel" is strictly used for the test infrastructure since touch events are off for open-source bots.
- let traits = GestureRecognizer.SupportsTouches || window.navigator.platform !== "MacIntel" ? LayoutTraits.iOS : LayoutTraits.macOS;
+ let traits = window.isIOSFamily ? LayoutTraits.iOS : LayoutTraits.macOS;
if (this.isFullscreen)
return traits | LayoutTraits.Fullscreen;
return traits;
Modified: trunk/Source/WebCore/PAL/ChangeLog (246117 => 246118)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,15 @@
+2019-06-05 Wenson Hsieh <[email protected]>
+
+ Upstream content mode support into open source from WebKitAdditions
+ https://bugs.webkit.org/show_bug.cgi?id=198484
+ <rdar://problem/51355671>
+
+ Reviewed by Andy Estes.
+
+ Add some new constants to MobileGestaltSPI.h.
+
+ * pal/spi/ios/MobileGestaltSPI.h:
+
2019-06-03 Don Olmstead <[email protected]>
[CMake] Add WebKit::_javascript_Core target
Modified: trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h (246117 => 246118)
--- trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -38,6 +38,7 @@
#else
static const CFStringRef kMGQAppleInternalInstallCapability = CFSTR("apple-internal-install");
+static const CFStringRef kMGQMainScreenClass = CFSTR("main-screen-class");
static const CFStringRef kMGQMainScreenPitch = CFSTR("main-screen-pitch");
static const CFStringRef kMGQMainScreenScale = CFSTR("main-screen-scale");
static const CFStringRef kMGQiPadCapability = CFSTR("ipad");
@@ -56,6 +57,12 @@
MGDeviceClassWatch = 6,
} MGDeviceClass;
+typedef enum {
+ MGScreenClassPad2 = 4,
+ MGScreenClassPad3 = 6,
+ MGScreenClassPad4 = 7,
+} MGScreenClass;
+
#endif
WTF_EXTERN_C_BEGIN
Modified: trunk/Source/WebCore/page/Quirks.cpp (246117 => 246118)
--- trunk/Source/WebCore/page/Quirks.cpp 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/page/Quirks.cpp 2019-06-05 18:23:06 UTC (rev 246118)
@@ -228,22 +228,26 @@
return false;
}
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/QuirksAdditions.cpp>
+static bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(const StringView& host)
+{
+#if PLATFORM(IOS_FAMILY)
+ return equalLettersIgnoringASCIICase(host, "docs.google.com");
#else
-
-static bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(const StringView&)
-{
+ UNUSED_PARAM(host);
return false;
+#endif
}
-static bool shouldEmulateUndoRedoInHiddenEditableAreasForHost(const StringView&)
+static bool shouldEmulateUndoRedoInHiddenEditableAreasForHost(const StringView& host)
{
+#if PLATFORM(IOS_FAMILY)
+ return equalLettersIgnoringASCIICase(host, "docs.google.com");
+#else
+ UNUSED_PARAM(host);
return false;
+#endif
}
-#endif
-
bool Quirks::shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const
{
if (m_document->settings().shouldDispatchSyntheticMouseEventsWhenModifyingSelection())
Modified: trunk/Source/WebCore/page/SettingsBase.h (246117 => 246118)
--- trunk/Source/WebCore/page/SettingsBase.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/page/SettingsBase.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -216,10 +216,6 @@
float m_multiLineTextMultiplierCoefficient { defaultMultiLineTextMultiplierCoefficient };
float m_maxTextAutosizingScaleIncrease { defaultMaxTextAutosizingScaleIncrease };
#endif
-
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/SettingsAdditions.h>
-#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (246117 => 246118)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1392,6 +1392,7 @@
NSBundle *bundle = [NSBundle bundleForClass:[WebCoreRenderThemeBundle class]];
StringBuilder scriptBuilder;
+ scriptBuilder.append("window.isIOSFamily = true;");
scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"modern-media-controls-localized-strings" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
scriptBuilder.append([NSString stringWithContentsOfFile:[bundle pathForResource:@"modern-media-controls" ofType:@"js" inDirectory:@"modern-media-controls"] encoding:NSUTF8StringEncoding error:nil]);
m_mediaControlsScript = scriptBuilder.toString();
Modified: trunk/Source/WebKit/ChangeLog (246117 => 246118)
--- trunk/Source/WebKit/ChangeLog 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/ChangeLog 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,56 @@
+2019-06-05 Wenson Hsieh <[email protected]>
+
+ Upstream content mode support into open source from WebKitAdditions
+ https://bugs.webkit.org/show_bug.cgi?id=198484
+ <rdar://problem/51355671>
+
+ Reviewed by Andy Estes.
+
+ Move code for handling WKContentMode into open source. No change in behavior, for internal builds.
+
+ * Shared/API/Cocoa/WebKit.apinotes:
+ * Shared/WebContentMode.h: Renamed from Source/WebKit/Shared/WebCompatibilityMode.h.
+ * Shared/WebPreferences.yaml:
+ * UIProcess/API/APINavigation.h:
+ (API::Navigation::setEffectiveContentMode):
+ (API::Navigation::effectiveContentMode const):
+ (API::Navigation::setEffectiveCompatibilityMode): Deleted.
+ (API::Navigation::effectiveCompatibilityMode const): Deleted.
+ * UIProcess/API/APINavigationClient.h:
+ (API::NavigationClient::shouldBypassContentModeSafeguards const):
+ (API::NavigationClient::shouldBypassCompatibilityModeSafeguards const): Deleted.
+ * UIProcess/API/APIWebsitePolicies.cpp:
+ (API::WebsitePolicies::copy const):
+ * UIProcess/API/APIWebsitePolicies.h:
+ * UIProcess/API/Cocoa/WKNavigation.h:
+ * UIProcess/API/Cocoa/WKNavigation.mm:
+ (-[WKNavigation effectiveContentMode]):
+ * UIProcess/API/Cocoa/WKWebpagePreferences.h:
+ * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+ (WebKit::contentMode):
+ (WebKit::webContentMode):
+ (-[WKWebpagePreferences _allowSiteSpecificQuirksToOverrideCompatibilityMode]):
+ (-[WKWebpagePreferences _setAllowSiteSpecificQuirksToOverrideCompatibilityMode:]):
+ (-[WKWebpagePreferences setPreferredContentMode:]):
+ (-[WKWebpagePreferences preferredContentMode]):
+ * UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h:
+ * UIProcess/Cocoa/NavigationState.h:
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::NavigationClient::shouldBypassContentModeSafeguards const):
+ (WebKit::NavigationState::NavigationClient::shouldBypassCompatibilityModeSafeguards const): Deleted.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+ (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
+ (WebKit::WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::desktopClassBrowsingSupported):
+ (WebKit::webViewSizeIsNarrow):
+ (WebKit::desktopClassBrowsingRecommendedForRequest):
+ (WebKit::desktopClassBrowsingRecommended):
+ (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
+ * WebKit.xcodeproj/project.pbxproj:
+
2019-06-05 Tim Horton <[email protected]>
Remove some unused selection code
Modified: trunk/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes (246117 => 246118)
--- trunk/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes 2019-06-05 18:23:06 UTC (rev 246118)
@@ -200,6 +200,5 @@
Tags:
- Name: WKErrorCode
NSErrorDomain: WKErrorDomain
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebKitAdditions.apinotes>
-#endif
+- Name: WKContentMode
+ SwiftName: WKWebpagePreferences.ContentMode
Deleted: trunk/Source/WebKit/Shared/WebCompatibilityMode.h (246117 => 246118)
--- trunk/Source/WebKit/Shared/WebCompatibilityMode.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/Shared/WebCompatibilityMode.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2019 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 <wtf/Forward.h>
-
-namespace WebKit {
-
-enum class WebCompatibilityMode : uint8_t {
- Recommended,
- Legacy,
- Modern,
-};
-
-}
Copied: trunk/Source/WebKit/Shared/WebContentMode.h (from rev 246117, trunk/Source/WebKit/Shared/WebCompatibilityMode.h) (0 => 246118)
--- trunk/Source/WebKit/Shared/WebContentMode.h (rev 0)
+++ trunk/Source/WebKit/Shared/WebContentMode.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 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 <wtf/Forward.h>
+
+namespace WebKit {
+
+enum class WebContentMode : uint8_t {
+ Recommended,
+ Mobile,
+ Desktop
+};
+
+}
Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (246117 => 246118)
--- trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1070,14 +1070,6 @@
category: debug
condition: PLATFORM(IOS_FAMILY)
-UseModernCompatibilityModeByDefault:
- type: bool
- defaultValue: false
- humanReadableName: "Use Modern Compatibility Mode"
- humanReadableDescription: "Use modern compatibility mode by default"
- webcoreBinding: none
- category: debug
-
SimpleLineLayoutDebugBordersEnabled:
type: bool
defaultValue: false
Modified: trunk/Source/WebKit/UIProcess/API/APINavigation.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/APINavigation.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/APINavigation.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -30,7 +30,7 @@
#include "FrameInfoData.h"
#include "NavigationActionData.h"
#include "WebBackForwardListItem.h"
-#include "WebCompatibilityMode.h"
+#include "WebContentMode.h"
#include <WebCore/AdClickAttribution.h>
#include <WebCore/ProcessIdentifier.h>
#include <WebCore/ResourceRequest.h>
@@ -142,8 +142,8 @@
void setDestinationFrameSecurityOrigin(const WebCore::SecurityOriginData& origin) { m_destinationFrameSecurityOrigin = origin; }
const WebCore::SecurityOriginData& destinationFrameSecurityOrigin() const { return m_destinationFrameSecurityOrigin; }
- void setEffectiveCompatibilityMode(WebKit::WebCompatibilityMode compatibilityMode) { m_effectiveCompatibilityMode = compatibilityMode; }
- WebKit::WebCompatibilityMode effectiveCompatibilityMode() const { return m_effectiveCompatibilityMode; }
+ void setEffectiveContentMode(WebKit::WebContentMode mode) { m_effectiveContentMode = mode; }
+ WebKit::WebContentMode effectiveContentMode() const { return m_effectiveContentMode; }
#if !LOG_DISABLED
const char* loggingString() const;
@@ -173,7 +173,7 @@
WebKit::FrameInfoData m_originatingFrameInfo;
WebCore::SecurityOriginData m_destinationFrameSecurityOrigin;
bool m_userContentExtensionsEnabled { true };
- WebKit::WebCompatibilityMode m_effectiveCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
+ WebKit::WebContentMode m_effectiveContentMode { WebKit::WebContentMode::Recommended };
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/APINavigationClient.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/APINavigationClient.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationClient.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -91,7 +91,7 @@
virtual void renderingProgressDidChange(WebKit::WebPageProxy&, OptionSet<WebCore::LayoutMilestone>) { }
virtual void didReceiveAuthenticationChallenge(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling); }
- virtual bool shouldBypassCompatibilityModeSafeguards() const { return false; }
+ virtual bool shouldBypassContentModeSafeguards() const { return false; }
// FIXME: These function should not be part of this client.
virtual bool processDidTerminate(WebKit::WebPageProxy&, WebKit::ProcessTerminationReason) { return false; }
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp 2019-06-05 18:23:06 UTC (rev 246118)
@@ -57,7 +57,7 @@
policies->setCustomUserAgent(m_customUserAgent);
policies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(m_customJavaScriptUserAgentAsSiteSpecificQuirks);
policies->setCustomNavigatorPlatform(m_customNavigatorPlatform);
- policies->setPreferredCompatibilityMode(m_preferredCompatibilityMode);
+ policies->setPreferredContentMode(m_preferredContentMode);
policies->setMetaViewportPolicy(m_metaViewportPolicy);
policies->setMediaSourcePolicy(m_mediaSourcePolicy);
policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy);
@@ -74,7 +74,7 @@
for (auto& field : m_customHeaderFields)
customHeaderFields.uncheckedAppend(field);
policies->setCustomHeaderFields(WTFMove(customHeaderFields));
- policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode);
+ policies->setAllowSiteSpecificQuirksToOverrideContentMode(m_allowSiteSpecificQuirksToOverrideContentMode);
policies->setApplicationNameForUserAgentWithModernCompatibility(m_applicationNameForUserAgentWithModernCompatibility);
return policies;
}
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -26,7 +26,7 @@
#pragma once
#include "APIObject.h"
-#include "WebCompatibilityMode.h"
+#include "WebContentMode.h"
#include "WebsiteAutoplayPolicy.h"
#include "WebsiteAutoplayQuirk.h"
#include "WebsiteLegacyOverflowScrollingTouchPolicy.h"
@@ -93,8 +93,8 @@
void setCustomNavigatorPlatform(const WTF::String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; }
const WTF::String& customNavigatorPlatform() const { return m_customNavigatorPlatform; }
- WebKit::WebCompatibilityMode preferredCompatibilityMode() const { return m_preferredCompatibilityMode; }
- void setPreferredCompatibilityMode(WebKit::WebCompatibilityMode mode) { m_preferredCompatibilityMode = mode; }
+ WebKit::WebContentMode preferredContentMode() const { return m_preferredContentMode; }
+ void setPreferredContentMode(WebKit::WebContentMode mode) { m_preferredContentMode = mode; }
WebKit::WebsiteMetaViewportPolicy metaViewportPolicy() const { return m_metaViewportPolicy; }
void setMetaViewportPolicy(WebKit::WebsiteMetaViewportPolicy policy) { m_metaViewportPolicy = policy; }
@@ -108,8 +108,8 @@
WebKit::WebsiteLegacyOverflowScrollingTouchPolicy legacyOverflowScrollingTouchPolicy() const { return m_legacyOverflowScrollingTouchPolicy; }
void setLegacyOverflowScrollingTouchPolicy(WebKit::WebsiteLegacyOverflowScrollingTouchPolicy policy) { m_legacyOverflowScrollingTouchPolicy = policy; }
- bool allowSiteSpecificQuirksToOverrideCompatibilityMode() const { return m_allowSiteSpecificQuirksToOverrideCompatibilityMode; }
- void setAllowSiteSpecificQuirksToOverrideCompatibilityMode(bool value) { m_allowSiteSpecificQuirksToOverrideCompatibilityMode = value; }
+ bool allowSiteSpecificQuirksToOverrideContentMode() const { return m_allowSiteSpecificQuirksToOverrideContentMode; }
+ void setAllowSiteSpecificQuirksToOverrideContentMode(bool value) { m_allowSiteSpecificQuirksToOverrideContentMode = value; }
WTF::String applicationNameForUserAgentWithModernCompatibility() const { return m_applicationNameForUserAgentWithModernCompatibility; }
void setApplicationNameForUserAgentWithModernCompatibility(const WTF::String& applicationName) { m_applicationNameForUserAgentWithModernCompatibility = applicationName; }
@@ -130,12 +130,12 @@
WTF::String m_customUserAgent;
WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
WTF::String m_customNavigatorPlatform;
- WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
+ WebKit::WebContentMode m_preferredContentMode { WebKit::WebContentMode::Recommended };
WebKit::WebsiteMetaViewportPolicy m_metaViewportPolicy { WebKit::WebsiteMetaViewportPolicy::Default };
WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default };
WebKit::WebsiteSimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { WebKit::WebsiteSimulatedMouseEventsDispatchPolicy::Default };
WebKit::WebsiteLegacyOverflowScrollingTouchPolicy m_legacyOverflowScrollingTouchPolicy { WebKit::WebsiteLegacyOverflowScrollingTouchPolicy::Default };
- bool m_allowSiteSpecificQuirksToOverrideCompatibilityMode { false };
+ bool m_allowSiteSpecificQuirksToOverrideContentMode { false };
WTF::String m_applicationNameForUserAgentWithModernCompatibility;
};
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -36,8 +36,9 @@
WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
@interface WKNavigation : NSObject
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKNavigationAdditions.h>
-#endif
+/*! The content mode used when loading this webpage.
+ @discussion The value is either WKContentModeMobile or WKContentModeDesktop.
+ */
+@property (nonatomic, readonly) WKContentMode effectiveContentMode WK_API_AVAILABLE(ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -45,10 +45,15 @@
return _navigation->originalRequest().nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody);
}
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKNavigationAdditions.mm>
-#endif
+#if PLATFORM(IOS_FAMILY)
+- (WKContentMode)effectiveContentMode
+{
+ return WebKit::contentMode(_navigation->effectiveContentMode());
+}
+
+#endif // PLATFORM(IOS_FAMILY)
+
#pragma mark WKObject protocol implementation
- (API::Object&)_apiObject
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -27,9 +27,21 @@
#import <Foundation/Foundation.h>
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesAdditionsBefore.h>
-#endif
+/*! @enum WKContentMode
+ @abstract A content mode represents the type of content to load, as well as
+ additional layout and rendering adaptations that are applied as a result of
+ loading the content
+ @constant WKContentModeRecommended The recommended content mode for the current platform
+ @constant WKContentModeMobile Represents content targeting mobile browsers
+ @constant WKContentModeDesktop Represents content targeting desktop browsers
+ @discussion WKContentModeRecommended behaves like WKContentModeMobile on iPhone and iPad mini
+ and WKContentModeDesktop on other iPad models as well as Mac.
+ */
+typedef NS_ENUM(NSInteger, WKContentMode) {
+ WKContentModeRecommended,
+ WKContentModeMobile,
+ WKContentModeDesktop
+} WK_API_AVAILABLE(ios(WK_IOS_TBA));
/*! A WKWebpagePreferences object is a collection of properties that
determine the preferences to use when loading and rendering a page.
@@ -38,8 +50,11 @@
WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
@interface WKWebpagePreferences : NSObject
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.h>
-#endif
+/*! @abstract A WKContentMode indicating the content mode to prefer
+ when loading and rendering a webpage.
+ @discussion The default value is WKContentModeRecommended. The stated
+ preference is ignored on subframe navigation
+ */
+@property (nonatomic) WKContentMode preferredContentMode WK_API_AVAILABLE(ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -29,15 +29,47 @@
#import "APICustomHeaderFields.h"
#import "WKWebpagePreferencesInternal.h"
#import "WKWebsiteDataStoreInternal.h"
-#import "WebCompatibilityMode.h"
+#import "WebContentMode.h"
#import "_WKCustomHeaderFieldsInternal.h"
#import "_WKWebsitePoliciesInternal.h"
#import <wtf/RetainPtr.h>
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesAdditionsBefore.mm>
-#endif
+#if PLATFORM(IOS_FAMILY)
+namespace WebKit {
+
+WKContentMode contentMode(WebKit::WebContentMode contentMode)
+{
+ switch (contentMode) {
+ case WebKit::WebContentMode::Recommended:
+ return WKContentModeRecommended;
+ case WebKit::WebContentMode::Mobile:
+ return WKContentModeMobile;
+ case WebKit::WebContentMode::Desktop:
+ return WKContentModeDesktop;
+ }
+ ASSERT_NOT_REACHED();
+ return WKContentModeRecommended;
+}
+
+WebKit::WebContentMode webContentMode(WKContentMode contentMode)
+{
+ switch (contentMode) {
+ case WKContentModeRecommended:
+ return WebKit::WebContentMode::Recommended;
+ case WKContentModeMobile:
+ return WebKit::WebContentMode::Mobile;
+ case WKContentModeDesktop:
+ return WebKit::WebContentMode::Desktop;
+ }
+ ASSERT_NOT_REACHED();
+ return WebKit::WebContentMode::Recommended;
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS_FAMILY)
+
@implementation WKWebpagePreferences
+ (instancetype)defaultPreferences
@@ -276,12 +308,12 @@
- (BOOL)_allowSiteSpecificQuirksToOverrideCompatibilityMode
{
- return _websitePolicies->allowSiteSpecificQuirksToOverrideCompatibilityMode();
+ return _websitePolicies->allowSiteSpecificQuirksToOverrideContentMode();
}
- (void)_setAllowSiteSpecificQuirksToOverrideCompatibilityMode:(BOOL)value
{
- _websitePolicies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(value);
+ _websitePolicies->setAllowSiteSpecificQuirksToOverrideContentMode(value);
}
- (NSString *)_applicationNameForUserAgentWithModernCompatibility
@@ -299,8 +331,18 @@
return *_websitePolicies;
}
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.mm>
-#endif
+#if PLATFORM(IOS_FAMILY)
+- (void)setPreferredContentMode:(WKContentMode)contentMode
+{
+ _websitePolicies->setPreferredContentMode(WebKit::webContentMode(contentMode));
+}
+
+- (WKContentMode)preferredContentMode
+{
+ return WebKit::contentMode(_websitePolicies->preferredContentMode());
+}
+
+#endif // PLATFORM(IOS_FAMILY)
+
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -36,8 +36,9 @@
using WrapperClass = WKWebpagePreferences;
};
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesInternalAdditions.h>
+#if PLATFORM(IOS_FAMILY)
+WKContentMode contentMode(WebContentMode);
+WebContentMode webContentMode(WKContentMode);
#endif
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -109,7 +109,7 @@
void renderingProgressDidChange(WebPageProxy&, OptionSet<WebCore::LayoutMilestone>) override;
- bool shouldBypassCompatibilityModeSafeguards() const final;
+ bool shouldBypassContentModeSafeguards() const final;
void didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy&) override;
bool processDidTerminate(WebPageProxy&, ProcessTerminationReason) override;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -939,7 +939,7 @@
[static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView renderingProgressDidChange:renderingProgressEvents(layoutMilestones)];
}
-bool NavigationState::NavigationClient::shouldBypassCompatibilityModeSafeguards() const
+bool NavigationState::NavigationClient::shouldBypassContentModeSafeguards() const
{
return m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler;
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-06-05 18:23:06 UTC (rev 246118)
@@ -4653,7 +4653,7 @@
policies = defaultPolicies->copy();
}
if (policies)
- navigation->setEffectiveCompatibilityMode(effectiveCompatibilityModeAfterAdjustingPolicies(*policies, navigation->currentRequest()));
+ navigation->setEffectiveContentMode(effectiveContentModeAfterAdjustingPolicies(*policies, navigation->currentRequest()));
}
receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, policies.get(), WTFMove(sender));
};
@@ -9130,14 +9130,14 @@
}
#endif // ENABLE(SPEECH_SYNTHESIS)
-#if !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK)
+#if !PLATFORM(IOS_FAMILY)
-WebCompatibilityMode WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&)
+WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&)
{
- return WebCompatibilityMode::Recommended;
+ return WebContentMode::Recommended;
}
-#endif // !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK)
+#endif // !PLATFORM(IOS_FAMILY)
void WebPageProxy::addObserver(WebViewDidMoveToWindowObserver& observer)
{
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -296,7 +296,7 @@
enum class ProcessSwapRequestedByClient;
enum class UndoOrRedo : bool;
-enum class WebCompatibilityMode : uint8_t;
+enum class WebContentMode : uint8_t;
#if USE(QUICK_LOOK)
class QuickLookDocumentData;
@@ -1647,7 +1647,7 @@
void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, const UserData&);
void beginSafeBrowsingCheck(const URL&, bool, WebFramePolicyListenerProxy&);
- WebCompatibilityMode effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&);
+ WebContentMode effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&);
void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData&);
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (246117 => 246118)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -63,6 +63,7 @@
#import <WebCore/SharedBuffer.h>
#import <WebCore/UserAgent.h>
#import <WebCore/ValidationBubble.h>
+#import <pal/spi/ios/MobileGestaltSPI.h>
#import <wtf/text/TextStream.h>
#if USE(QUICK_LOOK)
@@ -1261,10 +1262,146 @@
#endif
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WebPageProxyIOSAdditions.mm>
+static bool desktopClassBrowsingSupported()
+{
+ static bool supportsDesktopClassBrowsing = false;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+#if PLATFORM(IOSMAC)
+ supportsDesktopClassBrowsing = true;
+#else
+ supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPad();
#endif
+ });
+ return supportsDesktopClassBrowsing;
+}
+#if !PLATFORM(IOSMAC)
+
+static bool webViewSizeIsNarrow(WebCore::IntSize viewSize)
+{
+ return !viewSize.isEmpty() && viewSize.width() <= 375;
+}
+
+#endif // !PLATFORM(IOSMAC)
+
+static bool desktopClassBrowsingRecommendedForRequest(const WebCore::ResourceRequest& request)
+{
+ // FIXME: This should be additionally gated on site-specific quirks being enabled. However, site-specific quirks are already
+ // disabled by default in WKWebView, so we would need a new preference for controlling site-specific quirks that are on-by-default
+ // in all apps, but may be turned off via SPI (or via Web Inspector). See also: <rdar://problem/50035167>.
+ auto host = request.url().host();
+ if (equalLettersIgnoringASCIICase(host, "tv.kakao.com") || host.endsWithIgnoringASCIICase(".tv.kakao.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "tving.com") || host.endsWithIgnoringASCIICase(".tving.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "live.iqiyi.com") || host.endsWithIgnoringASCIICase(".live.iqiyi.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "video.sina.com.cn") || host.endsWithIgnoringASCIICase(".video.sina.com.cn"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "huya.com") || host.endsWithIgnoringASCIICase(".huya.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "video.tudou.com") || host.endsWithIgnoringASCIICase(".video.tudou.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "cctv.com") || host.endsWithIgnoringASCIICase(".cctv.com"))
+ return false;
+
+ if (equalLettersIgnoringASCIICase(host, "v.china.com.cn"))
+ return false;
+
+ return true;
+}
+
+enum class IgnoreAppCompatibilitySafeguards : bool { No, Yes };
+static bool desktopClassBrowsingRecommended(const WebCore::ResourceRequest& request, WebCore::IntSize viewSize, IgnoreAppCompatibilitySafeguards ignoreSafeguards)
+{
+ if (!desktopClassBrowsingRecommendedForRequest(request))
+ return false;
+
+#if !PLATFORM(IOSMAC)
+ if (webViewSizeIsNarrow(viewSize))
+ return false;
+#endif
+
+ static bool shouldRecommendDesktopClassBrowsing = false;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+#if PLATFORM(IOSMAC)
+ UNUSED_PARAM(ignoreSafeguards);
+ shouldRecommendDesktopClassBrowsing = true;
+#else
+ // While desktop-class browsing is supported on all iPad models, it is not recommended for iPad mini.
+ auto screenClass = MGGetSInt32Answer(kMGQMainScreenClass, MGScreenClassPad2);
+ shouldRecommendDesktopClassBrowsing = screenClass != MGScreenClassPad3 && screenClass != MGScreenClassPad4 && desktopClassBrowsingSupported();
+ if (ignoreSafeguards == IgnoreAppCompatibilitySafeguards::No && !linkedOnOrAfter(WebKit::SDKVersion::FirstWithModernCompabilityModeByDefault)) {
+ // Opt out apps that haven't yet built against the iOS 13 SDK to limit any incompatibilities as a result of enabling desktop-class browsing by default in
+ // WKWebView on appropriately-sized iPad models.
+ shouldRecommendDesktopClassBrowsing = false;
+ }
+#endif
+ });
+ return shouldRecommendDesktopClassBrowsing;
+}
+
+WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies& policies, const WebCore::ResourceRequest& request)
+{
+ if (m_preferences->mediaSourceEnabled()) {
+ // FIXME: This is a compatibility hack to ensure that turning MSE on via the existing preference still enables MSE.
+ policies.setMediaSourcePolicy(WebsiteMediaSourcePolicy::Enable);
+ }
+
+ auto viewSize = this->viewSize();
+ bool useDesktopBrowsingMode;
+ switch (policies.preferredContentMode()) {
+ case WebContentMode::Recommended: {
+ auto ignoreSafeguards = m_navigationClient->shouldBypassContentModeSafeguards() ? IgnoreAppCompatibilitySafeguards::Yes : IgnoreAppCompatibilitySafeguards::No;
+ useDesktopBrowsingMode = desktopClassBrowsingRecommended(request, viewSize, ignoreSafeguards);
+ break;
+ }
+ case WebContentMode::Mobile:
+ useDesktopBrowsingMode = false;
+ break;
+ case WebContentMode::Desktop:
+ useDesktopBrowsingMode = !policies.allowSiteSpecificQuirksToOverrideContentMode() || desktopClassBrowsingRecommendedForRequest(request);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ useDesktopBrowsingMode = false;
+ break;
+ }
+
+ if (!useDesktopBrowsingMode)
+ return WebContentMode::Mobile;
+
+ if (policies.customUserAgent().isEmpty() && customUserAgent().isEmpty()) {
+ auto applicationName = policies.applicationNameForUserAgentWithModernCompatibility();
+ if (applicationName.isEmpty())
+ applicationName = applicationNameForUserAgent();
+ policies.setCustomUserAgent(standardUserAgentWithApplicationName(applicationName, UserAgentType::Desktop));
+ }
+
+ if (policies.customNavigatorPlatform().isEmpty()) {
+ // FIXME: Grab this from WebCore instead of hard-coding it here.
+ policies.setCustomNavigatorPlatform("MacIntel"_s);
+ }
+
+ if (desktopClassBrowsingSupported()) {
+ // Apply some additional desktop-class browsing behaviors on supported devices.
+ policies.setMetaViewportPolicy(WebsiteMetaViewportPolicy::Ignore);
+ policies.setMediaSourcePolicy(WebsiteMediaSourcePolicy::Enable);
+ policies.setSimulatedMouseEventsDispatchPolicy(WebsiteSimulatedMouseEventsDispatchPolicy::Allow);
+ policies.setLegacyOverflowScrollingTouchPolicy(WebsiteLegacyOverflowScrollingTouchPolicy::Disable);
+ }
+
+ return WebContentMode::Desktop;
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (246117 => 246118)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1657,7 +1657,7 @@
F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; };
F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; };
- F430E94422473DFF005FE053 /* WebCompatibilityMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebCompatibilityMode.h */; };
+ F430E94422473DFF005FE053 /* WebContentMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebContentMode.h */; };
F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */; };
F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4632,7 +4632,7 @@
F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionData.h; path = ios/WebAutocorrectionData.h; sourceTree = "<group>"; };
F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebAutocorrectionData.mm; path = ios/WebAutocorrectionData.mm; sourceTree = "<group>"; };
F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMetaViewportPolicy.h; sourceTree = "<group>"; };
- F430E94322473DB8005FE053 /* WebCompatibilityMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCompatibilityMode.h; sourceTree = "<group>"; };
+ F430E94322473DB8005FE053 /* WebContentMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebContentMode.h; sourceTree = "<group>"; };
F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; };
F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebpagePreferences.mm; sourceTree = "<group>"; };
F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesInternal.h; sourceTree = "<group>"; };
@@ -5214,7 +5214,6 @@
518D2CAB12D5153B003BB93B /* WebBackForwardListItem.cpp */,
518D2CAC12D5153B003BB93B /* WebBackForwardListItem.h */,
BCF50726124329AA005955AE /* WebCertificateInfo.h */,
- F430E94322473DB8005FE053 /* WebCompatibilityMode.h */,
7C4ABECE1AA8E9F00088AA37 /* WebCompiledContentRuleList.cpp */,
7C4ABECF1AA8E9F00088AA37 /* WebCompiledContentRuleList.h */,
7C4ABED21AA8FCB80088AA37 /* WebCompiledContentRuleListData.cpp */,
@@ -5224,6 +5223,7 @@
1A1FEC191627B3EF00700F6D /* WebConnection.messages.in */,
BC4A628D147312BE006C681A /* WebConnectionClient.cpp */,
BC4A628E147312BE006C681A /* WebConnectionClient.h */,
+ F430E94322473DB8005FE053 /* WebContentMode.h */,
512935D51288D19400A4B695 /* WebContextMenuItem.cpp */,
512935D61288D19400A4B695 /* WebContextMenuItem.h */,
510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */,
@@ -9616,7 +9616,6 @@
3F87B9BE158940190090FF62 /* WebColorChooser.h in Headers */,
3F87B9C0158940D80090FF62 /* WebColorPicker.h in Headers */,
728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */,
- F430E94422473DFF005FE053 /* WebCompatibilityMode.h in Headers */,
7C4ABED11AA8E9F00088AA37 /* WebCompiledContentRuleList.h in Headers */,
7C4ABED51AA8FCB80088AA37 /* WebCompiledContentRuleListData.h in Headers */,
BC4A6290147312BE006C681A /* WebConnection.h in Headers */,
@@ -9623,6 +9622,7 @@
BC4A6292147312BE006C681A /* WebConnectionClient.h in Headers */,
1A1FEC1D1627B45700700F6D /* WebConnectionMessages.h in Headers */,
BC4A62A814744EC7006C681A /* WebConnectionToWebProcess.h in Headers */,
+ F430E94422473DFF005FE053 /* WebContentMode.h in Headers */,
31A505FA1680025500A930EB /* WebContextClient.h in Headers */,
BC09B8F9147460F7005F5625 /* WebContextConnectionClient.h in Headers */,
BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */,
Modified: trunk/Tools/ChangeLog (246117 => 246118)
--- trunk/Tools/ChangeLog 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/ChangeLog 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,3 +1,43 @@
+2019-06-05 Wenson Hsieh <[email protected]>
+
+ Upstream content mode support into open source from WebKitAdditions
+ https://bugs.webkit.org/show_bug.cgi?id=198484
+ <rdar://problem/51355671>
+
+ Reviewed by Andy Estes.
+
+ Change the "useModernCompatibilityMode" layout test option to instead be "contentMode", with values of either
+ "mobile" or "desktop".
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/ios/PreferredCompatibilityMode.mm: Removed.
+ * TestWebKitAPI/ios/PreferredContentMode.mm: Added.
+ (-[ContentModeNavigationDelegate setDecidePolicyForNavigationActionWithPreferences:]):
+ (-[ContentModeNavigationDelegate decidePolicyForNavigationActionWithPreferences]):
+ (-[ContentModeNavigationDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]):
+ (+[WKWebpagePreferences preferencesWithContentMode:]):
+ (-[WKWebView navigatorUserAgent]):
+ (-[WKWebView navigatorPlatform]):
+ (-[WKWebView loadTestPageNamed:withPolicyDecisionHandler:]):
+ (-[WKWebView loadHTMLString:withPolicyDecisionHandler:]):
+ (-[WKWebView loadTestPageNamed:andExpectEffectiveContentMode:withPolicyDecisionHandler:]):
+ (-[NSString shouldContainStrings:]):
+ (IPhoneUserInterfaceSwizzler::IPhoneUserInterfaceSwizzler):
+ (IPhoneUserInterfaceSwizzler::phoneUserInterfaceIdiom):
+ (TestWebKitAPI::setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate):
+ (TestWebKitAPI::setUpWebViewForPreferredContentModeTesting):
+ (TestWebKitAPI::makeContentModeDecisionHandler):
+ (TestWebKitAPI::TEST):
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::updateTestOptionsFromTestHeader):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestOptions.h:
+ (WTR::TestOptions::hasSameInitializationOptions const):
+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+ (WTR::TestController::platformCreateWebView):
+ (WTR::TestController::configureContentMode):
+ (WTR::TestController::enableModernCompatibilityMode): Deleted.
+
2019-06-01 Antoine Quint <[email protected]>
[Pointer Events] Add support for chorded button interactions
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (246117 => 246118)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-06-05 18:23:06 UTC (rev 246118)
@@ -942,7 +942,7 @@
F4811E5921940BDE00A5E0FD /* WKWebViewEditActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4811E5821940B4400A5E0FD /* WKWebViewEditActions.mm */; };
F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; };
F486B1D01F67952300F34BDD /* DataTransfer-setDragImage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F486B1CF1F6794FF00F34BDD /* DataTransfer-setDragImage.html */; };
- F48D6C10224B377000E3E2FB /* PreferredCompatibilityMode.mm in Sources */ = {isa = PBXBuildFile; fileRef = F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */; };
+ F48D6C10224B377000E3E2FB /* PreferredContentMode.mm in Sources */ = {isa = PBXBuildFile; fileRef = F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */; };
F4A32EC41F05F3850047C544 /* dragstart-change-selection-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */; };
F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */; };
F4A9202F1FEE34E900F59590 /* apple-data-url.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A9202E1FEE34C800F59590 /* apple-data-url.html */; };
@@ -2358,7 +2358,7 @@
F4811E5821940B4400A5E0FD /* WKWebViewEditActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewEditActions.mm; sourceTree = "<group>"; };
F4856CA21E6498A8009D7EE7 /* attachment-element.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "attachment-element.html"; sourceTree = "<group>"; };
F486B1CF1F6794FF00F34BDD /* DataTransfer-setDragImage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "DataTransfer-setDragImage.html"; sourceTree = "<group>"; };
- F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredCompatibilityMode.mm; sourceTree = "<group>"; };
+ F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredContentMode.mm; sourceTree = "<group>"; };
F493247C1F44DF8D006F4336 /* UIKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIKitSPI.h; sourceTree = "<group>"; };
F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-change-selection-offscreen.html"; sourceTree = "<group>"; };
F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-in-iframe.html"; sourceTree = "<group>"; };
@@ -2802,7 +2802,7 @@
F4CDAB3322489FE10057A2D9 /* IPadUserInterfaceSwizzler.h */,
2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */,
2D61EC3021B0B75C00A7D1CB /* PencilKitTestSPI.h */,
- F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */,
+ F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */,
F4517B652054C49500C26721 /* TestWKWebViewController.h */,
F4517B662054C49500C26721 /* TestWKWebViewController.mm */,
F493247C1F44DF8D006F4336 /* UIKitSPI.h */,
@@ -4368,7 +4368,7 @@
83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */,
7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */,
CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */,
- F48D6C10224B377000E3E2FB /* PreferredCompatibilityMode.mm in Sources */,
+ F48D6C10224B377000E3E2FB /* PreferredContentMode.mm in Sources */,
7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */,
7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,
Deleted: trunk/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm (246117 => 246118)
--- trunk/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2019 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"
-
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/PreferredCompatibilityModeAdditions.mm>
-#endif
Added: trunk/Tools/TestWebKitAPI/ios/PreferredContentMode.mm (0 => 246118)
--- trunk/Tools/TestWebKitAPI/ios/PreferredContentMode.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/PreferredContentMode.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -0,0 +1,435 @@
+/*
+ * Copyright (C) 2019 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"
+
+#if PLATFORM(IOS_FAMILY)
+
+#import "IPadUserInterfaceSwizzler.h"
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKWebpagePreferences.h>
+#import <WebKit/WKWebpagePreferencesPrivate.h>
+#import <wtf/BlockPtr.h>
+#import <wtf/text/WTFString.h>
+
+@interface ContentModeNavigationDelegate : TestNavigationDelegate
+@property (nonatomic, copy) void (^decidePolicyForNavigationActionWithPreferences)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *));
+@end
+
+@implementation ContentModeNavigationDelegate {
+ BlockPtr<void(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))> _decidePolicyForNavigationActionWithPreferences;
+}
+
+- (void)setDecidePolicyForNavigationActionWithPreferences:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decidePolicyForNavigationActionWithPreferences
+{
+ _decidePolicyForNavigationActionWithPreferences = decidePolicyForNavigationActionWithPreferences;
+}
+
+- (void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decidePolicyForNavigationActionWithPreferences
+{
+ return _decidePolicyForNavigationActionWithPreferences.get();
+}
+
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler
+{
+ if (_decidePolicyForNavigationActionWithPreferences)
+ _decidePolicyForNavigationActionWithPreferences(navigationAction, preferences, decisionHandler);
+ else
+ decisionHandler(WKNavigationActionPolicyAllow, preferences);
+}
+
+@end
+
+@implementation WKWebpagePreferences (PreferredContentMode)
+
++ (instancetype)preferencesWithContentMode:(WKContentMode)mode
+{
+ auto preferences = adoptNS([[self alloc] init]);
+ [preferences setPreferredContentMode:mode];
+ return preferences.autorelease();
+}
+
+@end
+
+@implementation WKWebView (PreferredContentMode)
+
+- (NSString *)navigatorUserAgent
+{
+ return [self stringByEvaluatingJavaScript:@"navigator.userAgent"];
+}
+
+- (NSString *)navigatorPlatform
+{
+ return [self stringByEvaluatingJavaScript:@"navigator.platform"];
+}
+
+- (void)loadTestPageNamed:(NSString *)pageName withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler
+{
+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate;
+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler;
+ [self loadTestPageNamed:pageName];
+ [navigationDelegate waitForDidFinishNavigation];
+}
+
+- (void)loadHTMLString:(NSString *)htmlString withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler
+{
+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate;
+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler;
+ [self loadHTMLString:htmlString baseURL:nil];
+ [navigationDelegate waitForDidFinishNavigation];
+}
+
+- (void)loadTestPageNamed:(NSString *)pageName andExpectEffectiveContentMode:(WKContentMode)expectedContentMode withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler
+{
+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate;
+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler;
+
+ auto didFailProvisionalNavigation = makeBlockPtr(navigationDelegate.didFailProvisionalNavigation);
+ navigationDelegate.didFailProvisionalNavigation = [expectedContentMode, didFailProvisionalNavigation] (WKWebView *webView, WKNavigation *navigation, NSError *error) {
+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode);
+ if (didFailProvisionalNavigation)
+ didFailProvisionalNavigation(webView, navigation, error);
+ };
+
+ auto didStartProvisionalNavigation = makeBlockPtr(navigationDelegate.didStartProvisionalNavigation);
+ navigationDelegate.didStartProvisionalNavigation = [expectedContentMode, didStartProvisionalNavigation] (WKWebView *webView, WKNavigation *navigation) {
+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode);
+ if (didStartProvisionalNavigation)
+ didStartProvisionalNavigation(webView, navigation);
+ };
+
+ auto didCommitNavigation = makeBlockPtr(navigationDelegate.didCommitNavigation);
+ navigationDelegate.didCommitNavigation = [expectedContentMode, didCommitNavigation] (WKWebView *webView, WKNavigation *navigation) {
+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode);
+ if (didCommitNavigation)
+ didCommitNavigation(webView, navigation);
+ };
+
+ bool finishedNavigation = false;
+ auto didFinishNavigation = makeBlockPtr(navigationDelegate.didFinishNavigation);
+ navigationDelegate.didFinishNavigation = [expectedContentMode, didFinishNavigation, &finishedNavigation] (WKWebView *webView, WKNavigation *navigation) {
+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode);
+ if (didFinishNavigation)
+ didFinishNavigation(webView, navigation);
+ finishedNavigation = true;
+ };
+
+ [self loadTestPageNamed:pageName];
+ TestWebKitAPI::Util::run(&finishedNavigation);
+
+ navigationDelegate.didFailProvisionalNavigation = didFailProvisionalNavigation.get();
+ navigationDelegate.didStartProvisionalNavigation = didStartProvisionalNavigation.get();
+ navigationDelegate.didCommitNavigation = didCommitNavigation.get();
+ navigationDelegate.didFinishNavigation = didFinishNavigation.get();
+}
+
+@end
+
+@implementation NSString (PreferredContentMode)
+
+- (void)shouldContainStrings:(NSString *)firstString, ...
+{
+ va_list args;
+ va_start(args, firstString);
+ for (NSString *string = firstString; string; string = va_arg(args, NSString *)) {
+ BOOL containsString = [self containsString:string];
+ EXPECT_TRUE(containsString);
+ if (!containsString)
+ NSLog(@"Expected '%@' to contain '%@'", self, string);
+ }
+ va_end(args);
+}
+
+@end
+
+class IPhoneUserInterfaceSwizzler {
+public:
+ IPhoneUserInterfaceSwizzler()
+ : m_swizzler(UIDevice.class, @selector(userInterfaceIdiom), reinterpret_cast<IMP>(phoneUserInterfaceIdiom))
+ {
+ }
+
+private:
+ static UIUserInterfaceIdiom phoneUserInterfaceIdiom(id, SEL)
+ {
+ return UIUserInterfaceIdiomPhone;
+ }
+
+ InstanceMethodSwizzler m_swizzler;
+};
+
+namespace TestWebKitAPI {
+
+template <typename ViewClass>
+RetainPtr<ViewClass> setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate(Optional<WKContentMode> defaultContentMode = { }, const String& applicationNameForUserAgent = "TestWebKitAPI", CGSize size = CGSizeMake(1024, 768))
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ if (defaultContentMode)
+ [configuration setDefaultWebpagePreferences:[WKWebpagePreferences preferencesWithContentMode:defaultContentMode.value()]];
+ if (!!applicationNameForUserAgent)
+ [configuration setApplicationNameForUserAgent:applicationNameForUserAgent];
+ auto webView = adoptNS([[ViewClass alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height) configuration:configuration.get()]);
+ EXPECT_TRUE([webView isKindOfClass:WKWebView.class]);
+ return webView;
+}
+
+template <typename ViewClass>
+std::pair<RetainPtr<ViewClass>, RetainPtr<ContentModeNavigationDelegate>> setUpWebViewForPreferredContentModeTesting(Optional<WKContentMode> defaultContentMode = { }, const String& applicationNameForUserAgent = "TestWebKitAPI", CGSize size = CGSizeMake(1024, 768))
+{
+ auto webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<ViewClass>(defaultContentMode, applicationNameForUserAgent, size);
+ auto navigationDelegate = adoptNS([[ContentModeNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:navigationDelegate.get()];
+ return { webView, navigationDelegate };
+}
+
+static auto makeContentModeDecisionHandler(WKContentMode mode)
+{
+ return [mode] (WKNavigationAction *action, WKWebpagePreferences *, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:mode]);
+ };
+};
+
+TEST(PreferredContentMode, SetDefaultWebpagePreferences)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<WKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+ [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode);
+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop);
+ [webView loadHTMLString:@"<pre>Bar</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+
+ [webView loadHTMLString:@"<pre>Baz</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeMobile]);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
+ EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]);
+}
+
+TEST(PreferredContentMode, DesktopModeWithoutNavigationDelegate)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ auto webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<TestWKWebView>(WKContentModeDesktop, "TestWebKitAPI");
+ [webView loadHTMLString:@"<body>Hello world</body>" baseURL:nil];
+
+ __block bool finished = false;
+ [webView performAfterLoading:^{
+ finished = true;
+ }];
+ Util::run(&finished);
+
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+}
+
+TEST(PreferredContentMode, DesktopModeOnPhone)
+{
+ IPhoneUserInterfaceSwizzler iPhoneUserInterface;
+
+ RetainPtr<WKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+ [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode);
+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeDesktop]);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
+
+ webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<WKWebView>(WKContentModeMobile);
+ [webView synchronouslyLoadHTMLString:@"<body>Hello world</body>"];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
+ EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]);
+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
+}
+
+TEST(PreferredContentMode, DesktopModeTopLevelFrameSupercedesSubframe)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<WKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+
+ __block BOOL decidedPolicyForMainFrame = NO;
+ __block BOOL decidedPolicyForSubFrame = NO;
+ [webView loadHTMLString:@"<p>Foo bar</p><iframe src=''></iframe>" withPolicyDecisionHandler:^(WKNavigationAction *action, WKWebpagePreferences *, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ WKContentMode contentMode;
+ if (action.targetFrame.mainFrame) {
+ decidedPolicyForMainFrame = YES;
+ contentMode = WKContentModeDesktop;
+ } else {
+ decidedPolicyForSubFrame = YES;
+ contentMode = WKContentModeMobile;
+ }
+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:contentMode]);
+ }];
+
+ EXPECT_TRUE(decidedPolicyForMainFrame);
+ EXPECT_TRUE(decidedPolicyForSubFrame);
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+}
+
+TEST(PreferredContentMode, DesktopModeUsesNativeViewportByDefault)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<WKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+
+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
+ EXPECT_EQ(1024, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
+
+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)];
+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
+
+ ((ContentModeNavigationDelegate *)[webView navigationDelegate]).decidePolicyForNavigationActionWithPreferences = makeContentModeDecisionHandler(WKContentModeDesktop);
+ [webView goBack];
+ [delegate waitForDidFinishNavigation];
+ EXPECT_EQ(1024, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
+}
+
+TEST(PreferredContentMode, CustomUserAgentOverridesDesktopContentModeUserAgent)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
+
+ NSString *customUserAgent = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
+ [webView setCustomUserAgent:customUserAgent];
+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil];
+ EXPECT_WK_STREQ(customUserAgent, [webView navigatorUserAgent]);
+
+ [webView setCustomUserAgent:@""];
+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:nil];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+}
+
+TEST(PreferredContentMode, DoNotAllowChangingDefaultWebpagePreferencesInDelegateMethod)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
+
+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+ defaultPreferences.preferredContentMode = WKContentModeMobile;
+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
+
+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+}
+
+TEST(PreferredContentMode, EffectiveContentModeOnIPad)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+
+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil];
+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)];
+}
+
+TEST(PreferredContentMode, EffectiveContentModeOnPhone)
+{
+ IPhoneUserInterfaceSwizzler iPhoneUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+
+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil];
+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)];
+}
+
+TEST(PreferredContentMode, RecommendedContentModeAtVariousViewWidths)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>({ }, "TestWebKitAPI", CGSizeZero);
+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"TestWebKitAPI", nil];
+
+ [webView setFrame:CGRectMake(0, 0, 320, 768)];
+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
+
+ [webView setFrame:CGRectMake(0, 0, 1024, 768)];
+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"TestWebKitAPI", nil];
+}
+
+TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
+{
+ IPadUserInterfaceSwizzler iPadUserInterface;
+
+ RetainPtr<TestWKWebView> webView;
+ RetainPtr<ContentModeNavigationDelegate> delegate;
+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+ defaultPreferences._applicationNameForUserAgentWithModernCompatibility = @"DesktopBrowser";
+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+ }];
+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"DesktopBrowser", nil];
+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (246117 => 246118)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2019-06-05 18:23:06 UTC (rev 246118)
@@ -1388,8 +1388,8 @@
testOptions.contentInsetTop = std::stod(value);
else if (key == "ignoreSynchronousMessagingTimeouts")
testOptions.contextOptions.ignoreSynchronousMessagingTimeouts = parseBooleanTestHeaderValue(value);
- else if (key == "shouldUseModernCompatibilityMode")
- testOptions.shouldUseModernCompatibilityMode = parseBooleanTestHeaderValue(value);
+ else if (key == "contentMode")
+ testOptions.contentMode = { value.c_str() };
else if (key == "enableAppNap")
testOptions.enableAppNap = parseBooleanTestHeaderValue(value);
pairStart = pairEnd + 1;
Modified: trunk/Tools/WebKitTestRunner/TestController.h (246117 => 246118)
--- trunk/Tools/WebKitTestRunner/TestController.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -471,7 +471,7 @@
#if PLATFORM(COCOA)
static void finishCreatingPlatformWebView(PlatformWebView*, const TestOptions&);
- void enableModernCompatibilityMode(WKWebViewConfiguration *);
+ void configureContentMode(WKWebViewConfiguration *, const TestOptions&);
#endif
static const char* libraryPathForTesting();
Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (246117 => 246118)
--- trunk/Tools/WebKitTestRunner/TestOptions.h 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h 2019-06-05 18:23:06 UTC (rev 246118)
@@ -91,7 +91,6 @@
bool enableUndoManagerAPI { false };
bool shouldHandleRunOpenPanel { true };
bool shouldPresentPopovers { true };
- bool shouldUseModernCompatibilityMode { false };
bool enableAppNap { false };
double contentInsetTop { 0 };
@@ -102,6 +101,7 @@
std::string additionalSupportedImageTypes;
HashMap<String, bool> experimentalFeatures;
HashMap<String, bool> internalDebugFeatures;
+ String contentMode;
ContextOptions contextOptions;
@@ -145,7 +145,7 @@
|| shouldHandleRunOpenPanel != options.shouldHandleRunOpenPanel
|| shouldPresentPopovers != options.shouldPresentPopovers
|| contentInsetTop != options.contentInsetTop
- || shouldUseModernCompatibilityMode != options.shouldUseModernCompatibilityMode
+ || contentMode != options.contentMode
|| enableAppNap != options.enableAppNap)
return false;
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (246117 => 246118)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2019-06-05 18:02:27 UTC (rev 246117)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2019-06-05 18:23:06 UTC (rev 246118)
@@ -159,8 +159,7 @@
if (options.enableUndoManagerAPI)
[copiedConfiguration _setUndoManagerAPIEnabled:YES];
- if (options.shouldUseModernCompatibilityMode)
- enableModernCompatibilityMode(copiedConfiguration.get());
+ configureContentMode(copiedConfiguration.get(), options);
if (options.applicationManifest.length()) {
auto manifestPath = [NSString stringWithUTF8String:options.applicationManifest.c_str()];
@@ -431,14 +430,30 @@
return m_mainWebView->platformView()._mediaCaptureState != _WKMediaCaptureStateNone;
}
-#if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/TestControllerCocoaAdditions.mm>
-#else
+#if PLATFORM(IOS_FAMILY)
-void TestController::enableModernCompatibilityMode(WKWebViewConfiguration *)
+static WKContentMode contentMode(const TestOptions& options)
{
+ if (options.contentMode == "desktop"_s)
+ return WKContentModeDesktop;
+
+ if (options.contentMode == "mobile"_s)
+ return WKContentModeMobile;
+
+ return WKContentModeRecommended;
}
+#endif // PLATFORM(IOS_FAMILY)
+
+void TestController::configureContentMode(WKWebViewConfiguration *configuration, const TestOptions& options)
+{
+ auto webpagePreferences = adoptNS([[WKWebpagePreferences alloc] init]);
+#if PLATFORM(IOS_FAMILY)
+ [webpagePreferences setPreferredContentMode:contentMode(options)];
+#else
+ UNUSED_PARAM(options);
#endif
+ configuration.defaultWebpagePreferences = webpagePreferences.get();
+}
} // namespace WTR