Skip to content

Commit

Permalink
[Quirk] iPadOS: Unable to enter PIN in account linking flow on shopee.sg
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273864
rdar://127031587

Reviewed by Tim Horton.

Add a quirk to use an *iPhone* user agent on `shopee.sg/payment/account-linking/landing`. Currently,
sending either macOS or (non-desktop-class) iPad user agents cause Shopee to load content that
doesn't work unless the user has a hardware keyboard; namely, the PIN input elements don't actually
use focusable elements at all, and instead rely on receiving hardware keyboard events.

Work around this for now with a site-specific quirk to load an iPhone user agent in this specific
landing page; while the layout doesn't fit very well for an iPad screen, it's at least functional.

* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::needsIPadMiniUserAgent):
(WebCore::Quirks::needsIPhoneUserAgent):
(WebCore::Quirks::needsIpadMiniUserAgent): Deleted.
* Source/WebCore/page/Quirks.h:
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::desktopClassBrowsingRecommendedForRequest):
(WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):

Canonical link: https://commits.webkit.org/278493@main
  • Loading branch information
whsieh committed May 8, 2024
1 parent d110152 commit 98754fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ bool Quirks::shouldDisableNavigatorStandaloneQuirk() const
// FIXME: find the reference radars and/or bugs.webkit.org issues on why these were added in the first place.
// FIXME: There is no check currently on needsQuirks(), this needs to be fixed so it makes it easier
// to deactivate them for testing.
bool Quirks::needsIpadMiniUserAgent(const URL& url)
bool Quirks::needsIPadMiniUserAgent(const URL& url)
{
auto host = url.host();

Expand Down Expand Up @@ -1787,6 +1787,16 @@ bool Quirks::needsIpadMiniUserAgent(const URL& url)
return false;
}

bool Quirks::needsIPhoneUserAgent(const URL& url)
{
#if PLATFORM(IOS_FAMILY)
if (url.host() == "shopee.sg"_s && url.path() == "/payment/account-linking/landing"_s)
return true;
#else
UNUSED_PARAM(url);
#endif
return false;
}

bool Quirks::shouldIgnorePlaysInlineRequirementQuirk() const
{
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class Quirks {

WEBCORE_EXPORT static void updateStorageAccessUserAgentStringQuirks(HashMap<RegistrableDomain, String>&&);
WEBCORE_EXPORT String storageAccessUserAgentStringQuirkForDomain(const URL&);
WEBCORE_EXPORT static bool needsIpadMiniUserAgent(const URL&);
WEBCORE_EXPORT static bool needsIPadMiniUserAgent(const URL&);
WEBCORE_EXPORT static bool needsIPhoneUserAgent(const URL&);

bool needsGMailOverflowScrollQuirk() const;
bool needsYouTubeOverflowScrollQuirk() const;
Expand Down
11 changes: 10 additions & 1 deletion Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,10 @@ static RecommendDesktopClassBrowsingForRequest desktopClassBrowsingRecommendedFo
// FIXME: This should be additionally gated on site-specific quirks being enabled.
// See also: <rdar://problem/50035167>.
// The list of domain names is currently available in Source/WebCore/page/Quirks.cpp
if (Quirks::needsIpadMiniUserAgent(request.url()))
if (Quirks::needsIPadMiniUserAgent(request.url()))
return RecommendDesktopClassBrowsingForRequest::No;

if (Quirks::needsIPhoneUserAgent(request.url()))
return RecommendDesktopClassBrowsingForRequest::No;

return RecommendDesktopClassBrowsingForRequest::Auto;
Expand Down Expand Up @@ -1430,6 +1433,12 @@ static RecommendDesktopClassBrowsingForRequest desktopClassBrowsingRecommendedFo
policies.setMediaSourcePolicy(WebsiteMediaSourcePolicy::Enable);
}

if (Quirks::needsIPhoneUserAgent(request.url())) {
policies.setCustomUserAgent(makeStringByReplacingAll(standardUserAgentWithApplicationName(m_applicationNameForUserAgent), "iPad"_s, "iPhone"_s));
policies.setCustomNavigatorPlatform("iPhone"_s);
return WebContentMode::Mobile;
}

bool useDesktopBrowsingMode = useDesktopClassBrowsing(policies, request);

m_preferFasterClickOverDoubleTap = false;
Expand Down

0 comments on commit 98754fd

Please sign in to comment.