Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="resources/test-helpers.js"></script> | |
| 5 <body> | |
| 6 <script> | |
| 7 (function () { | |
| 8 var t = async_test('Service Worker fetch event response'); | |
| 9 var scope = '/helloworld/*'; | |
| 10 | |
| 11 service_worker_unregister_and_register( | |
| 12 t, 'resources/hello-world-worker.js', scope, onRegister); | |
| 13 | |
| 14 function onRegister(sw) { | |
| 15 sw.addEventListener('statechange', t.step_func(onStateChange)); | |
| 16 } | |
| 17 | |
| 18 function onStateChange(event) { | |
| 19 if (event.target.state != 'active') | |
| 20 return; | |
| 21 with_iframe('/helloworld/hello', t.step_func(function(frame) { | |
| 22 assert_equals(frame.contentDocument.body.textContent, "hello, world" ); | |
|
jsbell
2014/06/02 23:27:34
Please add a description to the assertion, e.g. 'W
falken
2014/06/03 02:26:30
Done.
| |
| 23 service_worker_unregister_and_done(t, scope); | |
| 24 })); | |
| 25 } | |
| 26 }()); | |
| 27 | |
| 28 (function () { | |
| 29 var t = async_test('Service Worker fetch event not handled'); | |
| 30 var scope = '*'; | |
| 31 | |
| 32 service_worker_unregister_and_register( | |
| 33 t, 'resources/empty-worker.js', scope, onRegister); | |
| 34 | |
| 35 function onRegister(sw) { | |
| 36 sw.addEventListener('statechange', t.step_func(onStateChange)); | |
| 37 } | |
| 38 | |
| 39 function onStateChange(event) { | |
| 40 if (event.target.state != 'active') | |
| 41 return; | |
| 42 with_iframe('resources/simple.html', t.step_func(function(frame) { | |
| 43 assert_equals(frame.contentDocument.body.textContent, "Here's a simp le html file.\n"); | |
|
jsbell
2014/06/02 23:27:34
Ditto, e.g. 'Worker should not have intercepted fe
falken
2014/06/03 02:26:30
Done.
| |
| 44 service_worker_unregister_and_done(t, scope); | |
| 45 })); | |
| 46 } | |
| 47 }()); | |
| 48 | |
| 49 (function () { | |
| 50 var t = async_test('Service Worker fetch event rejected'); | |
| 51 var scope = '*'; | |
| 52 | |
| 53 service_worker_unregister_and_register( | |
| 54 t, 'resources/empty-worker.js', scope, onRegister); | |
|
jsbell
2014/06/02 23:27:34
Shouldn't this be reject-fetch-event-worker.js ?
falken
2014/06/03 02:26:30
Of course! Done.
| |
| 55 | |
| 56 function onRegister(sw) { | |
| 57 sw.addEventListener('statechange', t.step_func(onStateChange)); | |
| 58 } | |
| 59 | |
| 60 function onStateChange(event) { | |
| 61 if (event.target.state != 'active') | |
| 62 return; | |
| 63 with_iframe('resources/simple.html', t.step_func(function(frame) { | |
| 64 assert_equals(frame.contentDocument.body.textContent, "Here's a simp le html file.\n"); | |
|
jsbell
2014/06/02 23:27:34
Ditto.
falken
2014/06/03 02:26:30
Done.
| |
| 65 service_worker_unregister_and_done(t, scope); | |
| 66 })); | |
| 67 } | |
| 68 }()); | |
| 69 </script> | |
| 70 </body> | |
| OLD | NEW |