- Revision
- 266158
- Author
- [email protected]
- Date
- 2020-08-25 22:09:19 -0700 (Tue, 25 Aug 2020)
Log Message
Web Share API Level 2 functions even when its experimental feature flag is disabled
https://bugs.webkit.org/show_bug.cgi?id=215831
<rdar://problem/67760687>
Reviewed by Darin Adler.
Source/WebCore:
Tests: fast/web-share/canShare-with-files-feature-disabled.html
fast/web-share/share-with-files-feature-disabled.html
We had a feature flag for Web Share API Level 2, but it isn't actually
consulted anywhere in the implementation.
* page/Navigator.cpp:
(WebCore::Navigator::canShare):
Rewrite canShare to be a bit more readable, and also to consult the Level 2 feature flag.
(WebCore::Navigator::share):
Since canShare (per the spec) will return true if we have files and other content,
even if files are not shareable, check the feature flag again before loading the files.
Source/WebKit:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::showShareSheet):
If the Web Content process sends us files, but the Level 2 feature flag is disabled,
something fishy is happening, so fire a MESSAGE_CHECK.
LayoutTests:
* fast/web-share/canShare-with-files-feature-disabled-expected.txt: Added.
* fast/web-share/canShare-with-files-feature-disabled.html: Added.
* fast/web-share/share-with-files-feature-disabled-expected.txt: Added.
* fast/web-share/share-with-files-feature-disabled.html: Added.
Add some tests that ensure that disabling the feature actually works.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (266157 => 266158)
--- trunk/LayoutTests/ChangeLog 2020-08-26 02:25:04 UTC (rev 266157)
+++ trunk/LayoutTests/ChangeLog 2020-08-26 05:09:19 UTC (rev 266158)
@@ -1,3 +1,17 @@
+2020-08-25 Tim Horton <[email protected]>
+
+ Web Share API Level 2 functions even when its experimental feature flag is disabled
+ https://bugs.webkit.org/show_bug.cgi?id=215831
+ <rdar://problem/67760687>
+
+ Reviewed by Darin Adler.
+
+ * fast/web-share/canShare-with-files-feature-disabled-expected.txt: Added.
+ * fast/web-share/canShare-with-files-feature-disabled.html: Added.
+ * fast/web-share/share-with-files-feature-disabled-expected.txt: Added.
+ * fast/web-share/share-with-files-feature-disabled.html: Added.
+ Add some tests that ensure that disabling the feature actually works.
+
2020-08-25 Zalan Bujtas <[email protected]>
Facebook post with lots of comments has cut off scrollbar, and can't scroll fully to the bottom (sticky)
Added: trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt (0 => 266158)
--- trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt 2020-08-26 05:09:19 UTC (rev 266158)
@@ -0,0 +1 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled.
Added: trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html (0 => 266158)
--- trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html (rev 0)
+++ trunk/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html 2020-08-26 05:09:19 UTC (rev 266158)
@@ -0,0 +1,16 @@
+<!-- webkit-test-runner [ experimental:WebShareFileAPIEnabled=false ] -->
+<html>
+<body>
+<pre id="output"></pre>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ const textFile = new File(['This is a text file'], 'TextFile.txt', { type: 'text/plain' });
+ if (navigator.canShare({ files: [ textFile ] }))
+ output.innerText = "FAIL: Allowed to share file with Web Share Level 2 disabled.";
+ else
+ output.innerText = "PASS: Not allowed to share file with Web Share Level 2 disabled.";
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt (0 => 266158)
--- trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt 2020-08-26 05:09:19 UTC (rev 266158)
@@ -0,0 +1,2 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled: TypeError: Type error
+
Added: trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled.html (0 => 266158)
--- trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled.html (rev 0)
+++ trunk/LayoutTests/fast/web-share/share-with-files-feature-disabled.html 2020-08-26 05:09:19 UTC (rev 266158)
@@ -0,0 +1,43 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true experimental:WebShareFileAPIEnabled=false ] -->
+<html>
+<head>
+<meta name="viewport" content="initial-scale=5, width=device-width">
+<script src=""
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function runTest()
+ {
+ document.getElementById("target").addEventListener("click", () => {
+ const textFile = new File(['This is a text file'], 'TextFile.txt', { type: 'text/plain' });
+ navigator.share({ files: [ textFile ] })
+ .then(() => {
+ output.innerText = "FAIL: Allowed to share file with Web Share Level 2 disabled.";
+ testRunner.notifyDone();
+ })
+ .catch((error) => {
+ output.innerText = "PASS: Not allowed to share file with Web Share Level 2 disabled: " + error;
+ testRunner.notifyDone();
+ });
+ });
+
+ UIHelper.activateAt(50, 50);
+ }
+</script>
+<style>
+ #target {
+ height: 100px;
+ width: 100px;
+ background-color: silver;
+ }
+</style>
+</head>
+<body _onload_="runTest()">
+<pre id="output"></pre>
+<button id="target">
+</button>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (266157 => 266158)
--- trunk/Source/WebCore/ChangeLog 2020-08-26 02:25:04 UTC (rev 266157)
+++ trunk/Source/WebCore/ChangeLog 2020-08-26 05:09:19 UTC (rev 266158)
@@ -1,3 +1,25 @@
+2020-08-25 Tim Horton <[email protected]>
+
+ Web Share API Level 2 functions even when its experimental feature flag is disabled
+ https://bugs.webkit.org/show_bug.cgi?id=215831
+ <rdar://problem/67760687>
+
+ Reviewed by Darin Adler.
+
+ Tests: fast/web-share/canShare-with-files-feature-disabled.html
+ fast/web-share/share-with-files-feature-disabled.html
+
+ We had a feature flag for Web Share API Level 2, but it isn't actually
+ consulted anywhere in the implementation.
+
+ * page/Navigator.cpp:
+ (WebCore::Navigator::canShare):
+ Rewrite canShare to be a bit more readable, and also to consult the Level 2 feature flag.
+
+ (WebCore::Navigator::share):
+ Since canShare (per the spec) will return true if we have files and other content,
+ even if files are not shareable, check the feature flag again before loading the files.
+
2020-08-25 Ryosuke Niwa <[email protected]>
HashMap<Ref<T>>::take should return RefPtr<T>
Modified: trunk/Source/WebCore/page/Navigator.cpp (266157 => 266158)
--- trunk/Source/WebCore/page/Navigator.cpp 2020-08-26 02:25:04 UTC (rev 266157)
+++ trunk/Source/WebCore/page/Navigator.cpp 2020-08-26 05:09:19 UTC (rev 266158)
@@ -129,21 +129,16 @@
auto* frame = this->frame();
if (!frame || !frame->page())
return false;
- if (data.title.isNull() && data.url.isNull() && data.text.isNull()) {
- if (!data.files.isEmpty()) {
+
+ bool hasShareableTitleOrText = !data.title.isNull() || !data.text.isNull();
+ bool hasShareableURL = !!shareableURLForShareData(context, data);
#if ENABLE(FILE_SHARE)
- return true;
+ bool hasShareableFiles = RuntimeEnabledFeatures::sharedFeatures().webShareFileAPIEnabled() && !data.files.isEmpty();
#else
- return false;
+ bool hasShareableFiles = false;
#endif
- }
- return false;
- }
- if (!data.url.isNull() && !shareableURLForShareData(context, data))
- return false;
-
- return true;
+ return hasShareableTitleOrText || hasShareableURL || hasShareableFiles;
}
void Navigator::share(ScriptExecutionContext& context, const ShareData& data, Ref<DeferredPromise>&& promise)
@@ -167,7 +162,7 @@
{ },
};
#if ENABLE(FILE_SHARE)
- if (!data.files.isEmpty()) {
+ if (RuntimeEnabledFeatures::sharedFeatures().webShareFileAPIEnabled() && !data.files.isEmpty()) {
if (m_loader)
m_loader->cancel();
Modified: trunk/Source/WebKit/ChangeLog (266157 => 266158)
--- trunk/Source/WebKit/ChangeLog 2020-08-26 02:25:04 UTC (rev 266157)
+++ trunk/Source/WebKit/ChangeLog 2020-08-26 05:09:19 UTC (rev 266158)
@@ -1,3 +1,16 @@
+2020-08-25 Tim Horton <[email protected]>
+
+ Web Share API Level 2 functions even when its experimental feature flag is disabled
+ https://bugs.webkit.org/show_bug.cgi?id=215831
+ <rdar://problem/67760687>
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::showShareSheet):
+ If the Web Content process sends us files, but the Level 2 feature flag is disabled,
+ something fishy is happening, so fire a MESSAGE_CHECK.
+
2020-08-25 Ryosuke Niwa <[email protected]>
HashMap<Ref<T>>::take should return RefPtr<T>
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (266157 => 266158)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-08-26 02:25:04 UTC (rev 266157)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-08-26 05:09:19 UTC (rev 266158)
@@ -5945,6 +5945,7 @@
void WebPageProxy::showShareSheet(const ShareDataWithParsedURL& shareData, CompletionHandler<void(bool)>&& completionHandler)
{
MESSAGE_CHECK(m_process, !shareData.url || shareData.url->protocolIsInHTTPFamily() || shareData.url->protocolIsData());
+ MESSAGE_CHECK(m_process, shareData.files.isEmpty() || m_preferences->webShareFileAPIEnabled());
pageClient().showShareSheet(shareData, WTFMove(completionHandler));
}