From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/web-share/META.yml | 5 + .../tests/web-share/canShare-files.https.html | 40 ++++++ .../tests/web-share/canShare-insecure.http.html | 16 +++ .../tests/web-share/canShare.https.html | 159 +++++++++++++++++++++ ...-permissions-policy-cross-origin.https.sub.html | 122 ++++++++++++++++ .../disabled-by-permissions-policy.https.sub.html | 27 ++++ ...ed-by-permissions-policy.https.sub.html.headers | 1 + .../web-share/feature-policy-listed.tentative.html | 35 +++++ .../tests/web-share/idlharness.https.window.js | 17 +++ .../tests/web-share/resources/blank.html | 2 + .../tests/web-share/resources/manual-helper.js | 100 +++++++++++++ .../tests/web-share/resources/post-message.html | 35 +++++ .../tests/web-share/share-cancel-manual.https.html | 24 ++++ .../web-share/share-consume-activation.https.html | 33 +++++ .../tests/web-share/share-empty.https.html | 54 +++++++ .../share-extra-argument-manual.https.html | 21 +++ .../web-share/share-extra-field-manual.https.html | 21 +++ .../tests/web-share/share-files-manual.https.html | 30 ++++ .../share-image-manual.tentative.https.html | 26 ++++ .../web-share/share-non-string-manual.https.html | 23 +++ .../tests/web-share/share-null-manual.https.html | 22 +++ .../tests/web-share/share-securecontext.http.html | 17 +++ .../share-sharePromise-internal-slot.https.html | 38 +++++ .../tests/web-share/share-simple-manual.https.html | 28 ++++ .../share-unicode-strings-manual.https.html | 25 ++++ ...share-unicode-strings-nonutf8-manual.https.html | 27 ++++ .../web-share/share-url-empty-manual.https.html | 18 +++ .../web-share/share-url-encoding-manual.https.html | 22 +++ .../tests/web-share/share-url-invalid.https.html | 76 ++++++++++ .../web-share/share-url-noscheme-manual.https.html | 19 +++ .../web-share/share-url-pathonly-manual.https.html | 19 +++ .../web-share/share-url-relative-manual.https.html | 20 +++ .../share-without-user-gesture.https.html | 19 +++ .../tests/web-share/test-fully-active.https.html | 77 ++++++++++ 34 files changed, 1218 insertions(+) create mode 100644 testing/web-platform/tests/web-share/META.yml create mode 100644 testing/web-platform/tests/web-share/canShare-files.https.html create mode 100644 testing/web-platform/tests/web-share/canShare-insecure.http.html create mode 100644 testing/web-platform/tests/web-share/canShare.https.html create mode 100644 testing/web-platform/tests/web-share/disabled-by-permissions-policy-cross-origin.https.sub.html create mode 100644 testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html create mode 100644 testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html.headers create mode 100644 testing/web-platform/tests/web-share/feature-policy-listed.tentative.html create mode 100644 testing/web-platform/tests/web-share/idlharness.https.window.js create mode 100644 testing/web-platform/tests/web-share/resources/blank.html create mode 100644 testing/web-platform/tests/web-share/resources/manual-helper.js create mode 100644 testing/web-platform/tests/web-share/resources/post-message.html create mode 100644 testing/web-platform/tests/web-share/share-cancel-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-consume-activation.https.html create mode 100644 testing/web-platform/tests/web-share/share-empty.https.html create mode 100644 testing/web-platform/tests/web-share/share-extra-argument-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-extra-field-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-files-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-image-manual.tentative.https.html create mode 100644 testing/web-platform/tests/web-share/share-non-string-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-null-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-securecontext.http.html create mode 100644 testing/web-platform/tests/web-share/share-sharePromise-internal-slot.https.html create mode 100644 testing/web-platform/tests/web-share/share-simple-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-unicode-strings-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-unicode-strings-nonutf8-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-empty-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-encoding-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-invalid.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-noscheme-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-pathonly-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-url-relative-manual.https.html create mode 100644 testing/web-platform/tests/web-share/share-without-user-gesture.https.html create mode 100644 testing/web-platform/tests/web-share/test-fully-active.https.html (limited to 'testing/web-platform/tests/web-share') diff --git a/testing/web-platform/tests/web-share/META.yml b/testing/web-platform/tests/web-share/META.yml new file mode 100644 index 0000000000..d2eccca6f4 --- /dev/null +++ b/testing/web-platform/tests/web-share/META.yml @@ -0,0 +1,5 @@ +spec: https://w3c.github.io/web-share/ +suggested_reviewers: + - ewilligers + - mgiuca + - marcoscaceres diff --git a/testing/web-platform/tests/web-share/canShare-files.https.html b/testing/web-platform/tests/web-share/canShare-files.https.html new file mode 100644 index 0000000000..2c2f2ff969 --- /dev/null +++ b/testing/web-platform/tests/web-share/canShare-files.https.html @@ -0,0 +1,40 @@ + + + + + WebShare Test: canShare with files + + + + + + + diff --git a/testing/web-platform/tests/web-share/canShare-insecure.http.html b/testing/web-platform/tests/web-share/canShare-insecure.http.html new file mode 100644 index 0000000000..ce81c7c0c8 --- /dev/null +++ b/testing/web-platform/tests/web-share/canShare-insecure.http.html @@ -0,0 +1,16 @@ + + + + + WebShare Test: canShare from non-secure context + + + + + + + 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 @@ + + + + + WebShare Test: canShare method tests + + + + + + + diff --git a/testing/web-platform/tests/web-share/disabled-by-permissions-policy-cross-origin.https.sub.html b/testing/web-platform/tests/web-share/disabled-by-permissions-policy-cross-origin.https.sub.html new file mode 100644 index 0000000000..773da84c0c --- /dev/null +++ b/testing/web-platform/tests/web-share/disabled-by-permissions-policy-cross-origin.https.sub.html @@ -0,0 +1,122 @@ + + + + + WebShare Test: is disabled by permissions policy cross-origin + + + + + + + diff --git a/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html b/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html new file mode 100644 index 0000000000..e9ea903965 --- /dev/null +++ b/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html @@ -0,0 +1,27 @@ + + + + + WebShare Test: Can be disabled by permissions policy + + + + + + + + + + diff --git a/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html.headers b/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000000..83f5a343fa --- /dev/null +++ b/testing/web-platform/tests/web-share/disabled-by-permissions-policy.https.sub.html.headers @@ -0,0 +1 @@ +Permissions-Policy: web-share=() diff --git a/testing/web-platform/tests/web-share/feature-policy-listed.tentative.html b/testing/web-platform/tests/web-share/feature-policy-listed.tentative.html new file mode 100644 index 0000000000..8f709e68e7 --- /dev/null +++ b/testing/web-platform/tests/web-share/feature-policy-listed.tentative.html @@ -0,0 +1,35 @@ + + + + + WebShare Test: policy is listed + + + + + + + + diff --git a/testing/web-platform/tests/web-share/idlharness.https.window.js b/testing/web-platform/tests/web-share/idlharness.https.window.js new file mode 100644 index 0000000000..fbe59864af --- /dev/null +++ b/testing/web-platform/tests/web-share/idlharness.https.window.js @@ -0,0 +1,17 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: timeout=long + +// https://w3c.github.io/web-share/ + +'use strict'; + +idl_test( + ['web-share'], + ['html'], + idl_array => { + idl_array.add_objects({ + Navigator: ['navigator'] + }); + } +); diff --git a/testing/web-platform/tests/web-share/resources/blank.html b/testing/web-platform/tests/web-share/resources/blank.html new file mode 100644 index 0000000000..84f43b333a --- /dev/null +++ b/testing/web-platform/tests/web-share/resources/blank.html @@ -0,0 +1,2 @@ + + diff --git a/testing/web-platform/tests/web-share/resources/manual-helper.js b/testing/web-platform/tests/web-share/resources/manual-helper.js new file mode 100644 index 0000000000..15bb17936e --- /dev/null +++ b/testing/web-platform/tests/web-share/resources/manual-helper.js @@ -0,0 +1,100 @@ +// Internal function. Returns [instruction, list] DOM elements. +function setupManualShareTestCommon() { + const div = document.createElement('div'); + document.body.appendChild(div); + + const instruction = document.createElement('div'); + instruction.id = 'instruction'; + div.appendChild(instruction); + + const shareButton = document.createElement('input'); + shareButton.id = 'share_button'; + shareButton.value = 'Share button'; + shareButton.type = 'button'; + div.appendChild(shareButton); + + let heading = document.createElement('h2'); + heading.innerText = 'Instructions:'; + instruction.appendChild(heading); + let list = document.createElement('ol'); + instruction.appendChild(list); + let item = document.createElement('li'); + list.appendChild(item); + item.innerText = 'Click the Share button.'; + + return [instruction, list]; +} + +// Sets up the page for running manual tests. Automatically creates the +// instructions (based on the parameters) and the share button. +function setupManualShareTest(expected_share_data) { + const {title, text, url, files} = expected_share_data; + let [instruction, list] = setupManualShareTestCommon(); + let item = document.createElement('li'); + list.appendChild(item); + item.innerText = 'Choose a valid share target.'; + + heading = document.createElement('h2'); + heading.innerText = 'Pass the test iff the target app received:'; + instruction.appendChild(heading); + + list = document.createElement('ul'); + instruction.appendChild(list); + + item = document.createElement('li'); + list.appendChild(item); + item.innerText = `title = "${title}"`; + item = document.createElement('li'); + list.appendChild(item); + item.innerText = `text = "${text}"`; + item = document.createElement('li'); + list.appendChild(item); + item.innerText = `url = "${url}"`; + if (files) { + item = document.createElement('li'); + list.appendChild(item); + item.innerText = `files = ${files.length} file(s)`; + for (let file of files) { + const div = document.createElement('div'); + if (file.type.startsWith('text/')) { + const reader = new FileReader(); + reader.onload = () => { + div.textContent = reader.result; + }; + reader.readAsText(file); + } else if (file.type.startsWith('image/')) { + const image = document.createElement('img'); + image.src = URL.createObjectURL(file); + image.alt = file.name; + div.appendChild(image); + } + item.appendChild(div); + } + } +} + +function setupManualShareTestRequiringCancellation() { + const [instruction, list] = setupManualShareTestCommon(); + const item = document.createElement('li'); + list.appendChild(item); + item.innerText = 'Cancel the share dialog.'; +} + +// Returns a promise. When the user clicks the button, calls +// |click_handler| and resolves the promise with the result. +function callWhenButtonClicked(click_handler) { + return new Promise((resolve, reject) => { + document.querySelector('#share_button').onclick = () => { + try { + const result = click_handler(); + resolve(result); + } catch (e) { + reject(e); + } + }; + }); +} + +function getAbsoluteUrl(url) { + return new URL(url, document.baseURI).toString(); +} diff --git a/testing/web-platform/tests/web-share/resources/post-message.html b/testing/web-platform/tests/web-share/resources/post-message.html new file mode 100644 index 0000000000..30134e2901 --- /dev/null +++ b/testing/web-platform/tests/web-share/resources/post-message.html @@ -0,0 +1,35 @@ + + + + + + diff --git a/testing/web-platform/tests/web-share/share-cancel-manual.https.html b/testing/web-platform/tests/web-share/share-cancel-manual.https.html new file mode 100644 index 0000000000..e27d1975be --- /dev/null +++ b/testing/web-platform/tests/web-share/share-cancel-manual.https.html @@ -0,0 +1,24 @@ + + + + + WebShare Test: Share cancelled by user + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-consume-activation.https.html b/testing/web-platform/tests/web-share/share-consume-activation.https.html new file mode 100644 index 0000000000..301469f83d --- /dev/null +++ b/testing/web-platform/tests/web-share/share-consume-activation.https.html @@ -0,0 +1,33 @@ + + + + + WebShare Test: consume user activation + + + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-empty.https.html b/testing/web-platform/tests/web-share/share-empty.https.html new file mode 100644 index 0000000000..0bca2f2960 --- /dev/null +++ b/testing/web-platform/tests/web-share/share-empty.https.html @@ -0,0 +1,54 @@ + + + + + WebShare Test: Share no known fields + + + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-extra-argument-manual.https.html b/testing/web-platform/tests/web-share/share-extra-argument-manual.https.html new file mode 100644 index 0000000000..47ef7fa115 --- /dev/null +++ b/testing/web-platform/tests/web-share/share-extra-argument-manual.https.html @@ -0,0 +1,21 @@ + + + + + WebShare Test: Surplus arguments ignored + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-extra-field-manual.https.html b/testing/web-platform/tests/web-share/share-extra-field-manual.https.html new file mode 100644 index 0000000000..8b479bb02b --- /dev/null +++ b/testing/web-platform/tests/web-share/share-extra-field-manual.https.html @@ -0,0 +1,21 @@ + + + + + WebShare Test: Surplus fields ignored + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-files-manual.https.html b/testing/web-platform/tests/web-share/share-files-manual.https.html new file mode 100644 index 0000000000..c3941bb406 --- /dev/null +++ b/testing/web-platform/tests/web-share/share-files-manual.https.html @@ -0,0 +1,30 @@ + + + + + WebShare Test: Share multiple files + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-image-manual.tentative.https.html b/testing/web-platform/tests/web-share/share-image-manual.tentative.https.html new file mode 100644 index 0000000000..48ea4c378c --- /dev/null +++ b/testing/web-platform/tests/web-share/share-image-manual.tentative.https.html @@ -0,0 +1,26 @@ + + + + + WebShare Test: Share single image file + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-non-string-manual.https.html b/testing/web-platform/tests/web-share/share-non-string-manual.https.html new file mode 100644 index 0000000000..b70f8fc23d --- /dev/null +++ b/testing/web-platform/tests/web-share/share-non-string-manual.https.html @@ -0,0 +1,23 @@ + + + + + WebShare Test: Share non-string types (test implicit conversion) + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-null-manual.https.html b/testing/web-platform/tests/web-share/share-null-manual.https.html new file mode 100644 index 0000000000..4c74225cbe --- /dev/null +++ b/testing/web-platform/tests/web-share/share-null-manual.https.html @@ -0,0 +1,22 @@ + + + + + WebShare Test: Share null and undefined values + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-securecontext.http.html b/testing/web-platform/tests/web-share/share-securecontext.http.html new file mode 100644 index 0000000000..6344330c6b --- /dev/null +++ b/testing/web-platform/tests/web-share/share-securecontext.http.html @@ -0,0 +1,17 @@ + + + + + WebShare Test: Share from non-secure context + + + + + + + + diff --git a/testing/web-platform/tests/web-share/share-sharePromise-internal-slot.https.html b/testing/web-platform/tests/web-share/share-sharePromise-internal-slot.https.html new file mode 100644 index 0000000000..eb8bf7e4c7 --- /dev/null +++ b/testing/web-platform/tests/web-share/share-sharePromise-internal-slot.https.html @@ -0,0 +1,38 @@ + + + + + + WebShare Test: only one share at a time + + + + + + +