Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / permissions / chromium / resources / test-change-event.js
blobb6f027ac03a673b84c8dbb8d293799687dfd354e
1 if (self.importScripts) {
2     importScripts('../../resources/helpers.js');
3     importScripts('testrunner-helpers.js');
5     if (get_current_scope() == 'ServiceWorker')
6         importScripts('../../../serviceworker/resources/worker-testharness.js');
7     else
8         importScripts('../../../resources/testharness.js');
11 async_test(function(t) {
12     setPermission('geolocation', 'granted', location.origin, location.origin).then(t.step_func(function() {
13         navigator.permissions.query({name:'geolocation'}).then(t.step_func(function(p) {
14             assert_equals(p.state, 'granted');
16             p.onchange = t.step_func(function() {
17                 assert_equals(p.state, 'denied');
19                 p.onchange = t.step_func(function() {
20                     assert_unreached('the permission should not change again.');
21                 });
23                 setPermission('geolocation', 'prompt', 'https://example.com', 'https://example.com');
24                 setPermission('geolocation', 'prompt', 'https://example.com', location.origin);
25                 setPermission('geolocation', 'prompt', location.origin, 'https://example.com');
27                 navigator.permissions.query({name:'geolocation'}).then(t.step_func(function(p) {
28                     assert_equals(p.state, 'denied');
29                     t.done();
30                 }));
31             });
33             setPermission('geolocation', 'denied', location.origin, location.origin);
34         }));
35     }));
36 }, 'Testing that the change event is correctly sent. Scope: ' + get_current_scope());
38 done();