Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: LayoutTests/http/tests/serviceworker/unregister-controller.html

Issue 358553003: Service Worker: add layout tests for behavior of controller after unregister (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: feedback Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/unregister-controller-page.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/unregister-controller.html
diff --git a/LayoutTests/http/tests/serviceworker/unregister-controller.html b/LayoutTests/http/tests/serviceworker/unregister-controller.html
new file mode 100644
index 0000000000000000000000000000000000000000..c4cc03308077ea65508054abfc60425339785c61
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/unregister-controller.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+var worker_url = 'resources/simple-intercept-worker.js';
+
+async_test(function(t) {
+ var scope = 'resources/unregister-controller-page.html?load-before-unregister';
+
+ service_worker_unregister_and_register(t, worker_url, scope).then(t.step_func(function(worker) {
+ worker.addEventListener('statechange', t.step_func(on_state_change));
+ }));
+
+ function on_state_change(event) {
+ if (event.target.state != 'active')
+ return;
+ with_iframe(scope, t.step_func(function(frame) {
+ var w = frame.contentWindow;
+ assert_true(w.navigator.serviceWorker.controller instanceof w.ServiceWorker,
+ 'document should load with a controller');
+ w.fetch_url('simple.txt').then(t.step_func(function(response) {
+ assert_equals(response, 'intercepted by service worker', 'controller should intercept requests');
+ t.done();
+ }), unreached_rejection(t, 'fetch failed'));
+ }));
+ }
+}, 'Unregister does not affect existing controller');
+
+async_test(function(t) {
+ var scope = 'resources/unregister-controller-page.html?load-after-unregister';
+
+ service_worker_unregister_and_register(t, worker_url, scope).then(t.step_func(function(worker) {
+ worker.addEventListener('statechange', t.step_func(on_state_change));
+ }));
+
+ function on_state_change(event) {
+ if (event.target.state != 'active')
+ return;
+ navigator.serviceWorker.unregister(scope).then(t.step_func(function() {
+ with_iframe(scope, t.step_func(function(frame) {
+ var w = frame.contentWindow;
+ assert_equals(w.navigator.serviceWorker.controller, null, 'document should not have a controller');
+ w.fetch_url('simple.txt').then(t.step_func(function(response) {
+ assert_equals(response, 'a simple text file\n', 'requests should not be intercepted');
+ t.done();
+ }), unreached_rejection(t, 'fetch failed'));
+ }));
+ }));
+ }
+}, 'Unregister prevents control of subsequent navigations');
+</script>
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/unregister-controller-page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698