Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow-404.html

Issue 933153003: Add some image loading layout tests for Web Notifications. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: ServiceWorkerRegistration.showNotification().</title> 4 <title>Notifications: Showing a notification with an image that 404s after a slow redirect.</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="../resources/testharnessreport.js"></script>
7 <script src="../serviceworker/resources/test-helpers.js"></script> 7 <script src="../serviceworker/resources/test-helpers.js"></script>
8 <script src="resources/test-helpers.js"></script> 8 <script src="resources/test-helpers.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 // Tests that the showNotification() function when used in a Service Worke r 12 // Tests that showing a notification with an image that creates a 404 resp onse
13 // rejects when no permission has been granted. This test requires the tes t runner. 13 // after a slow redirect works properly, and does not block the actual dis play of it.
14 14
15 async_test(function(test) { 15 async_test(function(test) {
16 var scope = 'resources/scope/serviceworkerregistration-service-worker- click', 16 var scope = 'resources/scope/' + location.pathname,
17 script = 'resources/instrumentation-service-worker.js'; 17 script = 'resources/instrumentation-service-worker.js';
18 18
19 testRunner.grantWebNotificationPermission(location.origin, false); 19 testRunner.grantWebNotificationPermission(location.origin, true);
20 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 20 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) {
21 // (1) Tell the Service Worker to display a Web Notification. 21 // (1) Display a Web Notification through the Service Worker with
22 workerInfo.port.postMessage({ 22 // an image that 404s after a 200ms redirect to load.
23 info.port.postMessage({
23 command: 'show', 24 command: 'show',
24 25
25 title: 'My Notification', 26 title: 'My Notification',
26 options: { body: 'Hello, world!' } 27 options: { body: 'Hello, world!',
28 icon: '/resources/slow-image.php?redirect_name=not_ there.png&mimeType=image/png&sleep=200' }
27 }); 29 });
28 30
29 workerInfo.port.addEventListener('message', function(event) { 31 info.port.addEventListener('message', function(event) {
30 if (typeof event.data != 'object' || !event.data.command) { 32 if (typeof event.data != 'object' || !event.data.command) {
31 assert_unreached('Invalid message from the Service Worker. '); 33 assert_unreached('Invalid message from the Service Worker. ');
32 return; 34 return;
33 } 35 }
34 36
35 // (2) Listen for confirmation from the Service Worker that th e 37 // (2) Listen for confirmation from the Service Worker that th e
36 // notification could not be displayed because of a permission error. 38 // notification could be displayed as expected.
37 assert_equals(event.data.command, 'show'); 39 assert_equals(event.data.command, 'show');
38 40 assert_true(event.data.success);
39 assert_false(event.data.success);
40 assert_equals(event.data.message, 'No notification permission has been granted for this origin.');
41 41
42 test.done(); 42 test.done();
43 }); 43 });
44 }).catch(unreached_rejection(test)); 44 }).catch(unreached_rejection(test));
45 45
46 }, 'showNotification() must reject if no Web Notification permission has b een granted.'); 46 }, 'Displaying a notification with an image that 404s after a slow redirec t still resolves the promise.');
47 </script> 47 </script>
48 </body> 48 </body>
49 </html> 49 </html>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-image-slow.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698