Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / serviceworkerregistration-get.html
blobff316e2c89d3b851f07c8f67084f31c89bf1110a
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: ServiceWorkerRegistration.getNotifications().</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 getNotifications() function when used in a document returns
13 // an array of the notifications which were previously displayed using the
14 // same Service Worker registration id.
15 async_test(function(test) {
16 var scope = 'resources/scope/' + location.pathname,
17 script = 'resources/instrumentation-service-worker.js';
19 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
21 var registration = null;
22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
23 registration = workerInfo.registration;
25 return registration.showNotification('Hello, world!', {
26 body: 'First notification'
27 });
28 }).then(function() {
29 return registration.showNotification('Hello again, world!', {
30 body: 'Second notification'
31 });
32 }).then(function() {
33 return registration.getNotifications();
34 }).then(function(notifications) {
35 assert_equals(notifications.length, 2);
37 // We don't want to make any promises about the order of the
38 // returned notifications in |notifications|.
39 var firstIndex = notifications[0].title == 'Hello, world!' ? 0 : 1;
40 var secondIndex = firstIndex ? 0 : 1;
42 assert_equals(notifications[firstIndex].title, 'Hello, world!');
43 assert_equals(notifications[firstIndex].body, 'First notification');
45 assert_equals(notifications[secondIndex].title, 'Hello again, world!');
46 assert_equals(notifications[secondIndex].body, 'Second notification');
48 test.done();
49 }).catch(unreached_rejection(test));
51 }, 'ServiceWorkerRegistration.getNotifications() returns the opened notifications.');
52 </script>
53 </body>
54 </html>