Title: [271059] trunk/Source
Revision
271059
Author
[email protected]
Date
2020-12-22 11:45:08 -0800 (Tue, 22 Dec 2020)

Log Message

Cannot see 'Add to my stations' button in BBC World service Radio
https://bugs.webkit.org/show_bug.cgi?id=219949
<rdar://problem/60319532>

Reviewed by Alex Christensen.

This is a temporary quirk to assist a high-traffic website while they
complete the large task of migrating away from site compatibility using
third party cookies. This quirk will be removed when the site is
updated.

Source/WebCore:

No new tests, site-specific quirk.

Create a quirk that will call the Storage Access API on behalf of
BBC for radioplayer.co.uk under bbc.co.uk. When the user clicks to open
the radio player pop-up, storage access is requested. If the user grants
permission, then we open the pop-up to static.radioplayer.co.uk to get
first party status, then immediately redirect to the radio player page.

This changes the language of the site-specific quirk code in
NetworkStorageSession now that we are creating quirks for instances
other than login cases.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::responseReceived):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::open):
Even if WebKit cancels the pop-up click in Element::dispatchMouseEvent,
the popup still appears. So we should check here if the pop-up is trying
to load before storage access has been granted. If so, we should cancel it
and wait for the quirk to re-open the pop-up after prompting the user.
Also adds a null frame check.

* page/Quirks.cpp:
(WebCore::isBBCDomain):
(WebCore::isBBCPopOutPlayerElement):
(WebCore::Quirks::BBCRadioPlayerURLString):
(WebCore::Quirks::staticRadioPlayerURLString):
(WebCore::Quirks::triggerOptionalStorageAccessQuirk const):
* page/Quirks.h:
This is where we check if the pop-up button has been clicked and
prompt for storage access if needed. If the user grants storage
access, we should open a popup to static.radioplayer.co.uk so it
gets marked as first party, then inject script to redirect to the
correct BBC radio player page.

* platform/network/NetworkStorageSession.cpp:
(WebCore::NetworkStorageSession::storageAccessQuirks):
(WebCore::NetworkStorageSession::loginDomainMatchesRequestingDomain):
(WebCore::NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction):
(WebCore::NetworkStorageSession::subDomainInNeedOfStorageAccessForFirstParty):
(WebCore::NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction): Deleted.
(WebCore::NetworkStorageSession::loginDomainForFirstParty): Deleted.
* platform/network/NetworkStorageSession.h:
Change wording now that quirks are not only being used for login
flows.

Source/WebKit:

Create a quirk that will call the Storage Access API on behalf of
BBC for radioplayer.co.uk under bbc.co.uk. When the user clicks to open
the radio player pop-up, storage access is requested. If the user grants
permission, then we open the pop-up to static.radioplayer.co.uk to get
first party status, then immediately redirect to the radio player page.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
(WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
(WebKit::ResourceLoadStatisticsDatabaseStore::cookieAccess):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccessEphemeral):
Change wording now that quirks are not only being used for login
flows.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::createNewPage):
Mark the quirk-initiated pop-up as user-initiated so it doesn't get
blocked.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271058 => 271059)


