Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / serviceworkerregistration-service-worker-image-abort.html
blobd1520e396995c9057ab4146abef02b62118bafc1
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Showing a notification with an image and then abort the load immediately.</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>
9 </head>
10 <body>
11 <script>
12 // Tests that showing a notification with an image that takes 200ms to load, which
13 // is unlikely to succeed because the Service Worker registration will be unregistered
14 // immediately after, does not cause a crash.
16 async_test(function(test) {
17 var scope = 'resources/scope/' + location.pathname,
18 script = 'resources/instrumentation-service-worker.js';
20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
22 // (1) Display a Web Notification through the Service Worker with which
23 // will take 200ms to load, and unregister the Service Worker immediately
24 // after that to abort the in-progress load.
25 info.port.postMessage({
26 command: 'show',
28 title: 'My Notification',
29 options: { body: 'Hello, world!',
30 icon: '/resources/slow-image.php?redirect_name=square100.png&mimeType=image/png&sleep=200' }
31 });
33 return info.registration.unregister().then(function () {
34 test.done();
35 });
36 }).catch(unreached_rejection(test));
38 }, 'Showing a notification with an image and then abort the load immediately.');
39 </script>
40 </body>
41 </html>