Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / notifications / request-permission-promise.html
blob92bd481b24832ecfc5cd233f677f8c91c4d6436c
1 <!doctype html>
2 <html>
3 <head>
4 <title>Notifications: Requesting permission using the Promise return value.</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="../resources/permissions-helper.js"></script>
8 </head>
9 <body>
10 <script>
11 // Tests that Notification.requestPermission() returns a promise that will be
12 // resolved with the current permission level. This test cannot be ran manually
13 // because of the permission shifting going on.
14 promise_test(test => {
15 // Default value in layout tests is "denied".
16 return Notification.requestPermission().then(permission => {
17 assert_equals(permission, 'denied');
19 return PermissionsHelper.setPermission('notifications', 'granted');
20 }).then(function() {
21 return Notification.requestPermission();
22 }).then(permission => {
23 assert_equals(permission, 'granted');
24 });
26 }, 'Requesting permission returns a promise that will be resolved.');
28 // Tests that Notification.requestPermission() still invokes the callback (before
29 // resolving the promise) and that the values are equal. Like the previous test,
30 // this cannot be ran manually.
31 promise_test(test => {
32 var callbackPermission = 'undefined';
34 function permissionCallback(value) {
35 callbackPermission = value;
38 return PermissionsHelper.setPermission('notifications', 'denied').then(function() {
39 return Notification.requestPermission(permissionCallback).then(permission => {
40 assert_equals(permission, 'denied');
41 assert_equals(permission, callbackPermission);
43 return PermissionsHelper.setPermission('notifications', 'granted');
44 }).then(function() {
45 return Notification.requestPermission(permissionCallback);
46 }).then(permission => {
47 assert_equals(permission, 'granted');
48 assert_equals(permission, callbackPermission);
49 });
51 }, 'Requesting permission returns a promise, maintains the callback behaviour.');
52 </script>
53 </body>
54 </html>