Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| diff --git a/LayoutTests/http/tests/serviceworker/windowclient-navigate.html b/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1748c1e54435445960a881d00bfd1731808bb5ef |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| @@ -0,0 +1,81 @@ |
| +<!DOCTYPE html> |
| +<title>Service Worker: WindowClient.navigate() tests</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/get-host-info.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<script> |
| + |
| +var scope = 'resources/blank.html?windowclient-navigate'; |
| +var client_frame; |
| +var message_frame; |
| +var test; |
| + |
| +var current_index = 0; |
| +var test_list = [ |
| + { url : 'blank.html' }, |
| + { url : 'blank.html', init : 'uncontrolled/blank.html' }, |
| + { url : get_host_info()['HTTP_REMOTE_ORIGIN'] + |
| + '/serviceworker/resources/blank.html' }, |
| + { url : 'http://[test].com' }, |
| + { 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.
|
| + { url : 'file:///' }, |
| + { url : 'about:blank' }, |
| + { url : 'about:crash' } |
| +]; |
| + |
| +var expected = [ |
| + location.origin + '/serviceworker/resources/blank.html', |
| + '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.
|
| + null, |
| + 'TypeError', |
| + '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
|
| + 'SecurityError', |
| + 'TypeError', |
| + 'TypeError' |
| +]; |
| + |
| +var actual = []; |
| + |
| +async_test(function(t) { |
| + test = t; |
| + return service_worker_unregister_and_register( |
| + 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.
|
| + .then(function(registration) { |
| + return wait_for_state(test, registration.installing, 'activated'); |
| + }) |
|
nhiroki
2015/09/28 08:59:21
Could you insert more indents like this?
return s
zino
2015/10/07 02:30:41
Done.
|
| + .then(function() { |
| + var init_url = test_list[current_index].init || scope; |
| + return with_iframe(init_url + '#client'); |
| + }) |
| + .then(function(f) { |
| + client_frame = f; |
| + return with_iframe(scope + '#message'); |
| + }) |
| + .then(function(f) { |
| + 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.
|
| + var worker = f.contentWindow.navigator.serviceWorker; |
| + worker.onmessage = test.step_func(on_message); |
| + worker.controller.postMessage(test_list[current_index++].url); |
| + }) |
| + .catch(unreached_rejection(t)); |
| +}, 'WindowClient.navigate() test'); |
| + |
| +function on_message(e) { |
| + var message = e.data; |
| + |
| + actual.push(message); |
| + if (expected.length == actual.length) { |
| + assert_array_equals(actual, expected); |
| + service_worker_unregister_and_done(test, scope); |
| + } else { |
| + client_frame.remove(); |
| + var init_url = test_list[current_index].init || scope; |
| + with_iframe(init_url + '#client').then(function(f) { |
| + client_frame = f; |
| + e.source.postMessage(test_list[current_index++].url); |
| + }); |
|
nhiroki
2015/09/28 08:59:21
nit: indent
with_iframe(...).then(function(f) {
zino
2015/10/07 02:30:41
Done.
|
| + } |
| +} |
| + |
| +</script> |