Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / serviceworker-notificationclick-event-action-reflection.html
blob590dc519b8e303be86a254eafdb1fae46da5aabe
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Action reflection in the "notificationclick" event.</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 the action property of the "notificationclick" event in the
13 // Service Worker accurately reflects which action was activated, if any.
15 async_test(function(test) {
16 var scope = 'resources/scope/' + location.pathname,
17 script = 'resources/instrumentation-service-worker.js';
19 var options = {
20 actions: []
23 var expectedActions = [];
24 for (var i = 0; i < Notification.maxActions; ++i) {
25 var action = { action: "action" + i, title: "Action " + i };
26 options.actions.push(action);
27 expectedActions.push(action.action);
29 // Expect empty string when main body of notification is activated.
30 expectedActions.push("");
32 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
33 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
34 // (1) Tell the Service Worker to display a Web Notification.
35 workerInfo.port.postMessage({
36 command: 'show',
38 title: scope,
39 options: options
40 });
42 workerInfo.port.addEventListener('message', function(event) {
43 if (typeof event.data != 'object' || !event.data.command) {
44 assert_unreached('Invalid message from the Service Worker.');
45 return;
48 // (2) Listen for confirmation from the Service Worker that the
49 // notification's display promise has been resolved.
50 if (event.data.command == 'show') {
51 assert_true(event.data.success, 'The notification must have been displayed.');
52 for (var i = 0; i < options.actions.length; ++i)
53 testRunner.simulateWebNotificationClick(scope, i);
54 testRunner.simulateWebNotificationClick(scope);
55 return;
58 // (3) Listen for confirmation from the Service Worker that the
59 // notification has been clicked on. Make sure that the action
60 // property set on the NotificationEvent object is as expected.
61 assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
63 assert_equals(event.data.action, expectedActions.shift());
65 if (expectedActions.length === 0)
66 test.done();
67 });
68 }).catch(unreached_rejection(test));
70 }, 'NotificationEvent action property should be reflect which action was clicked.');
71 </script>
72 </body>
73 </html>