Chromium Code Reviews| 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 init_url = test_list[current_index].init || scope; | |
| 54 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.
| |
| 55 }) | |
| 56 .then(function(f) { | |
| 57 client_frame = f; | |
| 58 var channel = new MessageChannel(); | |
| 59 channel.port1.onmessage = test.step_func(on_message); | |
| 60 worker.postMessage({ port : channel.port2 }, [channel.port2]); | |
| 61 worker.postMessage(test_list[current_index++].url); | |
| 62 }) | |
| 63 .catch(unreached_rejection(t)); | |
| 64 }, 'WindowClient.navigate() test'); | |
| 65 | |
| 66 function on_message(e) { | |
| 67 var message = e.data; | |
| 68 actual.push(message); | |
| 69 if (expected.length == actual.length) { | |
| 70 assert_array_equals(actual, expected); | |
| 71 service_worker_unregister_and_done(test, scope); | |
| 72 } else { | |
| 73 client_frame.remove(); | |
| 74 var init_url = test_list[current_index].init || scope; | |
| 75 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.
| |
| 76 client_frame = f; | |
| 77 worker.postMessage(test_list[current_index++].url); | |
| 78 }); | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 </script> | |
| OLD | NEW |