Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / serviceworker-notificationclick-event-reflection.html
blob2c7283b7ec601a6666f6c67f535dbc4d6894a6d7
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Property 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 notification available in the "notificationclick" event in the
13 // Service Worker accurately reflects the attributes with which the notification
14 // was created (for this test --) in the document.
16 async_test(function(test) {
17 var scope = 'resources/scope/' + location.pathname,
18 script = 'resources/instrumentation-service-worker.js';
20 var options = {
21 title: scope,
22 dir: 'rtl',
23 lang: 'nl-NL',
24 body: 'Hello, world!',
25 tag: 'tag',
26 // FIXME: Relative URLs for the icon attribute currently get reflected as
27 // an absolute URL, which should probably be the given relative URL.
28 icon: 'https://example/icon.png',
29 vibrate: [100, 200, 300],
30 silent: false,
31 requireInteraction: true,
32 data: [
33 { property: 'foobar',
34 string: '\uDFFF\u0000\uDBFF',
35 scalar: true },
36 12.15
38 actions: [{ action: 'one', title: 'Action 1' },
39 { action: 'two', title: 'Action 2' },
40 { action: 'three', title: 'Action 3' }]
43 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
44 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
45 // (1) Tell the Service Worker to display a Web Notification.
46 workerInfo.port.postMessage({
47 command: 'show',
49 title: scope,
50 options: options
51 });
53 workerInfo.port.addEventListener('message', function(event) {
54 if (typeof event.data != 'object' || !event.data.command) {
55 assert_unreached('Invalid message from the Service Worker.');
56 return;
59 // (2) Listen for confirmation from the Service Worker that the
60 // notification's display promise has been resolved.
61 if (event.data.command == 'show') {
62 assert_true(event.data.success, 'The notification must have been displayed.');
63 testRunner.simulateWebNotificationClick(scope);
64 return;
67 // (3) Listen for confirmation from the Service Worker that the
68 // notification has been clicked on. Make sure that all properties
69 // set on the Notification object are as expected.
70 assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
72 options.actions = options.actions.slice(0, Notification.maxActions);
73 Object.keys(options).forEach(function(key) {
74 if (typeof options[key] == 'object')
75 assert_object_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
76 else
77 assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
78 });
80 test.done();
81 });
82 }).catch(unreached_rejection(test));
84 }, 'Clicking on a notification displayed by a Service Worker the notificationclick event.');
85 </script>
86 </body>
87 </html>