Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/notificationclick-can-focus.js

Issue 896043004: Tests for WaitUntilObserver and focus/openining windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_client_focus_cleanup
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var client = null;
2
3 function initializeClient() {
4 return self.clients.getAll().then(function(clients) {
5 client = clients[0];
6 });
7 }
8
9 function testWithClick() {
10 var notification = new Notification('My Notification');
11 notification.addEventListener('show', function() {
12 client.postMessage('click');
13 });
14
15 notification.addEventListener('click', function() {
16 client.focus().catch(function() {
17 client.postMessage('focus() outside of a notificationclick failed');
18 client.postMessage('quit');
19 });
20 });
21
22 notification.addEventListener('error', function() {
23 client.postMessage('quit');
24 });
25
26 client.postMessage('quit');
27 }
28
29 function testWithNoClick() {
30 client.focus().catch(function() {
31 client.postMessage('focus() outside of a notificationclick failed');
32 testWithClick();
33 });
34 }
35
36 self.onmessage = function(e) {
37 switch(e.data) {
38 case "start":
39 initializeClient().then(testWithNoClick);
40 break;
41 }
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698