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

Side by Side Diff: LayoutTests/http/tests/serviceworker/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, 3 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.navigate() tests</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="../resources/get-host-info.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <script>
8
9 var scope = 'resources/blank.html?windowclient-navigate';
10 var client_frame;
11 var message_frame;
12 var test;
13
14 var current_index = 0;
15 var test_list = [
16 { url : 'blank.html' },
17 { url : 'blank.html', init : 'uncontrolled/blank.html' },
18 { url : get_host_info()['HTTP_REMOTE_ORIGIN'] +
19 '/serviceworker/resources/blank.html' },
20 { url : 'http://[test].com' },
21 { url : 'view-source://http://test.com' },
nhiroki 2015/09/28 08:59:21 'view-source:http://example.com'? - '//' before
zino 2015/10/07 02:30:41 Done.
22 { url : 'file:///' },
23 { url : 'about:blank' },
24 { url : 'about:crash' }
25 ];
26
27 var expected = [
28 location.origin + '/serviceworker/resources/blank.html',
29 'UnknownError',
nhiroki 2015/09/28 08:59:21 According to the spec, navigation for uncontrolled
zino 2015/10/07 02:30:41 I tried it but I faced some troubles. So, I filed
nhiroki 2015/10/08 07:52:09 Acknowledged.
30 null,
31 'TypeError',
32 'UnknownError',
nhiroki 2015/09/28 08:59:21 The spec does not mention 'view-source', but "Type
zino 2015/10/07 02:30:41 ditto
33 'SecurityError',
34 'TypeError',
35 'TypeError'
36 ];
37
38 var actual = [];
39
40 async_test(function(t) {
41 test = t;
42 return service_worker_unregister_and_register(
43 test, 'resources/windowclient-navigate.js', scope)
nhiroki 2015/09/28 08:59:21 Could you add "-worker.js" suffix? "windowclient-
zino 2015/10/07 02:30:41 Done.
44 .then(function(registration) {
45 return wait_for_state(test, registration.installing, 'activated');
46 })
nhiroki 2015/09/28 08:59:21 Could you insert more indents like this? return s
zino 2015/10/07 02:30:41 Done.
47 .then(function() {
48 var init_url = test_list[current_index].init || scope;
49 return with_iframe(init_url + '#client');
50 })
51 .then(function(f) {
52 client_frame = f;
53 return with_iframe(scope + '#message');
54 })
55 .then(function(f) {
56 message_frame = f;
nhiroki 2015/09/28 08:59:21 Why doesn't this toplevel frame (not |message_fram
zino 2015/10/07 02:30:41 Done.
57 var worker = f.contentWindow.navigator.serviceWorker;
58 worker.onmessage = test.step_func(on_message);
59 worker.controller.postMessage(test_list[current_index++].url);
60 })
61 .catch(unreached_rejection(t));
62 }, 'WindowClient.navigate() test');
63
64 function on_message(e) {
65 var message = e.data;
66
67 actual.push(message);
68 if (expected.length == actual.length) {
69 assert_array_equals(actual, expected);
70 service_worker_unregister_and_done(test, scope);
71 } else {
72 client_frame.remove();
73 var init_url = test_list[current_index].init || scope;
74 with_iframe(init_url + '#client').then(function(f) {
75 client_frame = f;
76 e.source.postMessage(test_list[current_index++].url);
77 });
nhiroki 2015/09/28 08:59:21 nit: indent with_iframe(...).then(function(f) {
zino 2015/10/07 02:30:41 Done.
78 }
79 }
80
81 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698