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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-openwindow-crash.html

Issue 1644063002: Simplify TestRunnerBindings::SimulateWebNotificationClick param handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: Calling openWindow() in a Service Worker should not cr ash.</title> 4 <title>Notifications: Calling openWindow() in a Service Worker should not cr ash.</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 calling openWindow() in a Service Worker in response to a 12 // Tests that calling openWindow() in a Service Worker in response to a
13 // notificationclick event does not cause the browser to crash. 13 // notificationclick event does not cause the browser to crash.
14 14
15 async_test(function(test) { 15 async_test(function(test) {
16 var scope = 'resources/scope/' + location.pathname, 16 var scope = 'resources/scope/' + location.pathname,
17 script = 'resources/instrumentation-service-worker.js', 17 script = 'resources/instrumentation-service-worker.js',
18 workerInfo = null; 18 workerInfo = null;
19 19
20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); 20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { 21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) {
22 workerInfo = info; 22 workerInfo = info;
23 23
24 // (1) Display a persistent notification with an OPENWINDOW trigge r. 24 // (1) Display a persistent notification with an OPENWINDOW trigge r.
25 return workerInfo.registration.showNotification(scope, { 25 return workerInfo.registration.showNotification(scope, {
26 body: 'ACTION:OPENWINDOW' 26 body: 'ACTION:OPENWINDOW'
27 }); 27 });
28 }).then(function() { 28 }).then(function() {
29 // (2) Simulate a click on the notification, invokes the Service W orker event. 29 // (2) Simulate a click on the notification, invokes the Service W orker event.
30 testRunner.simulateWebNotificationClick(scope); 30 testRunner.simulateWebNotificationClick(scope, -1 /* action_index */);
31 31
32 workerInfo.port.addEventListener('message', function(event) { 32 workerInfo.port.addEventListener('message', function(event) {
33 if (typeof event.data != 'object' || !event.data.command) { 33 if (typeof event.data != 'object' || !event.data.command) {
34 assert_unreached('Invalid message from the Service Worker. '); 34 assert_unreached('Invalid message from the Service Worker. ');
35 return; 35 return;
36 } 36 }
37 37
38 // (3) Listen for confirmation by the Service Worker that the notificationclick 38 // (3) Listen for confirmation by the Service Worker that the notificationclick
39 // event has been executed successfully. 39 // event has been executed successfully.
40 assert_equals(event.data.command, 'click'); 40 assert_equals(event.data.command, 'click');
41 assert_equals(event.data.notification.title, scope); 41 assert_equals(event.data.notification.title, scope);
42 42
43 test.done(); 43 test.done();
44 }); 44 });
45 }).catch(unreached_rejection(test)); 45 }).catch(unreached_rejection(test));
46 46
47 }, 'Opening a window in a Service Worker should not trigger a DCHECK.'); 47 }, 'Opening a window in a Service Worker should not trigger a DCHECK.');
48 </script> 48 </script>
49 </body> 49 </body>
50 </html> 50 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698