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

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

Issue 1211253007: ServiceWorker: Add LayoutTest for WindowClient.navigate(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: clients.openWindow() tests (using testRunner)</title> 2 <title>Service Worker: WindowClient.navigate() tests (using testRunner)</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/test-helpers.js"></script> 5 <script src="../resources/test-helpers.js"></script>
6 <script> 6 <script>
7 // This test is using testRunner to grant itself the notification permission and 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 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. 9 // be run as a manual test by other browser vendors.
10 if (window.testRunner) 10 if (window.testRunner)
11 testRunner.setPermission('notifications', 'granted', location.origin, locati on.origin); 11 testRunner.setPermission('notifications', 'granted', location.origin, locati on.origin);
nhiroki 2015/07/15 08:53:14 I think we can re-write these tests using iframes
zino 2015/09/22 07:53:31 Done.
12 12
13 var t = async_test('clients.openWindow() behaved as expected'); 13 var t = async_test('WindowClient.navigate() behaved as expected');
14 t.step(function() { 14 t.step(function() {
15 var scope = 'resources/blank.html' 15 var scope = 'resources/'
16 service_worker_unregister_and_register( 16 service_worker_unregister_and_register(
17 t, 'resources/clients-openwindow.js', scope) 17 t, 'resources/windowclient-navigate.js', scope)
18 .then(function(registration) { 18 .then(function(registration) {
19 return wait_for_state(t, registration.installing, 'activated'); 19 return wait_for_state(t, registration.installing, 'activated');
20 }) 20 })
21 .then(function() { return with_iframe(scope); }) 21 .then(function() { return with_iframe(scope); })
22 .then(function(frame) { 22 .then(function(frame) {
23 var w = frame.contentWindow; 23 var w = frame.contentWindow;
24 w.navigator.serviceWorker.onmessage = t.step_func(onMessage); 24 w.navigator.serviceWorker.onmessage = t.step_func(onMessage);
25 w.navigator.serviceWorker.controller.postMessage('start'); 25 w.navigator.serviceWorker.controller.postMessage('start');
26 }) 26 })
27 .catch(unreached_rejection(t)); 27 .catch(unreached_rejection(t));
28 28
29 var result = []; 29 var result = [];
30 var expected = ['openWindow() can\'t open a window without a user interactio n', 30 var expected = ['navigate() can navigate controlled client',
31 'openWindow() error is InvalidAccessError', 31 'navigate() result: [object WindowClient]',
32 'openWindow() can open cross origin windows', 32 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/test.html',
33 'openWindow() result: null',
34 'openWindow() can open not controlled windows',
35 'openWindow() result: [object WindowClient]',
36 'openWindow() can open controlled windows',
37 'openWindow() result: [object WindowClient]',
38 ' url: ' + location.origin + '/serviceworker/chromium/resour ces/blank.html',
39 ' visibilityState: visible', 33 ' visibilityState: visible',
40 ' focused: true', 34 ' focused: true',
41 ' frameType: top-level', 35 ' frameType: top-level',
42 'openWindow() can open about:blank', 36 'navigate() can navigate not controlled client',
43 'openWindow() result: null', 37 'navigate() result: [object WindowClient]',
44 'openWindow() can open about:crash', 38 'navigate() can navigate to a cross origin url',
45 'openWindow() result: null', 39 'navigate() result: null',
46 'openWindow() can not open an invalid url', 40 'navigate() can not navigate to an invalid url',
47 'openWindow() error is: TypeError', 41 'navigate() error is TypeError',
48 'openWindow() can not open view-source scheme', 42 'navigate() can not navigate to view-source scheme',
49 'openWindow() can not open file scheme', 43 'navigate() error is UnknownError',
50 'openWindow() error is: SecurityError', 44 'navigate() can not navigate to file scheme',
45 'navigate() error is SecurityError',
46 'navigate() can not navigate to about:blank',
47 'navigate() error is TypeError',
48 'navigate() can not navigate to about:crash',
49 'navigate() error is TypeError',
51 ]; 50 ];
52 51
53 // LayoutTests on Mac do not open focused windows. 52 // LayoutTests on Mac do not open focused windows.
54 var isMac = navigator.platform.indexOf('Mac') == 0; 53 var isMac = navigator.platform.indexOf('Mac') == 0;
55 if (isMac) 54 if (isMac)
56 expected[10] = ' focused: false'; 55 expected[10] = ' focused: false';
57 56
58 function onMessage(e) { 57 function onMessage(e) {
59 var message = e.data; 58 var message = e.data;
60 59
61 if (typeof(message) === 'object') { 60 if (typeof(message) === 'object') {
62 if (message.type !== 'click') 61 if (message.type !== 'click')
63 return; 62 return;
64 if (window.testRunner) 63 if (window.testRunner)
65 testRunner.simulateWebNotificationClick(message.title); 64 testRunner.simulateWebNotificationClick(message.title);
66 return; 65 return;
67 } 66 }
68 67
69 if (message === 'quit') { 68 if (message === 'quit') {
70 assert_array_equals(result, expected, 69 assert_array_equals(result, expected,
71 'Worker should post back expected messages.'); 70 'Worker should post back expected messages.');
72 service_worker_unregister_and_done(t, scope); 71 service_worker_unregister_and_done(t, scope);
73 } else { 72 } else {
74 result.push(message); 73 result.push(message);
75 } 74 }
76 } 75 }
77 }); 76 });
78 </script> 77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698