mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 05:39:41 +02:00
Automatic update from web-platform-tests WebShare: canShare() method in Level 2 canShare(data) returns false iff share(data) would reject with TypeError https://wicg.github.io/web-share/level-2/#canshare-method Intent to Implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/AiKgWvv3cq0/xAsjfSfMDQAJ Bug: 903010 Change-Id: I15e8a92a9d71b08da4e9e6d4bf2692c97dce5c0f Reviewed-on: https://chromium-review.googlesource.com/c/1351340 Commit-Queue: Eric Willigers <ericwilligers@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#624658} -- wpt-commits: f5df77f83ba77088d354838b377eef5e3f770e36 wpt-pr: 14967
40 lines
1.3 KiB
HTML
40 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>WebShare Test: canShare with files</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
'use strict';
|
|
const textFile = new File(['hello'], 'hello.txt', {type:'text/plain'});
|
|
const emptyFile = new File([''], 'empty');
|
|
|
|
test(() => {
|
|
assert_throws(new TypeError(), () => { navigator.canShare({files: textFile}) });
|
|
}, 'canShare with single file');
|
|
|
|
test(() => {
|
|
assert_equals(navigator.canShare({files: []}), false);
|
|
}, 'canShare with empty file list');
|
|
|
|
test(() => {
|
|
assert_equals(navigator.canShare({files: [emptyFile]}), true);
|
|
}, 'canShare with single file list');
|
|
|
|
test(() => {
|
|
assert_equals(navigator.canShare({files: [textFile, emptyFile]}), true);
|
|
}, 'canShare with file list');
|
|
|
|
test(() => {
|
|
assert_equals(navigator.canShare({files: [textFile, emptyFile, textFile]}), true);
|
|
}, 'canShare with repeated file');
|
|
|
|
test(() => {
|
|
assert_equals(navigator.canShare({url: 'https://example.com/', files: [textFile, emptyFile]}), true);
|
|
}, 'canShare with file list and url');
|
|
</script>
|
|
</body>
|
|
</html>
|