summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-share/canShare.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/web-share/canShare.https.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/web-share/canShare.https.html')
-rw-r--r--testing/web-platform/tests/web-share/canShare.https.html159
1 files changed, 159 insertions, 0 deletions
diff --git a/testing/web-platform/tests/web-share/canShare.https.html b/testing/web-platform/tests/web-share/canShare.https.html
new file mode 100644
index 0000000000..f0aed9a244
--- /dev/null
+++ b/testing/web-platform/tests/web-share/canShare.https.html
@@ -0,0 +1,159 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>WebShare Test: canShare method tests</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <script>
+ test(() => {
+ assert_false(
+ navigator.canShare(),
+ "no arguments (uses default argument value, which is empty dictionary)"
+ );
+
+ assert_false(navigator.canShare({}), "empty dictionary not allowed");
+
+ assert_false(navigator.canShare(undefined), "empty dictionary not allowed");
+
+ assert_false(navigator.canShare(null), "empty dictionary not allowed");
+
+ assert_false(
+ navigator.canShare({ unused: "unexpected field" }),
+ "results in empty dictionary, which is not allowed"
+ );
+ }, "canShare() empty and default dictionary");
+
+ test(() => {
+ assert_true(navigator.canShare({ url: "http://a.b" }), "http URL is ok");
+
+ assert_true(navigator.canShare({ url: "https://a.b" }), "https URL is ok");
+
+ assert_false(
+ navigator.canShare({ url: "http://a.b:65536" }),
+ "URL is invalid"
+ );
+
+ assert_false(
+ navigator.canShare({ url: "data:the url" }),
+ "data URL is not allowed"
+ );
+
+ assert_false(
+ navigator.canShare({ url: "file:///usr/" }),
+ "file URL is not allowed"
+ );
+
+ assert_true(
+ navigator.canShare({
+ url: "https://a.b/path?query#fragment",
+ }),
+ "canShare with URL"
+ );
+
+ assert_true(
+ navigator.canShare({
+ url: {
+ toString() {
+ return "https://a.b/";
+ },
+ },
+ }),
+ "canShare URL as with object with stringifier"
+ );
+
+ assert_true(
+ navigator.canShare(
+ { url: "" },
+ "canShare with empty URL, which resolves as the doc's base URL"
+ )
+ );
+
+ assert_true(
+ navigator.canShare({
+ url: "//a.b/path?query#fragment",
+ }),
+ "canShare with URL having no scheme"
+ );
+
+ assert_true(
+ navigator.canShare({
+ url: "relative",
+ }),
+ "canShare relative URL, resolved against API base URL"
+ );
+ }, "canShare() url member");
+
+ test(() => {
+ assert_false(
+ navigator.canShare({ title: undefined }),
+ "canShare with attribute undefined is equivalent to omitting the attribute"
+ );
+
+ assert_true(navigator.canShare({ title: "subject" }), "canShare with title");
+
+ assert_true(navigator.canShare({ title: null }), "stringified null");
+ }, "canShare() title member");
+
+ test(() => {
+ assert_true(navigator.canShare({ text: "" }), "ok to share empty text");
+
+ assert_true(
+ navigator.canShare({ text: "some text 🤔" }),
+ "ok to share unicode"
+ );
+
+ assert_true(navigator.canShare({ text: 123 }), "number is stringified");
+ }, "canShare() text member");
+
+ test(() => {
+ const file = new File(["hello"], "file", { type: "text/plain" });
+ const file2 = new File([], "file2");
+
+ assert_false(navigator.canShare({ files: [] }), "empty list is not allowed");
+
+ assert_false(
+ navigator.canShare({
+ url: "https://a.b:800000",
+ files: [file, file2],
+ }),
+ "invalid URL invalidates the share"
+ );
+
+ assert_true(
+ navigator.canShare({ files: [file] }),
+ "single file is ok to share"
+ );
+
+ assert_true(
+ navigator.canShare({ files: [file, file2, file] }),
+ "repeated files is ok to share"
+ );
+
+ assert_true(
+ navigator.canShare({
+ files: [file, file2],
+ text: "some texts",
+ url: "https://example.com/",
+ }),
+ "is ok to share files, text, and url together"
+ );
+ }, "canShare() files member");
+
+ test(() => {
+ assert_true(
+ navigator.canShare({
+ title: "subject",
+ text: "body",
+ url: "https://a.b/",
+ files: [new File([], "file")],
+ unused: "unexpected field",
+ }),
+ "canShare with unexpected field"
+ );
+ }, "canShare() multiple members");
+ </script>
+ </body>
+</html>