Title: [266179] branches/safari-610.1.28.0-branch

Diff

Modified: branches/safari-610.1.28.0-branch/LayoutTests/ChangeLog (266178 => 266179)


--- branches/safari-610.1.28.0-branch/LayoutTests/ChangeLog	2020-08-26 18:41:06 UTC (rev 266178)
+++ branches/safari-610.1.28.0-branch/LayoutTests/ChangeLog	2020-08-26 18:49:00 UTC (rev 266179)
@@ -1,3 +1,19 @@
+2020-08-26  Russell Epstein  <[email protected]>
+
+        Apply patch. rdar://problem/67812567
+
+    2020-08-26  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>
+
+            * 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-20  Alan Coon  <[email protected]>
 
         Cherry-pick r265932. rdar://problem/67485356

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


--- branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt	                        (rev 0)
+++ branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled-expected.txt	2020-08-26 18:49:00 UTC (rev 266179)
@@ -0,0 +1 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled.

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


--- branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html	                        (rev 0)
+++ branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/canShare-with-files-feature-disabled.html	2020-08-26 18:49:00 UTC (rev 266179)
@@ -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.1.28.0-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt (0 => 266179)


--- branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt	                        (rev 0)
+++ branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled-expected.txt	2020-08-26 18:49:00 UTC (rev 266179)
@@ -0,0 +1,2 @@
+PASS: Not allowed to share file with Web Share Level 2 disabled: TypeError: Type error
+

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


--- branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled.html	                        (rev 0)
+++ branches/safari-610.1.28.0-branch/LayoutTests/fast/web-share/share-with-files-feature-disabled.html	2020-08-26 18:49:00 UTC (rev 266179)
@@ -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.1.28.0-branch/Source/WebCore/ChangeLog (266178 => 266179)


--- branches/safari-610.1.28.0-branch/Source/WebCore/ChangeLog	2020-08-26 18:41:06 UTC (rev 266178)
+++ branches/safari-610.1.28.0-branch/Source/WebCore/ChangeLog	2020-08-26 18:49:00 UTC (rev 266179)
@@ -1,3 +1,27 @@
+2020-08-26  Russell Epstein  <[email protected]>
+
+        Apply patch. rdar://problem/67812567
+
+    2020-08-26  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>
+
+            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-19  Russell Epstein  <[email protected]>
 
         Cherry-pick r265890. rdar://problem/67439260

Modified: branches/safari-610.1.28.0-branch/Source/WebCore/page/Navigator.cpp (266178 => 266179)


--- branches/safari-610.1.28.0-branch/Source/WebCore/page/Navigator.cpp	2020-08-26 18:41:06 UTC (rev 266178)
+++ branches/safari-610.1.28.0-branch/Source/WebCore/page/Navigator.cpp	2020-08-26 18:49:00 UTC (rev 266179)
@@ -115,24 +115,22 @@
     auto* frame = this->frame();
     if (!frame || !frame->page())
         return false;
-    if (data.title.isNull() && data.url.isNull() && data.text.isNull()) {
-        if (!data.files.isEmpty()) {
-#if ENABLE(FILE_SHARE)
-            return true;
-#else
-            return false;
-#endif
-        }
-        return false;
-    }
-
+ 
+    bool hasShareableTitleOrText = !data.title.isNull() || !data.text.isNull();
+    bool hasShareableURL = false;
     Optional<URL> url;
     if (!data.url.isNull()) {
         url = ""
-        if (!url->isValid())
-            return false;
+        if (url->isValid())
+            hasShareableURL = true;
     }
-    return true;
+#if ENABLE(FILE_SHARE)
+    bool hasShareableFiles = RuntimeEnabledFeatures::sharedFeatures().webShareFileAPIEnabled() && !data.files.isEmpty();
+#else
+    bool hasShareableFiles = false;
+#endif
+  
+    return hasShareableTitleOrText || hasShareableURL || hasShareableFiles;
 }
 
 void Navigator::share(ScriptExecutionContext& context, const ShareData& data, Ref<DeferredPromise>&& promise)
@@ -159,7 +157,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.1.28.0-branch/Source/WebKit/ChangeLog (266178 => 266179)


--- branches/safari-610.1.28.0-branch/Source/WebKit/ChangeLog	2020-08-26 18:41:06 UTC (rev 266178)
+++ branches/safari-610.1.28.0-branch/Source/WebKit/ChangeLog	2020-08-26 18:49:00 UTC (rev 266179)
@@ -1,3 +1,18 @@
+2020-08-26  Russell Epstein  <[email protected]>
+
+        Apply patch. rdar://problem/67812567
+
+    2020-08-26  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>
+
+            * 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-20  Alan Coon  <[email protected]>
 
         Cherry-pick r265932. rdar://problem/67485356

Modified: branches/safari-610.1.28.0-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (266178 => 266179)


--- branches/safari-610.1.28.0-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-08-26 18:41:06 UTC (rev 266178)
+++ branches/safari-610.1.28.0-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-08-26 18:49:00 UTC (rev 266179)
@@ -5932,6 +5932,7 @@
 
 void WebPageProxy::showShareSheet(const ShareDataWithParsedURL& shareData, CompletionHandler<void(bool)>&& completionHandler)
 {
+    MESSAGE_CHECK(m_process, shareData.files.isEmpty() || m_preferences->webShareFileAPIEnabled());
     pageClient().showShareSheet(shareData, WTFMove(completionHandler));
 }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to