4 <title>Notifications: Showing a notification with an image that
404s after a slow redirect.
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></script>
7 <script src=
"../serviceworker/resources/test-helpers.js"></script>
8 <script src=
"resources/test-helpers.js"></script>
12 // Tests that showing a notification with an image that creates a 404 response
13 // after a slow redirect works properly, and does not block the actual display of it.
15 async_test(function(test
) {
16 var scope
= 'resources/scope/' + location
.pathname
,
17 script
= 'resources/instrumentation-service-worker.js';
19 testRunner
.setPermission('notifications', 'granted', location
.origin
, location
.origin
);
20 getActiveServiceWorkerWithMessagePort(test
, script
, scope
).then(function(info
) {
21 // (1) Display a Web Notification through the Service Worker with
22 // an image that 404s after a 200ms redirect to load.
23 info
.port
.postMessage({
26 title
: 'My Notification',
27 options
: { body
: 'Hello, world!',
28 icon
: '/resources/slow-image.php?redirect_name=not_there.png&mimeType=image/png&sleep=200' }
31 info
.port
.addEventListener('message', function(event
) {
32 if (typeof event
.data
!= 'object' || !event
.data
.command
) {
33 assert_unreached('Invalid message from the Service Worker.');
37 // (2) Listen for confirmation from the Service Worker that the
38 // notification could be displayed as expected.
39 assert_equals(event
.data
.command
, 'show');
40 assert_true(event
.data
.success
);
44 }).catch(unreached_rejection(test
));
46 }, 'Displaying a notification with an image that 404s after a slow redirect still resolves the promise.');