From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/notifications/META.yml | 3 + .../notifications/body-basic-manual.https.html | 28 +++++++++ .../notifications/body-empty-manual.https.html | 31 ++++++++++ testing/web-platform/tests/notifications/common.js | 48 ++++++++++++++++ .../notifications/constructor-basic.https.html | 21 +++++++ .../notifications/constructor-invalid.https.html | 19 +++++++ .../notifications/constructor-non-secure.html | 13 +++++ .../notifications/event-onclick-manual.https.html | 25 ++++++++ .../tests/notifications/event-onclose.https.html | 26 +++++++++ .../event-onerror-default-manual.https.html | 27 +++++++++ .../event-onerror-denied-manual.https.html | 26 +++++++++ .../tests/notifications/event-onshow.https.html | 25 ++++++++ .../tests/notifications/historical.any.js | 3 + .../notifications/icon-basic-manual.https.html | 28 +++++++++ .../notifications/icon-empty-manual.https.html | 27 +++++++++ .../tests/notifications/idlharness.https.any.js | 31 ++++++++++ .../tests/notifications/instance.https.html | 63 +++++++++++++++++++++ .../tests/notifications/lang.https.html | 63 +++++++++++++++++++++ .../tests/notifications/permission.html | 14 +++++ .../notifications/permissions-non-secure.html | 16 ++++++ .../requestPermission-denied-manual.https.html | 22 +++++++ .../requestPermission-granted-manual.https.html | 18 ++++++ .../tests/notifications/resources/icon.png | Bin 0 -> 1540 bytes .../notifications/resources/shownotification-sw.js | 27 +++++++++ .../shownotification-resolve-manual.https.html | 52 +++++++++++++++++ .../notifications/tag-different-manual.https.html | 37 ++++++++++++ .../tests/notifications/tag-same-manual.https.html | 37 ++++++++++++ 27 files changed, 730 insertions(+) create mode 100644 testing/web-platform/tests/notifications/META.yml create mode 100644 testing/web-platform/tests/notifications/body-basic-manual.https.html create mode 100644 testing/web-platform/tests/notifications/body-empty-manual.https.html create mode 100644 testing/web-platform/tests/notifications/common.js create mode 100644 testing/web-platform/tests/notifications/constructor-basic.https.html create mode 100644 testing/web-platform/tests/notifications/constructor-invalid.https.html create mode 100644 testing/web-platform/tests/notifications/constructor-non-secure.html create mode 100644 testing/web-platform/tests/notifications/event-onclick-manual.https.html create mode 100644 testing/web-platform/tests/notifications/event-onclose.https.html create mode 100644 testing/web-platform/tests/notifications/event-onerror-default-manual.https.html create mode 100644 testing/web-platform/tests/notifications/event-onerror-denied-manual.https.html create mode 100644 testing/web-platform/tests/notifications/event-onshow.https.html create mode 100644 testing/web-platform/tests/notifications/historical.any.js create mode 100644 testing/web-platform/tests/notifications/icon-basic-manual.https.html create mode 100644 testing/web-platform/tests/notifications/icon-empty-manual.https.html create mode 100644 testing/web-platform/tests/notifications/idlharness.https.any.js create mode 100644 testing/web-platform/tests/notifications/instance.https.html create mode 100644 testing/web-platform/tests/notifications/lang.https.html create mode 100644 testing/web-platform/tests/notifications/permission.html create mode 100644 testing/web-platform/tests/notifications/permissions-non-secure.html create mode 100644 testing/web-platform/tests/notifications/requestPermission-denied-manual.https.html create mode 100644 testing/web-platform/tests/notifications/requestPermission-granted-manual.https.html create mode 100644 testing/web-platform/tests/notifications/resources/icon.png create mode 100644 testing/web-platform/tests/notifications/resources/shownotification-sw.js create mode 100644 testing/web-platform/tests/notifications/shownotification-resolve-manual.https.html create mode 100644 testing/web-platform/tests/notifications/tag-different-manual.https.html create mode 100644 testing/web-platform/tests/notifications/tag-same-manual.https.html (limited to 'testing/web-platform/tests/notifications') diff --git a/testing/web-platform/tests/notifications/META.yml b/testing/web-platform/tests/notifications/META.yml new file mode 100644 index 0000000000..0daa86e6f4 --- /dev/null +++ b/testing/web-platform/tests/notifications/META.yml @@ -0,0 +1,3 @@ +spec: https://notifications.spec.whatwg.org/ +suggested_reviewers: + - sideshowbarker diff --git a/testing/web-platform/tests/notifications/body-basic-manual.https.html b/testing/web-platform/tests/notifications/body-basic-manual.https.html new file mode 100644 index 0000000000..a479917aee --- /dev/null +++ b/testing/web-platform/tests/notifications/body-basic-manual.https.html @@ -0,0 +1,28 @@ + + +Notification.body (basic) + + + + + +
+ diff --git a/testing/web-platform/tests/notifications/body-empty-manual.https.html b/testing/web-platform/tests/notifications/body-empty-manual.https.html new file mode 100644 index 0000000000..a94f08e1c5 --- /dev/null +++ b/testing/web-platform/tests/notifications/body-empty-manual.https.html @@ -0,0 +1,31 @@ + + +Notification.body (empty string) + + + + + +
+ diff --git a/testing/web-platform/tests/notifications/common.js b/testing/web-platform/tests/notifications/common.js new file mode 100644 index 0000000000..ecfa0e3c2d --- /dev/null +++ b/testing/web-platform/tests/notifications/common.js @@ -0,0 +1,48 @@ +function createPassFail(condition, test, cleanup, cleanupParam) { + var div = document.querySelector("#passfail") + var para = document.createElement("p") + var pass = document.createElement("button") + var fail = document.createElement("button") + var style = "font-family: monospace" + para.innerHTML = condition + + ', press the PASS button;' + + ' otherwise press the FAIL button.', + pass.innerHTML = "PASS" + fail.innerHTML = "FAIL" + pass.setAttribute("style", style) + fail.setAttribute("style", style) + pass.addEventListener("click", function () { + clearPassFail() + cleanup(cleanupParam) + test.done() + }, false) + fail.addEventListener("click", function () { + clearPassFail() + cleanup(cleanupParam) + test.force_timeout() + test.set_status(test.FAIL) + test.done() + }, false) + document.body.appendChild(div) + div.appendChild(para) + div.appendChild(pass) + div.appendChild(fail) +} +function clearPassFail() { + document.querySelector("#passfail").innerHTML = "" +} +function closeNotifications(notifications) { + for (var i=0; i < notifications.length; i++) { + notifications[i].close() + } +} +function hasNotificationPermission() { + Notification.requestPermission() + if (Notification.permission != "granted") { + alert("TEST NOT RUN. Change your browser settings so that" + + " notifications for this origin are allowed, and then re-run" + + " this test.") + return false + } + return true +} diff --git a/testing/web-platform/tests/notifications/constructor-basic.https.html b/testing/web-platform/tests/notifications/constructor-basic.https.html new file mode 100644 index 0000000000..a36a8ce304 --- /dev/null +++ b/testing/web-platform/tests/notifications/constructor-basic.https.html @@ -0,0 +1,21 @@ + + +Notification constructor (basic) + + + + + diff --git a/testing/web-platform/tests/notifications/constructor-invalid.https.html b/testing/web-platform/tests/notifications/constructor-invalid.https.html new file mode 100644 index 0000000000..1995ccc4f5 --- /dev/null +++ b/testing/web-platform/tests/notifications/constructor-invalid.https.html @@ -0,0 +1,19 @@ + + +Notification constructor (invalid) + + + + + diff --git a/testing/web-platform/tests/notifications/constructor-non-secure.html b/testing/web-platform/tests/notifications/constructor-non-secure.html new file mode 100644 index 0000000000..df1f74a71f --- /dev/null +++ b/testing/web-platform/tests/notifications/constructor-non-secure.html @@ -0,0 +1,13 @@ + + +Notification constructor (basic) on a non-secure connection + + + diff --git a/testing/web-platform/tests/notifications/event-onclick-manual.https.html b/testing/web-platform/tests/notifications/event-onclick-manual.https.html new file mode 100644 index 0000000000..0d48d06ae8 --- /dev/null +++ b/testing/web-platform/tests/notifications/event-onclick-manual.https.html @@ -0,0 +1,25 @@ + + +Notification.onclick (basic) + + + + + diff --git a/testing/web-platform/tests/notifications/event-onclose.https.html b/testing/web-platform/tests/notifications/event-onclose.https.html new file mode 100644 index 0000000000..aee3213698 --- /dev/null +++ b/testing/web-platform/tests/notifications/event-onclose.https.html @@ -0,0 +1,26 @@ + + +Notification.onclose (basic) + + + + diff --git a/testing/web-platform/tests/notifications/event-onerror-default-manual.https.html b/testing/web-platform/tests/notifications/event-onerror-default-manual.https.html new file mode 100644 index 0000000000..4a50de7366 --- /dev/null +++ b/testing/web-platform/tests/notifications/event-onerror-default-manual.https.html @@ -0,0 +1,27 @@ + + +Notification.onerror (permission=default) + + + + diff --git a/testing/web-platform/tests/notifications/event-onerror-denied-manual.https.html b/testing/web-platform/tests/notifications/event-onerror-denied-manual.https.html new file mode 100644 index 0000000000..b90fb38cc1 --- /dev/null +++ b/testing/web-platform/tests/notifications/event-onerror-denied-manual.https.html @@ -0,0 +1,26 @@ + + +Notification.onerror (permission=denied) + + + + diff --git a/testing/web-platform/tests/notifications/event-onshow.https.html b/testing/web-platform/tests/notifications/event-onshow.https.html new file mode 100644 index 0000000000..7cc2be9de5 --- /dev/null +++ b/testing/web-platform/tests/notifications/event-onshow.https.html @@ -0,0 +1,25 @@ + + +Notification.onshow (basic) + + + + + diff --git a/testing/web-platform/tests/notifications/historical.any.js b/testing/web-platform/tests/notifications/historical.any.js new file mode 100644 index 0000000000..fe5f3e9059 --- /dev/null +++ b/testing/web-platform/tests/notifications/historical.any.js @@ -0,0 +1,3 @@ +test(() => { + assert_equals(Notification.get, undefined); +}, "Notification.get is obsolete"); diff --git a/testing/web-platform/tests/notifications/icon-basic-manual.https.html b/testing/web-platform/tests/notifications/icon-basic-manual.https.html new file mode 100644 index 0000000000..32e8e0bbbd --- /dev/null +++ b/testing/web-platform/tests/notifications/icon-basic-manual.https.html @@ -0,0 +1,28 @@ + + +Notification.icon (basic) + + + + + +
+ diff --git a/testing/web-platform/tests/notifications/icon-empty-manual.https.html b/testing/web-platform/tests/notifications/icon-empty-manual.https.html new file mode 100644 index 0000000000..a4b288fa59 --- /dev/null +++ b/testing/web-platform/tests/notifications/icon-empty-manual.https.html @@ -0,0 +1,27 @@ + + +Notification.icon (empty string) + + + + + +
+ diff --git a/testing/web-platform/tests/notifications/idlharness.https.any.js b/testing/web-platform/tests/notifications/idlharness.https.any.js new file mode 100644 index 0000000000..e3afe2c219 --- /dev/null +++ b/testing/web-platform/tests/notifications/idlharness.https.any.js @@ -0,0 +1,31 @@ +// META: global=window,worker +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +'use strict'; + +// https://notifications.spec.whatwg.org/ + +idl_test( + ['notifications'], + ['service-workers', 'hr-time', 'html', 'dom'], + idl_array => { + if (self.ServiceWorkerGlobalScope) { + idl_array.add_objects({ + ServiceWorkerGlobalScope: ['self'], + }); + // NotificationEvent could be tested here, but the constructor requires + // a Notification instance which cannot be created in a service worker, + // see below. + } else { + // While the Notification interface is exposed in service workers, the + // constructor (https://notifications.spec.whatwg.org/#dom-notification-notification) + // is defined to throw a TypeError. Therefore, we only add the object in + // the other scopes. + idl_array.add_objects({ + Notification: ['notification'], + }); + self.notification = new Notification('title'); + } + } +); diff --git a/testing/web-platform/tests/notifications/instance.https.html b/testing/web-platform/tests/notifications/instance.https.html new file mode 100644 index 0000000000..c0ebe7e699 --- /dev/null +++ b/testing/web-platform/tests/notifications/instance.https.html @@ -0,0 +1,63 @@ + + +Notification instance basic tests + + + diff --git a/testing/web-platform/tests/notifications/lang.https.html b/testing/web-platform/tests/notifications/lang.https.html new file mode 100644 index 0000000000..be1795c8c9 --- /dev/null +++ b/testing/web-platform/tests/notifications/lang.https.html @@ -0,0 +1,63 @@ + + +Notification.lang + + + + diff --git a/testing/web-platform/tests/notifications/permission.html b/testing/web-platform/tests/notifications/permission.html new file mode 100644 index 0000000000..d8b201e42e --- /dev/null +++ b/testing/web-platform/tests/notifications/permission.html @@ -0,0 +1,14 @@ + + +Notification.permission (basic) + + + + + diff --git a/testing/web-platform/tests/notifications/permissions-non-secure.html b/testing/web-platform/tests/notifications/permissions-non-secure.html new file mode 100644 index 0000000000..0f4724c9b6 --- /dev/null +++ b/testing/web-platform/tests/notifications/permissions-non-secure.html @@ -0,0 +1,16 @@ + + +Notification permissions should be denied in non-secure contexts + + + diff --git a/testing/web-platform/tests/notifications/requestPermission-denied-manual.https.html b/testing/web-platform/tests/notifications/requestPermission-denied-manual.https.html new file mode 100644 index 0000000000..a7ec052dba --- /dev/null +++ b/testing/web-platform/tests/notifications/requestPermission-denied-manual.https.html @@ -0,0 +1,22 @@ + + +Notification.requestPermission (permission=denied) + + + + + diff --git a/testing/web-platform/tests/notifications/requestPermission-granted-manual.https.html b/testing/web-platform/tests/notifications/requestPermission-granted-manual.https.html new file mode 100644 index 0000000000..970f4e3cbc --- /dev/null +++ b/testing/web-platform/tests/notifications/requestPermission-granted-manual.https.html @@ -0,0 +1,18 @@ + + +Notification.requestPermission (permission=granted) + + + + + + diff --git a/testing/web-platform/tests/notifications/resources/icon.png b/testing/web-platform/tests/notifications/resources/icon.png new file mode 100644 index 0000000000..ee919cd512 Binary files /dev/null and b/testing/web-platform/tests/notifications/resources/icon.png differ diff --git a/testing/web-platform/tests/notifications/resources/shownotification-sw.js b/testing/web-platform/tests/notifications/resources/shownotification-sw.js new file mode 100644 index 0000000000..63a1569460 --- /dev/null +++ b/testing/web-platform/tests/notifications/resources/shownotification-sw.js @@ -0,0 +1,27 @@ +self.onmessage = event => { + // Checking for a particular value, so more tests can be added in future. + if (event.data !== 'test-shownotification') return; + + // Random number, so we can identify the notification we create. + const random = Math.random().toString(); + const start = Date.now(); + + event.waitUntil( + self.registration.showNotification('test', { + tag: random, + // ?pipe=trickle(d2) delays the icon request by two seconds + icon: 'icon.png?pipe=trickle(d2)' + }).then(() => { + const resolveDuration = Date.now() - start; + + return self.registration.getNotifications().then(notifications => { + event.source.postMessage({ + type: 'notification-data', + resolveDuration, + // Check if our notification is in notifications + notificationReturned: notifications.some(n => n.tag == random) + }); + }); + }) + ); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/notifications/shownotification-resolve-manual.https.html b/testing/web-platform/tests/notifications/shownotification-resolve-manual.https.html new file mode 100644 index 0000000000..a73b11d100 --- /dev/null +++ b/testing/web-platform/tests/notifications/shownotification-resolve-manual.https.html @@ -0,0 +1,52 @@ + + + + + + diff --git a/testing/web-platform/tests/notifications/tag-different-manual.https.html b/testing/web-platform/tests/notifications/tag-different-manual.https.html new file mode 100644 index 0000000000..e463e97670 --- /dev/null +++ b/testing/web-platform/tests/notifications/tag-different-manual.https.html @@ -0,0 +1,37 @@ + + +Notification.tag (two tags with different values) + + + + + +
+ diff --git a/testing/web-platform/tests/notifications/tag-same-manual.https.html b/testing/web-platform/tests/notifications/tag-same-manual.https.html new file mode 100644 index 0000000000..4454944c53 --- /dev/null +++ b/testing/web-platform/tests/notifications/tag-same-manual.https.html @@ -0,0 +1,37 @@ + + +Notification.tag (two tags with same value) + + + + + +
+ -- cgit v1.2.3