Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5fdab77923c954f2f27481a3d7779c1cf04529f1 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| @@ -0,0 +1,82 @@ |
| +<!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 worker; |
| +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://[example].com' }, |
| + { url : 'view-source://example.com' }, |
| + { url : 'file:///' }, |
| + { url : 'about:blank' }, |
| + { url : 'about:crash' } |
| +]; |
| + |
| +var expected = [ |
| + location.origin + '/serviceworker/resources/blank.html', |
| + // TODO(zino): Should TypeError instead of UnknownError. |
| + // Please see: http://crbug.com/540503 |
| + 'UnknownError', |
| + null, |
| + 'TypeError', |
| + // TODO(zino): Should TypeError instead of UnknownError. |
| + // Please see: http://crbug.com/540503 |
| + 'UnknownError', |
| + 'SecurityError', |
| + 'TypeError', |
| + 'TypeError' |
| +]; |
| + |
| +var actual = []; |
| + |
| +async_test(function(t) { |
| + test = t; |
| + return service_worker_unregister_and_register( |
| + test, 'resources/windowclient-navigate-worker.js', scope) |
| + .then(function(registration) { |
| + worker = registration.installing; |
| + return wait_for_state(test, worker, 'activated'); |
| + }) |
| + .then(function() { |
| + var init_url = test_list[current_index].init || scope; |
| + return with_iframe(init_url + '#client'); |
|
nhiroki
2015/10/08 09:19:06
"#client" might be no longer necessary?
zino
2015/10/08 13:35:36
Done.
|
| + }) |
| + .then(function(f) { |
| + client_frame = f; |
| + var channel = new MessageChannel(); |
| + channel.port1.onmessage = test.step_func(on_message); |
| + worker.postMessage({ port : channel.port2 }, [channel.port2]); |
| + worker.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) { |
|
nhiroki
2015/10/08 09:19:06
ditto (#client)
zino
2015/10/08 13:35:36
Done.
|
| + client_frame = f; |
| + worker.postMessage(test_list[current_index++].url); |
| + }); |
| + } |
| +} |
| + |
| +</script> |