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

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

Issue 879403005: [ServiceWorker] Tests for Clients.openWindow(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@window_interaction_tests
Patch Set: cleanup and add test helper 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html b/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html
new file mode 100644
index 0000000000000000000000000000000000000000..e81b49aa71b15a414a21adb438343a122f005705
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/clients-openwindow.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<title>Service Worker: clients.openWindow() tests (using testRunner)</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../resources/test-helpers.js"></script>
+<script>
+// This test is using testRunner to grant itself the notification permission and
+// to simulate a click on a notification. A couple of changes would allow it to
+// be run as a manual test by other browser vendors.
+if (window.testRunner)
+ testRunner.grantWebNotificationPermission(location.origin, true);
+
+var t = async_test('clients.openWindow() behaved as expected');
+t.step(function() {
+ var scope = 'resources/blank.html'
+ service_worker_unregister_and_register(
+ t, 'resources/clients-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() can\'t open a window without a user interaction',
+ 'openWindow() error is InvalidAccessError',
+ 'openWindow() can\'t open cross origin windows',
+ 'openWindow() error is SecurityError',
+ 'openWindow() can open not controlled windows',
+ 'openWindow() result: null',
+ 'openWindow() can open controlled windows',
+ 'openWindow() result: [object WindowClient]',
+ ' url: ' + location.origin + '/serviceworker/chromium/resources/blank.html',
+ ' visibilityState: visible',
+ ' focused: true',
+ ' frameType: top-level'];
+
+ // LayoutTests on Mac do not open focused windows.
+ var isMac = navigator.platform.indexOf('Mac') == 0;
+ if (isMac)
+ expected[10] = ' focused: false';
+
+ 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>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/clients-openwindow.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698