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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/notificationclick-can-openwindow.html

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: review comments 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/chromium/notificationclick-can-openwindow.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/notificationclick-can-openwindow.html b/LayoutTests/http/tests/serviceworker/chromium/notificationclick-can-openwindow.html
new file mode 100644
index 0000000000000000000000000000000000000000..8366a07fd02b93cbe0a21674cde454cfb31c627b
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/notificationclick-can-openwindow.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<title>Service Worker: notificationclick can open new 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)
+ testRunner.grantWebNotificationPermission(location.origin, true);
+
+var t = async_test('notificationclick can open new WindowClient');
+t.step(function() {
+ var scope = 'resources/blank.html'
+ service_worker_unregister_and_register(
+ t, 'resources/notificationclick-can-openwindow.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 = ['openWindow() outside of a notificationclick event failed',
+ 'openWindow() in notificationclick outside of waitUntil but in stack succeeded',
+ 'openWindow() in notificationclick outside of waitUntil not in stack failed',
+ 'openWindow() in notificationclick\'s waitUntil suceeded',
+ 'openWindow() called twice failed',
+ 'openWindow() failed after timeout',
+ 'openWindow() failed because a window was focused 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>

Powered by Google App Engine
This is Rietveld 408576698