| Index: LayoutTests/http/tests/notifications/serviceworkerregistration-document-invalid-language.html
|
| diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-document-invalid-language.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-invalid-language.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..120ba9b91eb68fb349230e14fc610b804b47924f
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-invalid-language.html
|
| @@ -0,0 +1,42 @@
|
| +<!doctype html>
|
| +<html>
|
| + <head>
|
| + <title>Notifications: ServiceWorkerRegistration.showNotification() should validate the syntax of the language tag of a notification.</title>
|
| + <script src="../resources/testharness.js"></script>
|
| + <script src="../resources/testharnessreport.js"></script>
|
| + <script src="../serviceworker/resources/test-helpers.js"></script>
|
| + <script src="resources/test-helpers.js"></script>
|
| + </head>
|
| + <body>
|
| + <script>
|
| + // Tests that the showNotification() function validates the language tag of the
|
| + // notification, by making sure that the tag is empty when an invalid BCP 47
|
| + // language has been supplied on getting the notifications.
|
| +
|
| + async_test(function(test) {
|
| + var scope = 'resources/spec/' + location.pathname,
|
| + script = 'resources/instrumentation-service-worker.js';
|
| +
|
| + testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
|
| +
|
| + var registration = null;
|
| + getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
|
| + registration = info.registration;
|
| +
|
| + // (1) Display a Web Notification from the document.
|
| + return registration.showNotification(scope, {
|
| + lang: 'invalid language'
|
| + });
|
| + }).then(function() {
|
| + return registration.getNotifications();
|
| + }).then(function(notifications) {
|
| + assert_equals(notifications.length, 1);
|
| + assert_equals(notifications[0].lang, '');
|
| +
|
| + test.done();
|
| + }).catch(unreached_rejection(test));
|
| +
|
| + }, 'ServiceWorkerRegistration.showNotification() should validate the syntax of the language tag of a notification.');
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|