OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
dominicc (has gone to gerrit)
2015/02/09 07:00:58
Should these tests be in ServiceWorker? Push Notif
Michael van Ouwerkerk
2015/02/09 10:44:24
These tests don't appear to exercise the push part
mlamouri (slow - plz ping)
2015/02/11 10:42:06
This test is testing WaitUntilObserver behaviour,
| |
2 <title>Service Worker: notificationclick can focus WindowClient</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="resources/test-helpers.js"></script> | |
6 <script> | |
7 if (window.testRunner) | |
dominicc (has gone to gerrit)
2015/02/09 07:00:58
If these tests are in Service Worker, tests that u
mlamouri (slow - plz ping)
2015/02/11 10:42:06
I wasn't aware of that directory. Will do.
| |
8 testRunner.grantWebNotificationPermission(location.origin, true); | |
9 | |
10 var t = async_test('notificationclick can focus WindowClient'); | |
11 t.step(function() { | |
12 var scope = 'resources/blank.html' | |
13 service_worker_unregister_and_register( | |
14 t, 'resources/notificationclick-can-focus.js', scope) | |
15 .then(function(registration) { | |
16 return wait_for_state(t, registration.installing, 'activated'); | |
17 }) | |
18 .then(function() { return with_iframe(scope); }) | |
19 .then(function(frame) { | |
20 var w = frame.contentWindow; | |
21 w.onmessage = t.step_func(onMessage); | |
22 w.navigator.serviceWorker.controller.postMessage('start'); | |
23 }) | |
24 .catch(unreached_rejection(t)); | |
25 | |
26 var result = []; | |
27 var expected = ['focus() outside of a Notification click event failed', | |
28 'focus() in Notification click event succeeded', | |
29 'focus() called twice failed', | |
30 'focus() in notificationclick outside of waitUntil but in st ack succeeded', | |
31 'focus() in notificationclick outside of waitUntil not in st ack failed', | |
32 'focus() in notificationclick\'s waitUntil suceeded', | |
33 'focus() called twice failed', | |
34 'focus() failed after timeout', | |
35 'focus() failed because a window was opened before']; | |
36 | |
37 function onMessage(e) { | |
38 var message = e.data; | |
39 | |
40 if (typeof(message) === 'object') { | |
41 if (message.type !== 'click') | |
42 return; | |
43 if (window.testRunner) | |
44 testRunner.simulateWebNotificationClick(message.title); | |
45 return; | |
46 } | |
47 | |
48 if (message === 'quit') { | |
49 assert_array_equals(result, expected, | |
50 'Worker should post back expected messages.'); | |
51 service_worker_unregister_and_done(t, scope); | |
52 } else { | |
53 result.push(message); | |
54 } | |
55 } | |
56 }); | |
57 </script> | |
OLD | NEW |