Bug 1212683 - Fix and enable update.https.html; r=jdm, a=test-only
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 07 Oct 2015 21:33:55 -0400
changeset 296376 3902adefa47c767da4aa55e238633018f3560da0
parent 296375 68f9590115499ee32320d3268a6365ef8b248ba4
child 296377 e9d716c60d3769f50e305531c82b4b4c48b99e60
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, test-only
bugs1212683
milestone43.0a2
Bug 1212683 - Fix and enable update.https.html; r=jdm, a=test-only The source of the missing python script is: https://chromium.googlesource.com/chromium/src/+/8a0f7fc/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/resources/update-worker.php
testing/web-platform/mozilla/meta/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html.ini
testing/web-platform/mozilla/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js
testing/web-platform/mozilla/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py
deleted file mode 100644
--- a/testing/web-platform/mozilla/meta/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[update.https.html]
-  type: testharness
-  [Update a registration on ServiceWorkerGlobalScope]
-    expected: FAIL
-
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.js
@@ -0,0 +1,25 @@
+importScripts('../../resources/test-helpers.sub.js');
+importScripts('../../resources/worker-testharness.js');
+
+var events_seen = [];
+
+self.registration.addEventListener('updatefound', function() {
+    events_seen.push('updatefound');
+  });
+
+self.addEventListener('activate', function(e) {
+    events_seen.push('activate');
+  });
+
+self.addEventListener('fetch', function(e) {
+    events_seen.push('fetch');
+    e.respondWith(new Response(events_seen));
+  });
+
+self.addEventListener('message', function(e) {
+    events_seen.push('message');
+    self.registration.update();
+  });
+
+// update() during the script evaluation should be ignored.
+self.registration.update();
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/ServiceWorkerGlobalScope/resources/update-worker.py
@@ -0,0 +1,14 @@
+import os
+import time
+
+def main(request, response):
+    # update() does not bypass cache so set the max-age to 0 such that update()
+    # can find a new version in the network.
+    headers = [('Cache-Control', 'max-age: 0'),
+               ('Content-Type', 'application/javascript')]
+    with open(os.path.join(os.path.dirname(__file__),
+                           'update-worker.js'), 'r') as file:
+        script = file.read()
+    # Return a different script for each access.
+    return headers, '// %s\n%s' % (time.time(), script)
+