Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/fetch-event.html |
| diff --git a/LayoutTests/http/tests/serviceworker/fetch-event.html b/LayoutTests/http/tests/serviceworker/fetch-event.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..be1151ca96f941e3389879d2558906d74b8e6d1d |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/fetch-event.html |
| @@ -0,0 +1,70 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<body> |
| +<script> |
| +(function () { |
| + var t = async_test('Service Worker fetch event response'); |
| + var scope = '/helloworld/*'; |
| + |
| + service_worker_unregister_and_register( |
| + t, 'resources/hello-world-worker.js', scope, onRegister); |
| + |
| + function onRegister(sw) { |
| + sw.addEventListener('statechange', t.step_func(onStateChange)); |
| + } |
| + |
| + function onStateChange(event) { |
| + if (event.target.state != 'active') |
| + return; |
| + with_iframe('/helloworld/hello', t.step_func(function(frame) { |
| + 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.
|
| + service_worker_unregister_and_done(t, scope); |
| + })); |
| + } |
| +}()); |
| + |
| +(function () { |
| + var t = async_test('Service Worker fetch event not handled'); |
| + var scope = '*'; |
| + |
| + service_worker_unregister_and_register( |
| + t, 'resources/empty-worker.js', scope, onRegister); |
| + |
| + function onRegister(sw) { |
| + sw.addEventListener('statechange', t.step_func(onStateChange)); |
| + } |
| + |
| + function onStateChange(event) { |
| + if (event.target.state != 'active') |
| + return; |
| + with_iframe('resources/simple.html', t.step_func(function(frame) { |
| + assert_equals(frame.contentDocument.body.textContent, "Here's a simple 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.
|
| + service_worker_unregister_and_done(t, scope); |
| + })); |
| + } |
| +}()); |
| + |
| +(function () { |
| + var t = async_test('Service Worker fetch event rejected'); |
| + var scope = '*'; |
| + |
| + service_worker_unregister_and_register( |
| + 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.
|
| + |
| + function onRegister(sw) { |
| + sw.addEventListener('statechange', t.step_func(onStateChange)); |
| + } |
| + |
| + function onStateChange(event) { |
| + if (event.target.state != 'active') |
| + return; |
| + with_iframe('resources/simple.html', t.step_func(function(frame) { |
| + assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n"); |
|
jsbell
2014/06/02 23:27:34
Ditto.
falken
2014/06/03 02:26:30
Done.
|
| + service_worker_unregister_and_done(t, scope); |
| + })); |
| + } |
| +}()); |
| +</script> |
| +</body> |