Chromium Code Reviews| Index: LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html |
| diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-no-permission.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html |
| similarity index 52% |
| copy from LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-no-permission.html |
| copy to LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html |
| index 3abbced552d460ab6eb9861f886956ca44775914..69c9e599fb0026b1a1d9875054594182289f01be 100644 |
| --- a/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-no-permission.html |
| +++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html |
| @@ -1,7 +1,7 @@ |
| <!doctype html> |
| <html> |
| <head> |
| - <title>Notifications: ServiceWorkerRegistration.showNotification().</title> |
| + <title>Notifications: Showing a notification with an image that 404s.</title> |
|
Michael van Ouwerkerk
2015/02/19 11:41:46
nit: update title
Peter Beverloo
2015/02/19 12:03:54
Done.
|
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="../serviceworker/resources/test-helpers.js"></script> |
| @@ -9,41 +9,41 @@ |
| </head> |
| <body> |
| <script> |
| - // Tests that the showNotification() function when used in a Service Worker |
| - // rejects when no permission has been granted. This test requires the test runner. |
| + // Tests that showing a notification with an image that takes a non-trivial |
| + // time to load still ends up resolving the promise. |
| async_test(function(test) { |
| - var scope = 'resources/scope/serviceworkerregistration-service-worker-click', |
| + var scope = 'resources/scope/' + location.pathname, |
| script = 'resources/instrumentation-service-worker.js'; |
| - testRunner.grantWebNotificationPermission(location.origin, false); |
| - getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) { |
| - // (1) Tell the Service Worker to display a Web Notification. |
| - workerInfo.port.postMessage({ |
| + testRunner.grantWebNotificationPermission(location.origin, true); |
| + getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) { |
| + // (1) Display a Web Notification through the Service Worker with |
| + // an image that takes 200ms to load. |
| + info.port.postMessage({ |
| command: 'show', |
| title: 'My Notification', |
| - options: { body: 'Hello, world!' } |
| + options: { body: 'Hello, world!', |
| + icon: '/resources/slow-image.php?redirect_name=square100.png&mimeType=image/png&sleep=200' } |
|
Michael van Ouwerkerk
2015/02/19 11:41:46
What happens when the mime type is wrong?
Peter Beverloo
2015/02/19 12:03:54
Nothing spectacular. We try to decode the image an
|
| }); |
| - workerInfo.port.addEventListener('message', function(event) { |
| + info.port.addEventListener('message', function(event) { |
| if (typeof event.data != 'object' || !event.data.command) { |
| assert_unreached('Invalid message from the Service Worker.'); |
| return; |
| } |
| // (2) Listen for confirmation from the Service Worker that the |
| - // notification could not be displayed because of a permission error. |
| + // notification could be displayed as expected. |
| assert_equals(event.data.command, 'show'); |
| - |
| - assert_false(event.data.success); |
| - assert_equals(event.data.message, 'No notification permission has been granted for this origin.'); |
| + assert_true(event.data.success); |
| test.done(); |
| }); |
| }).catch(unreached_rejection(test)); |
| - }, 'showNotification() must reject if no Web Notification permission has been granted.'); |
| + }, 'Displaying a notification with an image that takes some time to load still resolves the promise.'); |
| </script> |
| </body> |
| </html> |