Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/unregister-on-detached-iframe.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/unregister-on-detached-iframe.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/unregister-on-detached-iframe.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fd20429fda2d9659a3cab6560c90dc67fc4da980 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/unregister-on-detached-iframe.html |
| @@ -0,0 +1,41 @@ |
| +<!DOCTYPE html> |
| +<meta charset="utf-8"> |
| +<title>Service Worker: Unregistration on detached iframe context</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../../resources/testharness-helpers.js"></script> |
| +<script src="../resources/test-helpers.js"></script> |
| +<script> |
| +promise_test(function(t) { |
| + var resources_dir = 'resources'; |
|
nhiroki
2016/04/21 08:23:30
I think |resources_dir| does not help to reduce th
shimazu
2016/04/21 09:06:36
Done.
|
| + var url = resources_dir + '/blank.html'; |
| + var scope_for_iframe = 'unregister-on-detached-iframe' |
| + var scope_for_main = resources_dir + '/' + scope_for_iframe; |
| + var script = resources_dir + '/empty-worker.js'; |
| + var frame; |
| + |
| + return service_worker_unregister(t, scope_for_main) |
| + .then(function() { |
| + return with_iframe(url, {auto_remove: false}); |
|
nhiroki
2016/04/21 08:23:30
We could make 'auto_remove' true for the case wher
shimazu
2016/04/21 09:06:36
Done.
|
| + }) |
| + .then(function(f) { |
| + frame = f; |
| + return navigator.serviceWorker.register(script, |
| + {scope: scope_for_main}); |
| + }) |
| + .then(function(r) { |
| + add_completion_callback(function() { r.unregister(); } ); |
| + return frame.contentWindow.navigator.serviceWorker.getRegistration( |
| + scope_for_iframe); |
| + }) |
| + .then(function(r) { |
| + frame.remove(); |
| + return assert_promise_rejects( |
| + r.unregister(), |
| + 'InvalidStateError', |
| + 'Unregistration on a detached iframe should throw an exception' |
| + ); |
| + }); |
| + }, 'Unregistration on a detached iframe should fail and throw ' + |
| + 'InvalidStateError exception'); |
| +</script> |