OLD | NEW |
(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 worker; |
| 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://[example].com' }, |
| 21 { url : 'view-source://example.com' }, |
| 22 { url : 'file:///' }, |
| 23 { url : 'about:blank' }, |
| 24 { url : 'about:crash' } |
| 25 ]; |
| 26 |
| 27 var expected = [ |
| 28 location.origin + '/serviceworker/resources/blank.html', |
| 29 // TODO(zino): Should TypeError instead of UnknownError. |
| 30 // Please see: http://crbug.com/540503 |
| 31 'UnknownError', |
| 32 null, |
| 33 'TypeError', |
| 34 // TODO(zino): Should TypeError instead of UnknownError. |
| 35 // Please see: http://crbug.com/540503 |
| 36 'UnknownError', |
| 37 'SecurityError', |
| 38 'TypeError', |
| 39 'TypeError' |
| 40 ]; |
| 41 |
| 42 var actual = []; |
| 43 |
| 44 async_test(function(t) { |
| 45 test = t; |
| 46 return service_worker_unregister_and_register( |
| 47 test, 'resources/windowclient-navigate-worker.js', scope) |
| 48 .then(function(registration) { |
| 49 worker = registration.installing; |
| 50 return wait_for_state(test, worker, 'activated'); |
| 51 }) |
| 52 .then(function() { |
| 53 var channel = new MessageChannel(); |
| 54 channel.port1.onmessage = test.step_func(function(e) { |
| 55 on_message(e, channel.port1); |
| 56 }); |
| 57 worker.postMessage({ port : channel.port2 }, [channel.port2]); |
| 58 }) |
| 59 .catch(unreached_rejection(t)); |
| 60 }, 'WindowClient.navigate() test'); |
| 61 |
| 62 function on_message(e, port) { |
| 63 var message = e.data; |
| 64 |
| 65 message == 'ready' || actual.push(message); |
| 66 if (expected.length == actual.length) { |
| 67 assert_array_equals(actual, expected); |
| 68 service_worker_unregister_and_done(test, scope); |
| 69 } else { |
| 70 client_frame && client_frame.remove(); |
| 71 var init_url = test_list[current_index].init || scope; |
| 72 with_iframe(init_url).then(function(f) { |
| 73 client_frame = f; |
| 74 port.postMessage(test_list[current_index++].url); |
| 75 }); |
| 76 } |
| 77 } |
| 78 |
| 79 </script> |
OLD | NEW |