Title: [288546] trunk/Source/WebCore
- Revision
- 288546
- Author
- you...@apple.com
- Date
- 2022-01-25 06:09:03 -0800 (Tue, 25 Jan 2022)
Log Message
Add a WebShare policy quirk for Twitter
https://bugs.webkit.org/show_bug.cgi?id=235502
<rdar://87944391>
Reviewed by Chris Dumez.
Disable WebShare policy in case of twitter documents as this is not yet web compatible.
Manually tested.
* page/Navigator.cpp:
(WebCore::validateWebSharePolicy):
(WebCore::Navigator::canShare):
(WebCore::Navigator::share):
* page/Quirks.cpp:
(WebCore::isTwitterDocument):
(WebCore::Quirks::requiresUserGestureToLoadInPictureInPicture const):
(WebCore::Quirks::shouldDisableWebSharePolicy const):
* page/Quirks.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (288545 => 288546)
--- trunk/Source/WebCore/ChangeLog 2022-01-25 12:00:39 UTC (rev 288545)
+++ trunk/Source/WebCore/ChangeLog 2022-01-25 14:09:03 UTC (rev 288546)
@@ -1,3 +1,25 @@
+2022-01-25 Youenn Fablet <you...@apple.com>
+
+ Add a WebShare policy quirk for Twitter
+ https://bugs.webkit.org/show_bug.cgi?id=235502
+ <rdar://87944391>
+
+ Reviewed by Chris Dumez.
+
+ Disable WebShare policy in case of twitter documents as this is not yet web compatible.
+
+ Manually tested.
+
+ * page/Navigator.cpp:
+ (WebCore::validateWebSharePolicy):
+ (WebCore::Navigator::canShare):
+ (WebCore::Navigator::share):
+ * page/Quirks.cpp:
+ (WebCore::isTwitterDocument):
+ (WebCore::Quirks::requiresUserGestureToLoadInPictureInPicture const):
+ (WebCore::Quirks::shouldDisableWebSharePolicy const):
+ * page/Quirks.h:
+
2022-01-25 Ziran Sun <z...@igalia.com>
[css-grid] Fix grid shorthand expansion of initial values
Modified: trunk/Source/WebCore/page/Navigator.cpp (288545 => 288546)
--- trunk/Source/WebCore/page/Navigator.cpp 2022-01-25 12:00:39 UTC (rev 288545)
+++ trunk/Source/WebCore/page/Navigator.cpp 2022-01-25 14:09:03 UTC (rev 288546)
@@ -126,14 +126,16 @@
return url;
}
+static bool validateWebSharePolicy(Document& document)
+{
+ return isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::WebShare, document, LogFeaturePolicyFailure::Yes) || document.quirks().shouldDisableWebSharePolicy();
+}
+
bool Navigator::canShare(Document& document, const ShareData& data)
{
- if (!document.isFullyActive())
+ if (!document.isFullyActive() || !validateWebSharePolicy(document))
return false;
- if (!isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::WebShare, document, LogFeaturePolicyFailure::Yes))
- return false;
-
bool hasShareableTitleOrText = !data.title.isNull() || !data.text.isNull();
bool hasShareableURL = !!shareableURLForShareData(document, data);
#if ENABLE(FILE_SHARE)
@@ -152,7 +154,7 @@
return;
}
- if (!isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::WebShare, document, LogFeaturePolicyFailure::Yes)) {
+ if (!validateWebSharePolicy(document)) {
promise->reject(NotAllowedError, "Third-party iframes are not allowed to call share() unless explicitly allowed via Feature-Policy (web-share)"_s);
return;
}
Modified: trunk/Source/WebCore/page/Quirks.cpp (288545 => 288546)
--- trunk/Source/WebCore/page/Quirks.cpp 2022-01-25 12:00:39 UTC (rev 288545)
+++ trunk/Source/WebCore/page/Quirks.cpp 2022-01-25 14:09:03 UTC (rev 288546)
@@ -85,6 +85,11 @@
}
#endif
+static bool isTwitterDocument(Document& document)
+{
+ return RegistrableDomain(document.url()).string() == "twitter.com";
+}
+
Quirks::Quirks(Document& document)
: m_document(document)
{
@@ -1359,10 +1364,8 @@
if (!needsQuirks())
return false;
- if (!m_requiresUserGestureToLoadInPictureInPicture) {
- auto domain = RegistrableDomain(m_document->topDocument().url());
- m_requiresUserGestureToLoadInPictureInPicture = domain.string() == "twitter.com"_s;
- }
+ if (!m_requiresUserGestureToLoadInPictureInPicture)
+ m_requiresUserGestureToLoadInPictureInPicture = isTwitterDocument(m_document->topDocument());
return *m_requiresUserGestureToLoadInPictureInPicture;
#else
@@ -1433,4 +1436,15 @@
#endif // ENABLE(IMAGE_ANALYSIS)
+bool Quirks::shouldDisableWebSharePolicy() const
+{
+ if (!needsQuirks())
+ return false;
+
+ if (!m_shouldDisableWebSharePolicy)
+ m_shouldDisableWebSharePolicy = isTwitterDocument(*m_document);
+
+ return *m_shouldDisableWebSharePolicy;
}
+
+}
Modified: trunk/Source/WebCore/page/Quirks.h (288545 => 288546)
--- trunk/Source/WebCore/page/Quirks.h 2022-01-25 12:00:39 UTC (rev 288545)
+++ trunk/Source/WebCore/page/Quirks.h 2022-01-25 14:09:03 UTC (rev 288546)
@@ -153,6 +153,8 @@
bool needsToForceUserSelectAndUserDragWhenInstallingImageOverlay() const;
#endif
+ bool shouldDisableWebSharePolicy() const;
+
private:
bool needsQuirks() const;
@@ -197,6 +199,7 @@
#endif
mutable std::optional<bool> m_blocksReturnToFullscreenFromPictureInPictureQuirk;
mutable std::optional<bool> m_shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk;
+ mutable std::optional<bool> m_shouldDisableWebSharePolicy;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes