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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/windowclient-focus.html

Issue 866043005: [ServiceWorker] Tests for WindowClient.focus(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_openwindow_tests
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 <!DOCTYPE html>
2 <title>Service Worker: WindowClient.focus() tests (using testRunner)</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 // This test is using testRunner to grant itself the notification permission and
8 // to simulate a click on a notification. A couple of changes would allow it to
9 // be run as a manual test by other browser vendors.
10 if (window.testRunner)
11 testRunner.grantWebNotificationPermission(location.origin, true);
12
13 var t = async_test('WindowClient.focus() behaved as expected');
14 t.step(function() {
15 var scope = 'resources/windowclient-focus.html'
16 service_worker_unregister_and_register(
17 t, 'resources/windowclient-focus.js', scope)
18 .then(function(registration) {
19 return wait_for_state(t, registration.installing, 'activated');
20 })
21 .then(function() { return with_iframe(scope); })
22 .then(function(frame) {
23 var w = frame.contentWindow;
24 w.onmessage = t.step_func(onMessage);
25 w.navigator.serviceWorker.controller.postMessage('start');
26 })
27 .catch(unreached_rejection(t));
28
29 var result = [];
30 var expected = ['focus() can\'t focus a window without a user interaction',
31 'focus() error is InvalidAccessError',
32 'focus() succeeded',
33 'focus() result: [object WindowClient]',
34 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/windowclient-focus.html',
Michael van Ouwerkerk 2015/02/18 10:55:47 No need to indent this much, this line is over 100
mlamouri (slow - plz ping) 2015/02/18 11:34:56 Done.
35 ' visibilityState: visible',
36 ' focused: true',
37 ' frameType: nested',
38 'focused clients: 1',
39 'focus() succeeded',
40 'focus() result: [object WindowClient]',
41 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/windowclient-focus.html?1',
42 ' visibilityState: visible',
43 ' focused: true',
44 ' frameType: nested',
45 'focused clients: 2',
46 'focus() succeeded',
47 'focus() result: [object WindowClient]',
48 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/windowclient-focus.html?2',
49 ' visibilityState: visible',
50 ' focused: true',
51 ' frameType: nested',
52 'focused clients: 2',
53 'focus() succeeded',
54 'focus() result: [object WindowClient]',
55 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/windowclient-focus.html?3',
56 ' visibilityState: visible',
57 ' focused: true',
58 ' frameType: top-level',
59 'focused clients: 1',
60 ];
61
62 // On Mac, focusing and LayoutTests are no friend. This is amending the
63 // above |expected| array to match Mac's expectations.
64 var isMac = navigator.platform.indexOf('Mac') == 0;
65 if (isMac) {
66 expected[27] = ' focused: false';
67 expected[29] = 'focused clients: 3';
68 }
69
70 function onMessage(e) {
71 var message = e.data;
72
73 if (typeof(message) === 'object') {
74 if (message.type !== 'click')
75 return;
76 if (window.testRunner)
77 testRunner.simulateWebNotificationClick(message.title);
78 return;
79 }
80
81 if (message === 'quit') {
82 assert_array_equals(result, expected,
83 'Worker should post back expected messages.');
84 service_worker_unregister_and_done(t, scope);
85 } else {
86 result.push(message);
87 }
88 }
89 });
90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698