--- trunk/Source/WebCore/ChangeLog	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/ChangeLog	2020-12-22 19:45:08 UTC (rev 271059)
@@ -1,3 +1,62 @@
+2020-12-22  Kate Cheney  <[email protected]>
+
+        Cannot see 'Add to my stations' button in BBC World service Radio
+        https://bugs.webkit.org/show_bug.cgi?id=219949
+        <rdar://problem/60319532>
+
+        Reviewed by Alex Christensen.
+
+        This is a temporary quirk to assist a high-traffic website while they
+        complete the large task of migrating away from site compatibility using
+        third party cookies. This quirk will be removed when the site is
+        updated.
+
+        No new tests, site-specific quirk.
+
+        Create a quirk that will call the Storage Access API on behalf of
+        BBC for radioplayer.co.uk under bbc.co.uk. When the user clicks to open
+        the radio player pop-up, storage access is requested. If the user grants
+        permission, then we open the pop-up to static.radioplayer.co.uk to get
+        first party status, then immediately redirect to the radio player page.
+
+        This changes the language of the site-specific quirk code in
+        NetworkStorageSession now that we are creating quirks for instances
+        other than login cases.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::responseReceived):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::open):
+        Even if WebKit cancels the pop-up click in Element::dispatchMouseEvent,
+        the popup still appears. So we should check here if the pop-up is trying
+        to load before storage access has been granted. If so, we should cancel it
+        and wait for the quirk to re-open the pop-up after prompting the user.
+        Also adds a null frame check.
+
+        * page/Quirks.cpp:
+        (WebCore::isBBCDomain):
+        (WebCore::isBBCPopOutPlayerElement):
+        (WebCore::Quirks::BBCRadioPlayerURLString):
+        (WebCore::Quirks::staticRadioPlayerURLString):
+        (WebCore::Quirks::triggerOptionalStorageAccessQuirk const):
+        * page/Quirks.h:
+        This is where we check if the pop-up button has been clicked and
+        prompt for storage access if needed. If the user grants storage
+        access, we should open a popup to static.radioplayer.co.uk so it
+        gets marked as first party, then inject script to redirect to the
+        correct BBC radio player page.
+
+        * platform/network/NetworkStorageSession.cpp:
+        (WebCore::NetworkStorageSession::storageAccessQuirks):
+        (WebCore::NetworkStorageSession::loginDomainMatchesRequestingDomain):
+        (WebCore::NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction):
+        (WebCore::NetworkStorageSession::subDomainInNeedOfStorageAccessForFirstParty):
+        (WebCore::NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction): Deleted.
+        (WebCore::NetworkStorageSession::loginDomainForFirstParty): Deleted.
+        * platform/network/NetworkStorageSession.h:
+        Change wording now that quirks are not only being used for login
+        flows.
+
 2020-12-22  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Add fast path for the most common "inline level box is the child of the root inline box" case

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (271058 => 271059)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -805,7 +805,7 @@
         auto& document = *m_frame->document();
         if (Quirks::isMicrosoftTeamsRedirectURL(response.url())) {
             auto firstPartyDomain = RegistrableDomain(response.url());
-            if (auto loginDomains = NetworkStorageSession::loginDomainsForFirstParty(firstPartyDomain)) {
+            if (auto loginDomains = NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(firstPartyDomain)) {
                 if (!Quirks::hasStorageAccessForAllLoginDomains(*loginDomains, firstPartyDomain)) {
                     m_frame->navigationScheduler().scheduleRedirect(document, 0, microsoftTeamsRedirectURL());
                     return;

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (271058 => 271059)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -2501,6 +2501,17 @@
 
 ExceptionOr<RefPtr<WindowProxy>> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlStringToOpen, const AtomString& frameName, const String& windowFeaturesString)
 {
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    if (auto* document = this->document()) {
+        if (document->settings().needsSiteSpecificQuirks() && urlStringToOpen == Quirks::BBCRadioPlayerURLString()) {
+            auto radioPlayerDomain = RegistrableDomain(URL(URL(), Quirks::staticRadioPlayerURLString()));
+            auto BBCDomain = RegistrableDomain(URL(URL(), Quirks::BBCRadioPlayerURLString()));
+            if (!ResourceLoadObserver::shared().hasCrossPageStorageAccess(radioPlayerDomain, BBCDomain))
+                return RefPtr<WindowProxy> { nullptr };
+        }
+    }
+#endif
+
     if (!isCurrentlyDisplayedInFrame())
         return RefPtr<WindowProxy> { nullptr };
 
@@ -2528,6 +2539,9 @@
 #endif
 
     auto* frame = this->frame();
+    if (!frame)
+        return RefPtr<WindowProxy> { nullptr };
+
     if (!firstWindow.allowPopUp()) {
         // Because FrameTree::findFrameForNavigation() returns true for empty strings, we must check for empty frame names.
         // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.

Modified: trunk/Source/WebCore/page/Quirks.cpp (271058 => 271059)


--- trunk/Source/WebCore/page/Quirks.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/page/Quirks.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -1003,6 +1003,33 @@
     return true;
 }
 
+const String& Quirks::BBCRadioPlayerURLString()
+{
+    static NeverDestroyed<String> BBCRadioPlayerURLString = "https://www.bbc.co.uk/sounds/player/bbc_world_service"_s;
+    return BBCRadioPlayerURLString;
+}
+
+const String& Quirks::staticRadioPlayerURLString()
+{
+    static NeverDestroyed<String> staticRadioPlayerURLString = "https://static.radioplayer.co.uk/"_s;
+    return staticRadioPlayerURLString;
+}
+
+static bool isBBCDomain(const RegistrableDomain& domain)
+{
+    static NeverDestroyed<RegistrableDomain> BBCDomain = RegistrableDomain(URL(URL(), Quirks::BBCRadioPlayerURLString()));
+    return domain == BBCDomain;
+}
+
+static bool isBBCPopUpPlayerElement(const Element& element)
+{
+    auto* parentElement = element.parentElement();
+    if (!element.parentElement() || !element.parentElement()->hasClass() || !parentElement->parentElement() || !parentElement->parentElement()->hasClass())
+        return false;
+
+    return element.parentElement()->classNames().contains("p_audioButton_buttonInner") && parentElement->parentElement()->classNames().contains("hidden");
+}
+
 #endif
 
 Quirks::StorageAccessResult Quirks::triggerOptionalStorageAccessQuirk(Element& element, const PlatformMouseEvent& platformEvent, const AtomString& eventType, int detail, Element* relatedTarget) const
@@ -1041,6 +1068,8 @@
     static NeverDestroyed<UserScript> kinjaLoginUserScript { "function triggerLoginForm() { let elements = document.getElementsByClassName('js_header-userbutton'); if (elements && elements[0]) { elements[0].click(); clearInterval(interval); } } let interval = setInterval(triggerLoginForm, 200);", URL(aboutBlankURL()), Vector<String>(), Vector<String>(), UserScriptInjectionTime::DocumentEnd, UserContentInjectedFrames::InjectInTopFrameOnly, WaitForNotificationBeforeInjecting::Yes };
 
     if (eventType == "click") {
+        if (!m_document)
+            return Quirks::StorageAccessResult::ShouldNotCancelEvent;
 
         // Embedded YouTube case.
         if (element.hasClass() && domain == youTubeDomain && !m_document->isTopDocument() && ResourceLoadObserver::shared().hasHadUserInteraction(youTubeDomain)) {
@@ -1083,7 +1112,7 @@
         // FIXME(218779): Remove this quirk once microsoft.com completes their login flow redesign.
         if (isMicrosoftDomain(domain) && isMicrosoftLoginElement(element)) {
             auto firstPartyDomain = NetworkStorageSession::mapToTopDomain(RegistrableDomain::uncheckedCreateFromHost(m_document->topDocument().securityOrigin().host()));
-            if (auto loginDomains = NetworkStorageSession::loginDomainsForFirstParty(firstPartyDomain)) {
+            if (auto loginDomains = NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(firstPartyDomain)) {
                 if (!hasStorageAccessForAllLoginDomains(*loginDomains, firstPartyDomain)) {
                     auto loginDomain = RegistrableDomain(*loginDomains.value().begin().get());
                     DocumentStorageAccess::requestStorageAccessForNonDocumentQuirk(*m_document, WTFMove(loginDomain), [firstPartyDomain, loginDomain, &element, platformEvent, eventType, detail, relatedTarget](StorageAccessWasGranted storageAccessGranted) mutable {
@@ -1104,7 +1133,7 @@
         static NeverDestroyed<RegistrableDomain> playStationDomain = RegistrableDomain::uncheckedCreateFromRegistrableDomainString("playstation.com"_s);
         if (domain == playStationDomain && isPlaystationLoginElement(element)) {
             auto firstPartyDomain = RegistrableDomain(m_document->topDocument().url());
-            if (auto loginDomains = NetworkStorageSession::loginDomainsForFirstParty(firstPartyDomain)) {
+            if (auto loginDomains = NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(firstPartyDomain)) {
                 if (!hasStorageAccessForAllLoginDomains(*loginDomains, firstPartyDomain)) {
                     // Send only one login domain to avoid changing existing Storage Access code, which can only handle a single domain.
                     // We will match Sony login domains up when prompting the user and storing the domains.
@@ -1121,6 +1150,44 @@
             }
             return Quirks::StorageAccessResult::ShouldNotCancelEvent;
         }
+
+        static NeverDestroyed<String> BBCRadioPlayerPopUpWindowFeatureString = "featurestring width=400,height=730"_s;
+        static NeverDestroyed<UserScript> BBCUserScript { "function triggerRedirect() { document.location.href = "" } window.addEventListener('load', function () { triggerRedirect(); })", URL(aboutBlankURL()), Vector<String>(), Vector<String>(), UserScriptInjectionTime::DocumentEnd, UserContentInjectedFrames::InjectInTopFrameOnly, WaitForNotificationBeforeInjecting::Yes };
+
+        // BBC RadioPlayer case.
+        if (isBBCDomain(domain) && isBBCPopUpPlayerElement(element)) {
+            auto firstPartyDomain = RegistrableDomain(m_document->topDocument().url());
+            auto subResourceDomainsInNeedOfStorageAccess = NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(firstPartyDomain);
+            if (!subResourceDomainsInNeedOfStorageAccess)
+                return Quirks::StorageAccessResult::ShouldNotCancelEvent;
+
+            if (hasStorageAccessForAllLoginDomains(*subResourceDomainsInNeedOfStorageAccess, firstPartyDomain))
+                return Quirks::StorageAccessResult::ShouldNotCancelEvent;
+
+            auto subResourceDomain = RegistrableDomain(*subResourceDomainsInNeedOfStorageAccess.value().begin().get());
+            DocumentStorageAccess::requestStorageAccessForNonDocumentQuirk(*m_document, WTFMove(subResourceDomain), [document = m_document, firstPartyDomain, subResourceDomain](StorageAccessWasGranted storageAccessGranted) mutable {
+                if (storageAccessGranted == StorageAccessWasGranted::No)
+                    return;
+
+                ResourceLoadObserver::shared().setDomainsWithCrossPageStorageAccess({{ firstPartyDomain, subResourceDomain }}, [document = WTFMove(document)] {
+                    auto domWindow = document->domWindow();
+                    if (domWindow) {
+                        ExceptionOr<RefPtr<WindowProxy>> proxyOrException = domWindow->open(*domWindow, *domWindow, staticRadioPlayerURLString(), emptyString(), BBCRadioPlayerPopUpWindowFeatureString);
+                        if (proxyOrException.hasException())
+                            return;
+                        auto proxy = proxyOrException.releaseReturnValue();
+                        auto* abstractFrame = proxy->frame();
+                        if (is<Frame>(*abstractFrame)) {
+                            auto& frame = downcast<Frame>(*abstractFrame);
+                            auto world = ScriptController::createWorld("bbcRadioPlayerWorld", ScriptController::WorldType::User);
+                            frame.addUserScriptAwaitingNotification(world.get(), BBCUserScript);
+                            return;
+                        }
+                    }
+                });
+            });
+            return Quirks::StorageAccessResult::ShouldCancelEvent;
+        }
     }
 #else
     UNUSED_PARAM(element);

Modified: trunk/Source/WebCore/page/Quirks.h (271058 => 271059)


--- trunk/Source/WebCore/page/Quirks.h	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/page/Quirks.h	2020-12-22 19:45:08 UTC (rev 271059)
@@ -125,6 +125,8 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     static bool isMicrosoftTeamsRedirectURL(const URL&);
     static bool hasStorageAccessForAllLoginDomains(const HashSet<RegistrableDomain>&, const RegistrableDomain&);
+    static const String& BBCRadioPlayerURLString();
+    WEBCORE_EXPORT static const String& staticRadioPlayerURLString();
 #endif
 
 private:

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp (271058 => 271059)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -390,6 +390,8 @@
         map.add(RegistrableDomain::uncheckedCreateFromRegistrableDomainString("playstation.com"), HashSet {
             RegistrableDomain::uncheckedCreateFromRegistrableDomainString("sonyentertainmentnetwork.com"_s),
             RegistrableDomain::uncheckedCreateFromRegistrableDomainString("sony.com"_s) });
+        map.add(RegistrableDomain::uncheckedCreateFromRegistrableDomainString("bbc.co.uk"), HashSet {
+            RegistrableDomain::uncheckedCreateFromRegistrableDomainString("radioplayer.co.uk"_s) });
         return map;
     }();
     return map.get();
@@ -397,16 +399,16 @@
 
 bool NetworkStorageSession::loginDomainMatchesRequestingDomain(const TopFrameDomain& topFrameDomain, const SubResourceDomain& resourceDomain)
 {
-    auto loginDomains = WebCore::NetworkStorageSession::loginDomainsForFirstParty(topFrameDomain);
+    auto loginDomains = WebCore::NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(topFrameDomain);
     return loginDomains && loginDomains.value().contains(resourceDomain);
 }
 
-bool NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(const SubResourceDomain& resourceDomain, const TopFrameDomain& topFrameDomain)
+bool NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(const SubResourceDomain& resourceDomain, const TopFrameDomain& topFrameDomain)
 {
     return loginDomainMatchesRequestingDomain(topFrameDomain, resourceDomain);
 }
 
-Optional<HashSet<RegistrableDomain>> NetworkStorageSession::loginDomainsForFirstParty(const RegistrableDomain& topFrameDomain)
+Optional<HashSet<RegistrableDomain>> NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(const RegistrableDomain& topFrameDomain)
 {
     auto it = storageAccessQuirks().find(topFrameDomain);
     if (it != storageAccessQuirks().end())

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (271058 => 271059)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2020-12-22 19:45:08 UTC (rev 271059)
@@ -216,8 +216,8 @@
     WEBCORE_EXPORT void setThirdPartyCookieBlockingMode(ThirdPartyCookieBlockingMode);
 
     WEBCORE_EXPORT static HashMap<RegistrableDomain, HashSet<RegistrableDomain>>& storageAccessQuirks();
-    WEBCORE_EXPORT static bool canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(const SubResourceDomain&, const TopFrameDomain&);
-    WEBCORE_EXPORT static Optional<HashSet<RegistrableDomain>> loginDomainsForFirstParty(const RegistrableDomain&);
+    WEBCORE_EXPORT static bool canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(const SubResourceDomain&, const TopFrameDomain&);
+    WEBCORE_EXPORT static Optional<HashSet<RegistrableDomain>> subResourceDomainsInNeedOfStorageAccessForFirstParty(const RegistrableDomain&);
     WEBCORE_EXPORT static bool loginDomainMatchesRequestingDomain(const TopFrameDomain&, const SubResourceDomain&);
     WEBCORE_EXPORT static RegistrableDomain mapToTopDomain(const RegistrableDomain&);
     WEBCORE_EXPORT static Optional<RegistrableDomain> findAdditionalLoginDomain(const TopFrameDomain&, const SubResourceDomain&);

Modified: trunk/Source/WebKit/ChangeLog (271058 => 271059)


--- trunk/Source/WebKit/ChangeLog	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebKit/ChangeLog	2020-12-22 19:45:08 UTC (rev 271059)
@@ -1,3 +1,36 @@
+2020-12-22  Kate Cheney  <[email protected]>
+
+        Cannot see 'Add to my stations' button in BBC World service Radio
+        https://bugs.webkit.org/show_bug.cgi?id=219949
+        <rdar://problem/60319532>
+
+        Reviewed by Alex Christensen.
+
+        This is a temporary quirk to assist a high-traffic website while they
+        complete the large task of migrating away from site compatibility using
+        third party cookies. This quirk will be removed when the site is
+        updated.
+
+        Create a quirk that will call the Storage Access API on behalf of
+        BBC for radioplayer.co.uk under bbc.co.uk. When the user clicks to open
+        the radio player pop-up, storage access is requested. If the user grants
+        permission, then we open the pop-up to static.radioplayer.co.uk to get
+        first party status, then immediately redirect to the radio player page.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
+        (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
+        (WebKit::ResourceLoadStatisticsDatabaseStore::cookieAccess):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessEphemeral):
+        Change wording now that quirks are not only being used for login
+        flows.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::createNewPage):
+        Mark the quirk-initiated pop-up as user-initiated so it doesn't get
+        blocked.
+
 2020-12-22  Ryan Haddad  <[email protected]>
 
         Unreviewed, fix the build with recent SDKs.

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (271058 => 271059)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -1395,7 +1395,7 @@
         }
         ASSERT(subFrameStatus.first == AddedRecord::No);
 #if ASSERT_ENABLED
-        if (!NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain))
+        if (!NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain))
             ASSERT(hasHadUserInteraction(subFrameDomain, OperatingDatesWindow::Long));
 #endif
         insertDomainRelationshipList(storageAccessUnderTopFrameDomainsQuery, HashSet<RegistrableDomain>({ topFrameDomain }), *subFrameStatus.second);
@@ -1422,7 +1422,7 @@
         }
         ASSERT(subFrameStatus.first == AddedRecord::No);
 #if ASSERT_ENABLED
-        if (!NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain))
+        if (!NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain))
             ASSERT(hasHadUserInteraction(subFrameDomain, OperatingDatesWindow::Long));
 #endif
         ASSERT(hasUserGrantedStorageAccessThroughPrompt(*subFrameStatus.second, topFrameDomain) == StorageAccessPromptWasShown::Yes);
@@ -2112,7 +2112,7 @@
     if (!areAllThirdPartyCookiesBlockedUnder(topFrameDomain) && !isPrevalent)
         return CookieAccess::BasedOnCookiePolicy;
 
-    if (!NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(subresourceDomain, topFrameDomain) && !hadUserInteraction)
+    if (!NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(subresourceDomain, topFrameDomain) && !hadUserInteraction)
         return CookieAccess::CannotRequest;
 
     return CookieAccess::OnlyIfGranted;

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (271058 => 271059)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -470,7 +470,7 @@
 {
     ASSERT(isEphemeral());
 
-    if (!m_networkSession || (!m_domainsWithEphemeralUserInteraction.contains(subFrameDomain) && !NetworkStorageSession::canRequestStorageAccessForLoginPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain)))
+    if (!m_networkSession || (!m_domainsWithEphemeralUserInteraction.contains(subFrameDomain) && !NetworkStorageSession::canRequestStorageAccessForLoginOrCompatibilityPurposesWithoutPriorUserInteraction(subFrameDomain, topFrameDomain)))
         return completionHandler({ StorageAccessWasGranted::No, StorageAccessPromptWasShown::No, scope, topFrameDomain, subFrameDomain });
 
     CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = makeRef(*this), subFrameDomain, topFrameDomain, frameID, webPageID, scope, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (271058 => 271059)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-12-22 19:02:43 UTC (rev 271058)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-12-22 19:45:08 UTC (rev 271059)
@@ -5572,7 +5572,17 @@
 #endif
     };
 
-    auto userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
+    RefPtr<API::UserInitiatedAction> userInitiatedActivity;
+    
+    // WebKit cancels the original gesture to open the BBC radio player so
+    // we can call the Storage Access API first. When we re-initiate the open,
+    // we should make sure the client knows that this was user initiated so it
+    // does not block the popup.
+    if (request.url().string() == Quirks::staticRadioPlayerURLString())
+        userInitiatedActivity = API::UserInitiatedAction::create();
+    else
+        userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
+
     bool shouldOpenAppLinks = originatingFrameInfo->request().url().host() != request.url().host();
     auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), originatingFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to