Changeset 257289 in webkit
- Timestamp:
- Feb 24, 2020 5:22:00 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 30 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/TestExpectations
r257283 r257289 734 734 imported/w3c/web-platform-tests/content-security-policy/worker-src/shared-worker-src-script-fallback.sub.html 735 735 imported/w3c/web-platform-tests/content-security-policy/worker-src/shared-worker-src-self-fallback.sub.html 736 737 # Web platform test infrastructure unable to support insecure connection 738 imported/w3c/web-platform-tests/web-share/canShare-insecure.http.html 739 imported/w3c/web-platform-tests/web-share/share-securecontext.http.html 740 741 # Web platform tests produce wrong failing results- https://bugs.webkit.org/show_bug.cgi?id=208083 742 imported/w3c/web-platform-tests/web-share/idlharness.https.window.html 743 imported/w3c/web-platform-tests/web-share/share-empty.https.html 744 imported/w3c/web-platform-tests/web-share/share-url-invalid.https.html 745 imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https.html 746 imported/w3c/web-platform-tests/web-share/canShare.https.html 747 imported/w3c/web-platform-tests/web-share/canShare-files.https.html 736 748 737 749 # Only relevant on macOS -
trunk/LayoutTests/imported/w3c/ChangeLog
r257206 r257289 1 2020-02-24 Nikos Mouchtaris <nmouchtaris@apple.com> 2 3 Add canShare function for Web Share API v2 4 https://bugs.webkit.org/show_bug.cgi?id=207491 5 6 Reviewed by Tim Horton. 7 8 Imported new web platform tests for canShare function. 9 10 * resources/import-expectations.json: 11 * web-platform-tests/web-share/OWNERS: Removed. 12 * web-platform-tests/web-share/idlharness.https.html: Removed. 13 * web-platform-tests/web-share/resources/manual-helper.js: 14 (setupManualShareTest): 15 (callWhenButtonClicked): 16 * web-platform-tests/web-share/resources/w3c-import.log: 17 * web-platform-tests/web-share/share-empty.https.html: 18 * web-platform-tests/web-share/share-url-invalid.https.html: 19 * web-platform-tests/web-share/share-without-user-gesture.https.html: 20 * web-platform-tests/web-share/w3c-import.log: 21 1 22 2020-02-24 Rob Buis <rbuis@igalia.com> 2 23 -
trunk/LayoutTests/imported/w3c/resources/import-expectations.json
r256786 r257289 383 383 "web-platform-tests/web-animations": "import", 384 384 "web-platform-tests/web-nfc": "skip", 385 "web-platform-tests/web-share": "import", 385 386 "web-platform-tests/webaudio": "import", 386 387 "web-platform-tests/webauthn": "skip", -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/resources/manual-helper.js
r222307 r257289 29 29 // instructions (based on the parameters) and the share button. 30 30 function setupManualShareTest(expected_share_data) { 31 const {title, text, url } = expected_share_data;31 const {title, text, url, files} = expected_share_data; 32 32 let [instruction, list] = setupManualShareTestCommon(); 33 33 let item = document.createElement('li'); … … 51 51 list.appendChild(item); 52 52 item.innerText = `url = "${url}"`; 53 if (files) { 54 item = document.createElement('li'); 55 list.appendChild(item); 56 item.innerText = `files = ${files.length} file(s)`; 57 for (let file of files) { 58 const div = document.createElement('div'); 59 if (file.type.startsWith('text/')) { 60 const reader = new FileReader(); 61 reader.onload = () => { 62 div.textContent = reader.result; 63 }; 64 reader.readAsText(file); 65 } else if (file.type.startsWith('image/')) { 66 const image = document.createElement('img'); 67 image.src = URL.createObjectURL(file); 68 image.alt = file.name; 69 div.appendChild(image); 70 } 71 item.appendChild(div); 72 } 73 } 53 74 } 54 75 … … 66 87 document.querySelector('#share_button').onclick = () => { 67 88 try { 68 resolve(click_handler()); 89 const result = click_handler(); 90 resolve(result); 69 91 } catch (e) { 70 92 reject(e); -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/resources/w3c-import.log
r222307 r257289 2 2 Do NOT modify these tests directly in WebKit. 3 3 Instead, create a pull request on the WPT github: 4 https://github.com/w 3c/web-platform-tests4 https://github.com/web-platform-tests/wpt 5 5 6 6 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/share-empty.https.html
r222307 r257289 11 11 <script> 12 12 promise_test(t => { 13 return promise_rejects (t, new TypeError(), navigator.share());13 return promise_rejects_js(t, TypeError, navigator.share()); 14 14 }, 'share with no arguments (same as empty dictionary)'); 15 15 16 16 promise_test(t => { 17 return promise_rejects (t, new TypeError(), navigator.share({}));17 return promise_rejects_js(t, TypeError, navigator.share({})); 18 18 }, 'share with an empty dictionary'); 19 19 20 20 promise_test(t => { 21 return promise_rejects (t, new TypeError(), navigator.share(undefined));21 return promise_rejects_js(t, TypeError, navigator.share(undefined)); 22 22 }, 'share with a undefined argument (same as empty dictionary)'); 23 23 24 24 promise_test(t => { 25 return promise_rejects (t, new TypeError(), navigator.share(null));25 return promise_rejects_js(t, TypeError, navigator.share(null)); 26 26 }, 'share with a null argument (same as empty dictionary)'); 27 27 28 28 promise_test(t => { 29 return promise_rejects (t,30 new TypeError(), navigator.share({unused: 'unexpected field'}));29 return promise_rejects_js(t, 30 TypeError, navigator.share({unused: 'unexpected field'})); 31 31 }, 'share with a dictionary containing only surplus fields'); 32 32 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-invalid.https.html
r222307 r257289 13 13 // large). 14 14 const url = 'http://example.com:65536'; 15 return promise_rejects (16 t, new TypeError(), navigator.share({url}));15 return promise_rejects_js( 16 t, TypeError, navigator.share({url})); 17 17 }, 'share with an invalid URL'); 18 18 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https.html
r222307 r257289 13 13 t, 'NotAllowedError', 14 14 navigator.share({title: 'the title', text: 'the message', 15 url: ' data:the url'}));15 url: 'https://example.com'})); 16 16 }, 'share without a user gesture'); 17 17 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/web-share/w3c-import.log
r222307 r257289 2 2 Do NOT modify these tests directly in WebKit. 3 3 Instead, create a pull request on the WPT github: 4 https://github.com/w 3c/web-platform-tests4 https://github.com/web-platform-tests/wpt 5 5 6 6 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport … … 15 15 ------------------------------------------------------------------------ 16 16 List of files: 17 /LayoutTests/imported/w3c/web-platform-tests/web-share/OWNERS 18 /LayoutTests/imported/w3c/web-platform-tests/web-share/idlharness.https.html 17 /LayoutTests/imported/w3c/web-platform-tests/web-share/META.yml 18 /LayoutTests/imported/w3c/web-platform-tests/web-share/canShare-files.tentative.https.html 19 /LayoutTests/imported/w3c/web-platform-tests/web-share/canShare-insecure.tentative.http.html 20 /LayoutTests/imported/w3c/web-platform-tests/web-share/canShare.tentative.https.html 21 /LayoutTests/imported/w3c/web-platform-tests/web-share/idlharness.https.window.js 22 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-cancel-manual.https.html 19 23 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-empty.https.html 24 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-extra-argument-manual.https.html 25 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-extra-field-manual.https.html 26 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-files-manual.tentative.https.html 27 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-image-manual.tentative.https.html 28 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-non-string-manual.https.html 29 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-null-manual.https.html 20 30 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-securecontext.http.html 31 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-sharePromise-internal-slot.https.html 32 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-simple-manual.https.html 33 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-unicode-strings-manual.https.html 34 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-unicode-strings-nonutf8-manual.https.html 35 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-data-manual.https.html 36 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-empty-manual.https.html 37 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-encoding-manual.https.html 21 38 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-invalid.https.html 39 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-noscheme-manual.https.html 40 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-pathonly-manual.https.html 41 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-url-relative-manual.https.html 22 42 /LayoutTests/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https.html -
trunk/Source/WebCore/ChangeLog
r257285 r257289 1 2020-02-24 Nikos Mouchtaris <nmouchtaris@apple.com> 2 3 Add canShare function for Web Share API v2 4 https://bugs.webkit.org/show_bug.cgi?id=207491 5 6 Reviewed by Tim Horton. 7 8 Added files member to share data and canShare function to 9 navigator.cpp. Can share function should always be used 10 before call to share, and can be used to check if file 11 sharing is implemented by passing a share data object with 12 only files. 13 14 Imported new Web Platform Tests to test new function. 15 16 * page/Navigator.cpp: 17 (WebCore::Navigator::canShare): Will currently return false for 18 only file share data objects, since file sharing is currently 19 not implemented. 20 (WebCore::Navigator::share): Changed to use canShare to 21 determine if data is shareable. 22 * page/Navigator.h: 23 * page/NavigatorShare.idl: 24 * page/ShareData.h: 25 * page/ShareData.idl: 26 1 27 2020-02-24 Yusuke Suzuki <ysuzuki@apple.com> 2 28 -
trunk/Source/WebCore/page/Navigator.cpp
r254178 r257289 43 43 #include "SecurityOrigin.h" 44 44 #include "Settings.h" 45 #include "ShareData.h" 45 46 #include <wtf/IsoMallocInlines.h> 46 47 #include <wtf/Language.h> … … 106 107 } 107 108 108 void Navigator::share(ScriptExecutionContext& context, ShareData data, Ref<DeferredPromise>&& promise) 109 { 110 auto* frame = this->frame(); 111 if (!frame || !frame->page()) { 109 bool Navigator::canShare(ScriptExecutionContext& context, const ShareData& data) 110 { 111 auto* frame = this->frame(); 112 if (!frame || !frame->page()) 113 return false; 114 if (data.title.isNull() && data.url.isNull() && data.text.isNull()) { 115 if (!data.files.isEmpty()) 116 return false; 117 return false; 118 } 119 120 Optional<URL> url; 121 if (!data.url.isNull()) { 122 url = context.completeURL(data.url); 123 if (!url->isValid()) 124 return false; 125 } 126 return true; 127 } 128 129 void Navigator::share(ScriptExecutionContext& context, const ShareData& data, Ref<DeferredPromise>&& promise) 130 { 131 if (!canShare(context, data)) { 112 132 promise->reject(TypeError); 113 133 return; 114 134 } 115 135 116 if (data.title.isEmpty() && data.url.isEmpty() && data.text.isEmpty()) {117 promise->reject(TypeError);118 return;119 }120 121 136 Optional<URL> url; 122 if (!data.url.isEmpty()) {137 if (!data.url.isEmpty()) 123 138 url = context.completeURL(data.url); 124 if (!url->isValid()) {125 promise->reject(TypeError);126 return;127 }128 }129 139 130 140 auto* window = this->window(); … … 139 149 url, 140 150 }; 141 151 152 auto* frame = this->frame(); 142 153 frame->page()->chrome().showShareSheet(shareData, [promise = WTFMove(promise)] (bool completed) { 143 154 if (completed) { -
trunk/Source/WebCore/page/Navigator.h
r250735 r257289 23 23 #include "NavigatorBase.h" 24 24 #include "ScriptWrappable.h" 25 #include "ShareData.h"26 25 #include "Supplementable.h" 27 26 #include <wtf/IsoMalloc.h> … … 32 31 class DOMMimeTypeArray; 33 32 class DOMPluginArray; 33 struct ShareData; 34 34 35 35 class Navigator final : public NavigatorBase, public ScriptWrappable, public DOMWindowProperty, public Supplementable<Navigator> { … … 48 48 void userAgentChanged(); 49 49 bool onLine() const final; 50 void share(ScriptExecutionContext&, ShareData, Ref<DeferredPromise>&&); 50 bool canShare(ScriptExecutionContext&, const ShareData&); 51 void share(ScriptExecutionContext&, const ShareData&, Ref<DeferredPromise>&&); 51 52 52 53 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebCore/page/NavigatorShare.idl
r235489 r257289 29 29 EnabledAtRuntime=WebShare 30 30 ] interface NavigatorShare { 31 [CallWith=ScriptExecutionContext, SecureContext] boolean canShare(optional ShareData shareData); 31 32 [CallWith=ScriptExecutionContext, SecureContext] Promise<void> share(optional ShareData shareData); 32 33 }; -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r257234 r257289 402 402 bool isAccessibilityIsolatedTreeEnabled() const { return m_accessibilityIsolatedTree; } 403 403 #endif 404 405 void setWebShareFileAPIEnabled(bool isEnabled) { m_webShareFileAPIEnabled = isEnabled; } 406 bool webShareFileAPIEnabled() const { return m_webShareFileAPIEnabled; } 404 407 405 408 private: … … 608 611 bool m_accessibilityIsolatedTree { false }; 609 612 #endif 613 bool m_webShareFileAPIEnabled { false }; 610 614 611 615 friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>; -
trunk/Source/WebCore/page/ShareData.h
r239427 r257289 25 25 26 26 #pragma once 27 #include "File.h" 27 28 #include <wtf/URL.h> 28 29 … … 33 34 String text; 34 35 String url; 36 Vector<RefPtr<File>> files; 35 37 }; 36 38 -
trunk/Source/WebCore/page/ShareData.idl
r235489 r257289 28 28 USVString text; 29 29 USVString url; 30 FrozenArray<File> files; 30 31 }; -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r257254 r257289 1960 1960 condition: ENABLE(ACCESSIBILITY_ISOLATED_TREE) 1961 1961 1962 WebShareFileAPIEnabled: 1963 type: bool 1964 defaultValue: false 1965 humanReadableName: "Web Share API Level 2" 1966 humanReadableDescription: "Enable level 2 of Web Share API" 1967 webcoreBinding: RuntimeEnabledFeatures 1968 category: experimental 1969 1962 1970 # Deprecated 1963 1971 -
trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
r256512 r257289 61 61 // Defaults to EditableLinkNeverLive. 62 62 WK_EXPORT void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior); 63 WK_EXPORT WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef); 63 WK_EXPORT WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef); 64 64 65 65 // Defaults to false.
Note: See TracChangeset
for help on using the changeset viewer.