Title: [266551] branches/safari-610-branch
Revision
266551
Author
alanc...@apple.com
Date
2020-09-03 14:31:06 -0700 (Thu, 03 Sep 2020)

Log Message

Cherry-pick r266158. rdar://problem/67812825

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266158 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-610-branch/LayoutTests/ChangeLog (266550 => 266551)


--- branches/safari-610-branch/LayoutTests/ChangeLog	2020-09-03 21:31:02 UTC (rev 266550)
+++ branches/safari-610-branch/LayoutTests/ChangeLog	2020-09-03 21:31:06 UTC (rev 266551)
@@ -1,5 +1,63 @@
 2020-09-03  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r266158. rdar://problem/67812825
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Tim Horton  <timothy_hor...@apple.com>
+
+            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-09-03  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r266151. rdar://problem/67812825
 
     Web Share API can share non-HTTP(S) URLs

Added: branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt (0 => 266551)


--- branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt	2020-09-03 21:31:06 UTC (rev 266551)
@@ -0,0 +1 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled.

Added: branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html (0 => 266551)


--- branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html	2020-09-03 21:31:06 UTC (rev 266551)
@@ -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: branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt (0 => 266551)


--- branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt	2020-09-03 21:31:06 UTC (rev 266551)
@@ -0,0 +1,2 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled: TypeError: Type error
+

Added: branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled.html (0 => 266551)


--- branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled.html	                        (rev 0)
+++ branches/safari-610-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled.html	2020-09-03 21:31:06 UTC (rev 266551)
@@ -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: branches/safari-610-branch/Source/WebCore/ChangeLog (266550 => 266551)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-03 21:31:02 UTC (rev 266550)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-03 21:31:06 UTC (rev 266551)
@@ -1,5 +1,71 @@
 2020-09-03  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r266158. rdar://problem/67812825
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Tim Horton  <timothy_hor...@apple.com>
+
+            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-09-03  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r266151. rdar://problem/67812825
 
     Web Share API can share non-HTTP(S) URLs

Modified: branches/safari-610-branch/Source/WebCore/page/Navigator.cpp (266550 => 266551)


--- branches/safari-610-branch/Source/WebCore/page/Navigator.cpp	2020-09-03 21:31:02 UTC (rev 266550)
+++ branches/safari-610-branch/Source/WebCore/page/Navigator.cpp	2020-09-03 21:31:06 UTC (rev 266551)
@@ -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: branches/safari-610-branch/Source/WebKit/ChangeLog (266550 => 266551)


--- branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-03 21:31:02 UTC (rev 266550)
+++ branches/safari-610-branch/Source/WebKit/ChangeLog	2020-09-03 21:31:06 UTC (rev 266551)
@@ -1,5 +1,62 @@
 2020-09-03  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r266158. rdar://problem/67812825
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Tim Horton  <timothy_hor...@apple.com>
+
+            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-09-03  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r266151. rdar://problem/67812825
 
     Web Share API can share non-HTTP(S) URLs

Modified: branches/safari-610-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (266550 => 266551)


--- branches/safari-610-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-09-03 21:31:02 UTC (rev 266550)
+++ branches/safari-610-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-09-03 21:31:06 UTC (rev 266551)
@@ -5941,6 +5941,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));
 }
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to