Skip to content

Commit

Permalink
https://bugs.webkit.org/show_bug.cgi?id=257352
Browse files Browse the repository at this point in the history
rdar://106974958

Reviewed by John Wilander and Brent Fulgham.

This quirk is no longer nessesary to get favorites and recents to show up
in the radio player, which is why it was added in the first place. Therefore
it can be removed.

* Source/WebCore/page/DOMWindow.cpp:
(WebCore::DOMWindow::open):
* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::triggerOptionalStorageAccessQuirk const):
(WebCore::Quirks::BBCRadioPlayerURLString): Deleted.
(WebCore::Quirks::staticRadioPlayerURLString): Deleted.
(WebCore::isBBCDomain): Deleted.
(WebCore::isBBCPopUpPlayerElement): Deleted.
* Source/WebCore/page/Quirks.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::createNewPage):

Originally-landed-as: 259548.824@safari-7615-branch (cff01e3). rdar://113285349
Canonical link: https://commits.webkit.org/266597@main
  • Loading branch information
pascoej authored and JonWBedard committed Aug 4, 2023
1 parent b08d868 commit 9b58b4b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 71 deletions.
11 changes: 0 additions & 11 deletions Source/WebCore/page/LocalDOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2657,17 +2657,6 @@ ExceptionOr<RefPtr<LocalFrame>> LocalDOMWindow::createWindow(const String& urlSt

ExceptionOr<RefPtr<WindowProxy>> LocalDOMWindow::open(LocalDOMWindow& activeWindow, LocalDOMWindow& firstWindow, const String& urlStringToOpen, const AtomString& frameName, const String& windowFeaturesString)
{
#if ENABLE(TRACKING_PREVENTION)
if (RefPtr document = this->document()) {
if (document->settings().needsSiteSpecificQuirks() && urlStringToOpen == Quirks::BBCRadioPlayerURLString()) {
auto radioPlayerDomain = RegistrableDomain(URL { Quirks::staticRadioPlayerURLString() });
auto BBCDomain = RegistrableDomain(URL { Quirks::BBCRadioPlayerURLString() });
if (!ResourceLoadObserver::shared().hasCrossPageStorageAccess(radioPlayerDomain, BBCDomain))
return RefPtr<WindowProxy> { nullptr };
}
}
#endif

if (!isCurrentlyDisplayedInFrame())
return RefPtr<WindowProxy> { nullptr };

Expand Down
47 changes: 0 additions & 47 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,33 +1142,12 @@ bool Quirks::hasStorageAccessForAllLoginDomains(const HashSet<RegistrableDomain>
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 { 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"_s) && parentElement->parentElement()->classNames().contains("hidden"_s);
}

Quirks::StorageAccessResult Quirks::requestStorageAccessAndHandleClick(CompletionHandler<void(ShouldDispatchClick)>&& completionHandler) const
{
auto firstPartyDomain = RegistrableDomain(m_document->topDocument().url());
Expand Down Expand Up @@ -1292,32 +1271,6 @@ Quirks::StorageAccessResult Quirks::triggerOptionalStorageAccessQuirk(Element& e
protectedElement->dispatchMouseEvent(platformEvent, eventType, detail, relatedTarget, IsSyntheticClick::Yes);
});
}

static NeverDestroyed<String> BBCRadioPlayerPopUpWindowFeatureString = "featurestring width=400,height=730"_s;
static NeverDestroyed<UserScript> BBCUserScript { "function triggerRedirect() { document.location.href = \"https://www.bbc.co.uk/sounds/player/bbc_world_service\"; } window.addEventListener('load', function () { triggerRedirect(); })"_s, URL(aboutBlankURL()), Vector<String>(), Vector<String>(), UserScriptInjectionTime::DocumentEnd, UserContentInjectedFrames::InjectInTopFrameOnly, WaitForNotificationBeforeInjecting::Yes };

// BBC RadioPlayer case rdar://60319532
if (isBBCDomain(domain) && isBBCPopUpPlayerElement(element)) {
return requestStorageAccessAndHandleClick([document = m_document] (ShouldDispatchClick shouldDispatchClick) mutable {
if (!document || shouldDispatchClick == ShouldDispatchClick::No)
return;

auto domWindow = document->domWindow();
if (domWindow) {
ExceptionOr<RefPtr<WindowProxy>> proxyOrException = domWindow->open(*domWindow, *domWindow, staticRadioPlayerURLString(), emptyAtom(), BBCRadioPlayerPopUpWindowFeatureString);
if (proxyOrException.hasException())
return;
auto proxy = proxyOrException.releaseReturnValue();
auto* abstractFrame = proxy->frame();
if (is<LocalFrame>(abstractFrame)) {
auto* frame = downcast<LocalFrame>(abstractFrame);
auto world = ScriptController::createWorld("bbcRadioPlayerWorld"_s, ScriptController::WorldType::User);
frame->addUserScriptAwaitingNotification(world.get(), BBCUserScript);
return;
}
}
});
}
}
#else
UNUSED_PARAM(element);
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class Quirks {
#if ENABLE(TRACKING_PREVENTION)
static bool isMicrosoftTeamsRedirectURL(const URL&);
static bool hasStorageAccessForAllLoginDomains(const HashSet<RegistrableDomain>&, const RegistrableDomain&);
static const String& BBCRadioPlayerURLString();
WEBCORE_EXPORT static const String& staticRadioPlayerURLString();
StorageAccessResult requestStorageAccessAndHandleClick(CompletionHandler<void(ShouldDispatchClick)>&&) const;
#endif
Expand Down
13 changes: 1 addition & 12 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6823,18 +6823,7 @@ void WebPageProxy::createNewPage(FrameInfoData&& originatingFrameInfoData, WebPa
#endif
};

RefPtr<API::UserInitiatedAction> userInitiatedActivity;

#if ENABLE(TRACKING_PREVENTION)
// 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
#endif
userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
RefPtr<API::UserInitiatedAction> userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);

if (userInitiatedActivity && m_preferences->verifyWindowOpenUserGestureFromUIProcess() && request.url().string() != Quirks::staticRadioPlayerURLString())
m_process->consumeIfNotVerifiablyFromUIProcess(*userInitiatedActivity, navigationActionData.userGestureAuthorizationToken);
Expand Down

0 comments on commit 9b58b4b

Please sign in to comment.