Bug 1283674 P2 Add wpt test verifying serviceWorker.controller behavior on disconnected window. r=baku a=lizzard
authorBen Kelly <ben@wanderview.com>
Wed, 06 Jul 2016 06:17:42 -0700
changeset 339844 65d24c58d45069b3433dea3a2d30726083f5781f
parent 339843 fd3a743ee4e5ffcaf3cea99a7a2ce41af678ae17
child 339845 6eaa86d11a5c5dad67d5ca343e5d9226ff524517
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, lizzard
bugs1283674
milestone49.0a2
Bug 1283674 P2 Add wpt test verifying serviceWorker.controller behavior on disconnected window. r=baku a=lizzard
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -36031,16 +36031,22 @@
           }
         ],
         "html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html": [
           {
             "path": "html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html",
             "url": "/html/semantics/embedded-content/the-embed-element/embed-in-object-fallback.html"
           }
         ],
+        "service-workers/service-worker/controller-on-disconnect.https.html": [
+          {
+            "path": "service-workers/service-worker/controller-on-disconnect.https.html",
+            "url": "/service-workers/service-worker/controller-on-disconnect.https.html"
+          }
+        ],
         "web-animations/timing-model/animations/current-time.html": [
           {
             "path": "web-animations/timing-model/animations/current-time.html",
             "url": "/web-animations/timing-model/animations/current-time.html"
           }
         ],
         "web-animations/timing-model/animations/set-the-timeline-of-an-animation.html": [
           {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/controller-on-disconnect.https.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<title>Service Worker: Controller on load</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
+<body>
+<script>
+var t = async_test('controller is cleared on disconnected window');
+t.step(function() {
+    var url = 'resources/empty-worker.js';
+    var scope = 'resources/blank.html';
+    var registration;
+    var controller;
+    var frame;
+    service_worker_unregister_and_register(t, url, scope)
+      .then(t.step_func(function(swr) {
+          registration = swr;
+          return wait_for_state(t, registration.installing, 'activated');
+        }))
+      .then(t.step_func(function() {
+          return with_iframe(scope)
+        }))
+      .then(t.step_func(function(f) {
+          frame = f;
+          var w = frame.contentWindow;
+          var swc = w.navigator.serviceWorker;
+          assert_true(swc.controller instanceof w.ServiceWorker,
+                      'controller should be a ServiceWorker object');
+
+          frame.remove();
+
+          assert_equals(swc.controller, null,
+                        'disconnected frame should not be controlled');
+
+          service_worker_unregister_and_done(t, scope);
+        }))
+      .catch(unreached_rejection(t));
+  });
+</script>
+</body>