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):

Canonical link: https://commits.webkit.org/259548.824@safari-7615-branch
  • Loading branch information
pascoej committed Jun 12, 2023
1 parent 18a05c4 commit cff01e3
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 78 deletions.
11 changes: 0 additions & 11 deletions Source/WebCore/page/DOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2617,17 +2617,6 @@ ExceptionOr<RefPtr<Frame>> DOMWindow::createWindow(const String& urlString, cons

ExceptionOr<RefPtr<WindowProxy>> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& 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
53 changes: 0 additions & 53 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,33 +1074,6 @@ 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 @@ -1223,32 +1196,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.
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<Frame>(abstractFrame)) {
auto* frame = downcast<Frame>(abstractFrame);
auto world = ScriptController::createWorld("bbcRadioPlayerWorld"_s, ScriptController::WorldType::User);
frame->addUserScriptAwaitingNotification(world.get(), BBCUserScript);
return;
}
}
});
}
}
#else
UNUSED_PARAM(element);
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +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 @@ -6249,18 +6249,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);

bool shouldOpenAppLinks = originatingFrameInfo->request().url().host() != request.url().host();
auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), originatingFrameInfo.ptr(), nullptr, std::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));
Expand Down

0 comments on commit cff01e3

Please sign in to comment.