Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/notificationclick-can-focus.html |
| diff --git a/LayoutTests/http/tests/serviceworker/notificationclick-can-focus.html b/LayoutTests/http/tests/serviceworker/notificationclick-can-focus.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f1b49dc39fe065aabe49cd3c5c711647858c5ee8 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/notificationclick-can-focus.html |
| @@ -0,0 +1,57 @@ |
| +<!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,
|
| +<title>Service Worker: notificationclick can focus WindowClient</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<script> |
| +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.
|
| + testRunner.grantWebNotificationPermission(location.origin, true); |
| + |
| +var t = async_test('notificationclick can focus WindowClient'); |
| +t.step(function() { |
| + var scope = 'resources/blank.html' |
| + service_worker_unregister_and_register( |
| + t, 'resources/notificationclick-can-focus.js', scope) |
| + .then(function(registration) { |
| + return wait_for_state(t, registration.installing, 'activated'); |
| + }) |
| + .then(function() { return with_iframe(scope); }) |
| + .then(function(frame) { |
| + var w = frame.contentWindow; |
| + w.onmessage = t.step_func(onMessage); |
| + w.navigator.serviceWorker.controller.postMessage('start'); |
| + }) |
| + .catch(unreached_rejection(t)); |
| + |
| + var result = []; |
| + var expected = ['focus() outside of a Notification click event failed', |
| + 'focus() in Notification click event succeeded', |
| + 'focus() called twice failed', |
| + 'focus() in notificationclick outside of waitUntil but in stack succeeded', |
| + 'focus() in notificationclick outside of waitUntil not in stack failed', |
| + 'focus() in notificationclick\'s waitUntil suceeded', |
| + 'focus() called twice failed', |
| + 'focus() failed after timeout', |
| + 'focus() failed because a window was opened before']; |
| + |
| + function onMessage(e) { |
| + var message = e.data; |
| + |
| + if (typeof(message) === 'object') { |
| + if (message.type !== 'click') |
| + return; |
| + if (window.testRunner) |
| + testRunner.simulateWebNotificationClick(message.title); |
| + return; |
| + } |
| + |
| + if (message === 'quit') { |
| + assert_array_equals(result, expected, |
| + 'Worker should post back expected messages.'); |
| + service_worker_unregister_and_done(t, scope); |
| + } else { |
| + result.push(message); |
| + } |
| + } |
| + }); |
| +</script> |