haikuwebkit/LayoutTests/fast/web-share/share-with-files.html

50 lines
1.2 KiB
HTML
Raw Permalink Normal View History

Add canShare function for Web Share API v2 https://bugs.webkit.org/show_bug.cgi?id=207491 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-24 Reviewed by Tim Horton. LayoutTests/imported/w3c: Imported new web platform tests for canShare function. * resources/import-expectations.json: * web-platform-tests/web-share/OWNERS: Removed. * web-platform-tests/web-share/idlharness.https.html: Removed. * web-platform-tests/web-share/resources/manual-helper.js: (setupManualShareTest): (callWhenButtonClicked): * web-platform-tests/web-share/resources/w3c-import.log: * web-platform-tests/web-share/share-empty.https.html: * web-platform-tests/web-share/share-url-invalid.https.html: * web-platform-tests/web-share/share-without-user-gesture.https.html: * web-platform-tests/web-share/w3c-import.log: Source/WebCore: Added files member to share data and canShare function to navigator.cpp. Can share function should always be used before call to share, and can be used to check if file sharing is implemented by passing a share data object with only files. Imported new Web Platform Tests to test new function. * page/Navigator.cpp: (WebCore::Navigator::canShare): Will currently return false for only file share data objects, since file sharing is currently not implemented. (WebCore::Navigator::share): Changed to use canShare to determine if data is shareable. * page/Navigator.h: * page/NavigatorShare.idl: * page/ShareData.h: * page/ShareData.idl: Canonical link: https://commits.webkit.org/221110@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-25 01:22:00 +00:00
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<meta name="viewport" content="initial-scale=5, width=device-width">
Implement web-share v2 for files https://bugs.webkit.org/show_bug.cgi?id=209265 Reviewed by Andy Estes. LayoutTests/imported/w3c: Updated test expectations for new behavior. * ios-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : * mac-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : Source/WebCore: Modified existing tests for new behavior. Added support for handling of files in share/canShare, and implemented asynchronous reading of data from blobs on disk into memory. * WebCore.xcodeproj/project.pbxproj: * page/Navigator.cpp: (WebCore::Navigator::canShare): (WebCore::Navigator::share): (WebCore::Navigator::finishedLoad): * page/Navigator.h: * page/ReadShareDataAsync.cpp: Added. (WebCore::ReadShareDataAsync::readInternal): (WebCore::ReadShareDataAsync::ReadShareDataAsync): (WebCore::ReadShareDataAsync::~ReadShareDataAsync): (WebCore::ReadShareDataAsync::start): (WebCore::ReadShareDataAsync::didFinishLoading): (WebCore::ReadShareDataAsync::didReceiveData): (WebCore::ReadShareDataAsync::didStartLoading): (WebCore::ReadShareDataAsync::didFail): * page/ReadShareDataAsync.hpp: Added. * page/ShareData.h: Source/WebKit: Added support for passing file objects over IPC and sharing of files to share sheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<Vector<RawFile>>::encode): (IPC::ArgumentCoder<Vector<RawFile>>::decode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::encode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::decode): * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/ShareableFileWrite.h: Added. * UIProcess/Cocoa/ShareableFileWrite.mm: Added. (+[WKShareableFileWrite getSharingDirectoryPath]): (+[WKShareableFileWrite getFileDirectoryForSharing]): (+[WKShareableFileWrite removeFileDirectoryForSharing]): (+[WKShareableFileWrite setQuarantineInformationForFilePath:]): (+[WKShareableFileWrite applyQuarantineSandboxAndDownloadFlagsToFileAtPath:]): (+[WKShareableFileWrite createFilename:]): (+[WKShareableFileWrite writeFileToShareableURL:data:]): * UIProcess/Cocoa/WKShareSheet.mm: (-[WKShareSheet presentWithParameters:inRect:completionHandler:]): (-[WKShareSheet _didCompleteWithSuccess:]): * WebKit.xcodeproj/project.pbxproj: LayoutTests: Modified to no longer use url of image. * fast/web-share/share-with-files.html: Canonical link: https://commits.webkit.org/224560@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-08 20:46:10 +00:00
Add canShare function for Web Share API v2 https://bugs.webkit.org/show_bug.cgi?id=207491 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-24 Reviewed by Tim Horton. LayoutTests/imported/w3c: Imported new web platform tests for canShare function. * resources/import-expectations.json: * web-platform-tests/web-share/OWNERS: Removed. * web-platform-tests/web-share/idlharness.https.html: Removed. * web-platform-tests/web-share/resources/manual-helper.js: (setupManualShareTest): (callWhenButtonClicked): * web-platform-tests/web-share/resources/w3c-import.log: * web-platform-tests/web-share/share-empty.https.html: * web-platform-tests/web-share/share-url-invalid.https.html: * web-platform-tests/web-share/share-without-user-gesture.https.html: * web-platform-tests/web-share/w3c-import.log: Source/WebCore: Added files member to share data and canShare function to navigator.cpp. Can share function should always be used before call to share, and can be used to check if file sharing is implemented by passing a share data object with only files. Imported new Web Platform Tests to test new function. * page/Navigator.cpp: (WebCore::Navigator::canShare): Will currently return false for only file share data objects, since file sharing is currently not implemented. (WebCore::Navigator::share): Changed to use canShare to determine if data is shareable. * page/Navigator.h: * page/NavigatorShare.idl: * page/ShareData.h: * page/ShareData.idl: Canonical link: https://commits.webkit.org/221110@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-25 01:22:00 +00:00
<head>
<script src="../../resources/ui-helper.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
let write = (message) => output.innerHTML += (message + "<br>");
function runTest()
{
Implement web-share v2 for files https://bugs.webkit.org/show_bug.cgi?id=209265 Reviewed by Andy Estes. LayoutTests/imported/w3c: Updated test expectations for new behavior. * ios-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : * mac-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : Source/WebCore: Modified existing tests for new behavior. Added support for handling of files in share/canShare, and implemented asynchronous reading of data from blobs on disk into memory. * WebCore.xcodeproj/project.pbxproj: * page/Navigator.cpp: (WebCore::Navigator::canShare): (WebCore::Navigator::share): (WebCore::Navigator::finishedLoad): * page/Navigator.h: * page/ReadShareDataAsync.cpp: Added. (WebCore::ReadShareDataAsync::readInternal): (WebCore::ReadShareDataAsync::ReadShareDataAsync): (WebCore::ReadShareDataAsync::~ReadShareDataAsync): (WebCore::ReadShareDataAsync::start): (WebCore::ReadShareDataAsync::didFinishLoading): (WebCore::ReadShareDataAsync::didReceiveData): (WebCore::ReadShareDataAsync::didStartLoading): (WebCore::ReadShareDataAsync::didFail): * page/ReadShareDataAsync.hpp: Added. * page/ShareData.h: Source/WebKit: Added support for passing file objects over IPC and sharing of files to share sheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<Vector<RawFile>>::encode): (IPC::ArgumentCoder<Vector<RawFile>>::decode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::encode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::decode): * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/ShareableFileWrite.h: Added. * UIProcess/Cocoa/ShareableFileWrite.mm: Added. (+[WKShareableFileWrite getSharingDirectoryPath]): (+[WKShareableFileWrite getFileDirectoryForSharing]): (+[WKShareableFileWrite removeFileDirectoryForSharing]): (+[WKShareableFileWrite setQuarantineInformationForFilePath:]): (+[WKShareableFileWrite applyQuarantineSandboxAndDownloadFlagsToFileAtPath:]): (+[WKShareableFileWrite createFilename:]): (+[WKShareableFileWrite writeFileToShareableURL:data:]): * UIProcess/Cocoa/WKShareSheet.mm: (-[WKShareSheet presentWithParameters:inRect:completionHandler:]): (-[WKShareSheet _didCompleteWithSuccess:]): * WebKit.xcodeproj/project.pbxproj: LayoutTests: Modified to no longer use url of image. * fast/web-share/share-with-files.html: Canonical link: https://commits.webkit.org/224560@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-08 20:46:10 +00:00
var blob = this.response;
const textFile = new File(['This is a text file'], 'TextFile.txt', {type:'text/html'});
Add canShare function for Web Share API v2 https://bugs.webkit.org/show_bug.cgi?id=207491 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-24 Reviewed by Tim Horton. LayoutTests/imported/w3c: Imported new web platform tests for canShare function. * resources/import-expectations.json: * web-platform-tests/web-share/OWNERS: Removed. * web-platform-tests/web-share/idlharness.https.html: Removed. * web-platform-tests/web-share/resources/manual-helper.js: (setupManualShareTest): (callWhenButtonClicked): * web-platform-tests/web-share/resources/w3c-import.log: * web-platform-tests/web-share/share-empty.https.html: * web-platform-tests/web-share/share-url-invalid.https.html: * web-platform-tests/web-share/share-without-user-gesture.https.html: * web-platform-tests/web-share/w3c-import.log: Source/WebCore: Added files member to share data and canShare function to navigator.cpp. Can share function should always be used before call to share, and can be used to check if file sharing is implemented by passing a share data object with only files. Imported new Web Platform Tests to test new function. * page/Navigator.cpp: (WebCore::Navigator::canShare): Will currently return false for only file share data objects, since file sharing is currently not implemented. (WebCore::Navigator::share): Changed to use canShare to determine if data is shareable. * page/Navigator.h: * page/NavigatorShare.idl: * page/ShareData.h: * page/ShareData.idl: Canonical link: https://commits.webkit.org/221110@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-25 01:22:00 +00:00
document.getElementById("target").addEventListener("click", () => {
Implement web-share v2 for files https://bugs.webkit.org/show_bug.cgi?id=209265 Reviewed by Andy Estes. LayoutTests/imported/w3c: Updated test expectations for new behavior. * ios-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : * mac-wk2/imported/w3c/web-platform-tests/web-share/canShare-files.https-expected.txt : Source/WebCore: Modified existing tests for new behavior. Added support for handling of files in share/canShare, and implemented asynchronous reading of data from blobs on disk into memory. * WebCore.xcodeproj/project.pbxproj: * page/Navigator.cpp: (WebCore::Navigator::canShare): (WebCore::Navigator::share): (WebCore::Navigator::finishedLoad): * page/Navigator.h: * page/ReadShareDataAsync.cpp: Added. (WebCore::ReadShareDataAsync::readInternal): (WebCore::ReadShareDataAsync::ReadShareDataAsync): (WebCore::ReadShareDataAsync::~ReadShareDataAsync): (WebCore::ReadShareDataAsync::start): (WebCore::ReadShareDataAsync::didFinishLoading): (WebCore::ReadShareDataAsync::didReceiveData): (WebCore::ReadShareDataAsync::didStartLoading): (WebCore::ReadShareDataAsync::didFail): * page/ReadShareDataAsync.hpp: Added. * page/ShareData.h: Source/WebKit: Added support for passing file objects over IPC and sharing of files to share sheet. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<Vector<RawFile>>::encode): (IPC::ArgumentCoder<Vector<RawFile>>::decode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::encode): (IPC::ArgumentCoder<ShareDataWithParsedURL>::decode): * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/ShareableFileWrite.h: Added. * UIProcess/Cocoa/ShareableFileWrite.mm: Added. (+[WKShareableFileWrite getSharingDirectoryPath]): (+[WKShareableFileWrite getFileDirectoryForSharing]): (+[WKShareableFileWrite removeFileDirectoryForSharing]): (+[WKShareableFileWrite setQuarantineInformationForFilePath:]): (+[WKShareableFileWrite applyQuarantineSandboxAndDownloadFlagsToFileAtPath:]): (+[WKShareableFileWrite createFilename:]): (+[WKShareableFileWrite writeFileToShareableURL:data:]): * UIProcess/Cocoa/WKShareSheet.mm: (-[WKShareSheet presentWithParameters:inRect:completionHandler:]): (-[WKShareSheet _didCompleteWithSuccess:]): * WebKit.xcodeproj/project.pbxproj: LayoutTests: Modified to no longer use url of image. * fast/web-share/share-with-files.html: Canonical link: https://commits.webkit.org/224560@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-08 20:46:10 +00:00
navigator.share({text: "This is a text file", files: [textFile]}).then((result) => {
write("PASS: Share sheet invoked.");
Add canShare function for Web Share API v2 https://bugs.webkit.org/show_bug.cgi?id=207491 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-24 Reviewed by Tim Horton. LayoutTests/imported/w3c: Imported new web platform tests for canShare function. * resources/import-expectations.json: * web-platform-tests/web-share/OWNERS: Removed. * web-platform-tests/web-share/idlharness.https.html: Removed. * web-platform-tests/web-share/resources/manual-helper.js: (setupManualShareTest): (callWhenButtonClicked): * web-platform-tests/web-share/resources/w3c-import.log: * web-platform-tests/web-share/share-empty.https.html: * web-platform-tests/web-share/share-url-invalid.https.html: * web-platform-tests/web-share/share-without-user-gesture.https.html: * web-platform-tests/web-share/w3c-import.log: Source/WebCore: Added files member to share data and canShare function to navigator.cpp. Can share function should always be used before call to share, and can be used to check if file sharing is implemented by passing a share data object with only files. Imported new Web Platform Tests to test new function. * page/Navigator.cpp: (WebCore::Navigator::canShare): Will currently return false for only file share data objects, since file sharing is currently not implemented. (WebCore::Navigator::share): Changed to use canShare to determine if data is shareable. * page/Navigator.h: * page/NavigatorShare.idl: * page/ShareData.h: * page/ShareData.idl: Canonical link: https://commits.webkit.org/221110@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-25 01:22:00 +00:00
testRunner.notifyDone();
});
});
[ iOS wk2 ] imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https.html is a constant timeout https://bugs.webkit.org/show_bug.cgi?id=214694 <rdar://problem/66001110> Reviewed by Tim Horton. Tools: The test was failing because there was a share sheet still being presented from a previous Web Share test. TestController::platformResetStateToConsistentValues() would wait for that share sheet to get dismiss and would eventually give up and report the test as timing out. The issue is that WebKit layout test were relying on a UIScriptController function to dismiss the share sheet but Web Platform Tests did not. To address the issue, we now always promptly dismiss the share sheet in WebKitTestRunner, without the need for a UIScriptController function call. The Share Sheet now gets dismissed promptly in both WebKit tests and WPT tests. For robustness, I also added code in WebKitTestRunner to dismiss any remaining presented view controller after waiting, to avoid failing on the next test in such cases. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::setShareSheetCompletesImmediatelyWithResolution): Deleted. * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::setShareSheetCompletesImmediatelyWithResolution): Deleted. Delete UIScriptController.setShareSheetCompletesImmediatelyWithResolution() utility function for tests now that it is the default in WebKit TestRunner. * WebKitTestRunner/ios/TestControllerIOS.mm: (WTR::TestController::platformResetStateToConsistentValues): - Call _setShareSheetCompletesImmediatelyWithResolutionForTesting:YES on the test WKWebView instead of relying on individual tests to do that. - For robustness, if there is still a presented view controller after waiting, we now dismiss it ourselves instead of failing. This otherwise leads to next test to be reported as failing (or timing out) because there is a presented view controller that remains from the previous test. Note that this is not needed to fix the layout test in question since we now properly dismiss the share UI in WPT tests but I still think it is a good thing to do for robustness and avoid test flakiness. LayoutTests: * fast/web-share/share-transient-activation-expired.html: * fast/web-share/share-transient-activation.html: * fast/web-share/share-with-files.html: * fast/web-share/share-with-no-url.html: * fast/web-share/share.html: * platform/ios/TestExpectations: * resources/ui-helper.js: (window.UIHelper.setShareSheetCompletesImmediatelyWithResolution): Deleted. Update existing layout test so stop calling UIHelper.setShareSheetCompletesImmediatelyWithResolution() now that it is the default in WebKitTestRunner. * platform/ios/TestExpectations: Unskip test that is no longer timing out. Canonical link: https://commits.webkit.org/227560@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264834 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-24 16:44:55 +00:00
UIHelper.activateAt(50, 50);
Add canShare function for Web Share API v2 https://bugs.webkit.org/show_bug.cgi?id=207491 Patch by Nikos Mouchtaris <nmouchtaris@apple.com> on 2020-02-24 Reviewed by Tim Horton. LayoutTests/imported/w3c: Imported new web platform tests for canShare function. * resources/import-expectations.json: * web-platform-tests/web-share/OWNERS: Removed. * web-platform-tests/web-share/idlharness.https.html: Removed. * web-platform-tests/web-share/resources/manual-helper.js: (setupManualShareTest): (callWhenButtonClicked): * web-platform-tests/web-share/resources/w3c-import.log: * web-platform-tests/web-share/share-empty.https.html: * web-platform-tests/web-share/share-url-invalid.https.html: * web-platform-tests/web-share/share-without-user-gesture.https.html: * web-platform-tests/web-share/w3c-import.log: Source/WebCore: Added files member to share data and canShare function to navigator.cpp. Can share function should always be used before call to share, and can be used to check if file sharing is implemented by passing a share data object with only files. Imported new Web Platform Tests to test new function. * page/Navigator.cpp: (WebCore::Navigator::canShare): Will currently return false for only file share data objects, since file sharing is currently not implemented. (WebCore::Navigator::share): Changed to use canShare to determine if data is shareable. * page/Navigator.h: * page/NavigatorShare.idl: * page/ShareData.h: * page/ShareData.idl: Canonical link: https://commits.webkit.org/221110@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-25 01:22:00 +00:00
}
</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>