Bug 1181054 - Part 4: Make fetch-event.https.html pass; r=bkelly
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 20 Oct 2015 16:22:37 -0400
changeset 304695 8d81779015b803867b0caf3d860deb3b2436ff56
parent 304694 3ca8546e3cc5fef952164aa97a0b85b8c90863b1
child 304696 b1095ad5a4b84117cfbde34da2e9e77351b566db
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1181054
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1181054 - Part 4: Make fetch-event.https.html pass; r=bkelly
testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event.https.html.ini
testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event.https.html
testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-event-test-worker.js
deleted file mode 100644
--- a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event.https.html.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[fetch-event.https.html]
-  type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1194881
-  [Service Worker responds to fetch event with POST form]
-    expected: FAIL
-
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event.https.html
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event.https.html
@@ -150,72 +150,67 @@ async_test(function(t) {
               document.body.removeChild(form);
               resolve(frame);
             };
             form.submit();
           });
         })
       .then(function(frame) {
           assert_equals(frame.contentDocument.body.textContent,
-                        'POST:testName1=testValue1&testName2=testValue2');
+                        'POST:application/x-www-form-urlencoded:' +
+                        'testName1=testValue1&testName2=testValue2');
           document.body.removeChild(frame);
           return service_worker_unregister_and_done(t, scope);
         })
       .catch(unreached_rejection(t));
   }, 'Service Worker responds to fetch event with POST form');
 
 async_test(function(t) {
     var scope = 'resources/simple.html?multiple-respond-with';
     service_worker_unregister_and_register(t, worker, scope)
       .then(function(reg) {
           return wait_for_state(t, reg.installing, 'activated');
         })
       .then(function() { return with_iframe(scope); })
       .then(function(frame) {
           assert_equals(
             frame.contentDocument.body.textContent,
-            '(0)',
-            'Response should be the argument of the first respondWith() call.');
-          frame.remove();
-          return with_iframe(scope);
-        })
-      .then(function(frame) {
-          assert_equals(
-            frame.contentDocument.body.textContent,
-            '(0)(1)[InvalidStateError](2)[InvalidStateError](0)',
+            '(0)(1)[InvalidStateError](2)[InvalidStateError]',
             'Multiple calls of respondWith must throw InvalidStateErrors.');
           frame.remove();
           return service_worker_unregister_and_done(t, scope);
         })
       .catch(unreached_rejection(t));
   }, 'Multiple calls of respondWith must throw InvalidStateErrors');
 
 async_test(function(t) {
     var scope = 'resources/simple.html?used-check';
+    var first_frame;
     service_worker_unregister_and_register(t, worker, scope)
       .then(function(reg) {
           return wait_for_state(t, reg.installing, 'activated');
         })
       .then(function() { return with_iframe(scope); })
       .then(function(frame) {
           assert_equals(frame.contentDocument.body.textContent,
                         'Here\'s an other html file.\n',
                         'Response should come from fetched other file');
-          frame.remove();
+          first_frame = frame;
           return with_iframe(scope);
         })
       .then(function(frame) {
           // When we access to the scope in the second time, the content of the
           // response is generated inside the ServiceWorker. The body contains
           // the value of bodyUsed of the first response which is already
           // consumed by FetchEvent.respondWith method.
           assert_equals(
             frame.contentDocument.body.textContent,
             'bodyUsed: true',
             'event.respondWith must set the used flag.');
+          first_frame.remove();
           frame.remove();
           return service_worker_unregister_and_done(t, scope);
         })
       .catch(unreached_rejection(t));
   }, 'Service Worker event.respondWith must set the used flag');
 
 </script>
 </body>
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-event-test-worker.js
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-event-test-worker.js
@@ -18,28 +18,33 @@ function handleNullBody(event) {
 function handleFetch(event) {
   event.respondWith(fetch('other.html'));
 }
 
 function handleFormPost(event) {
   event.respondWith(new Promise(function(resolve) {
       event.request.text()
         .then(function(result) {
-            resolve(new Response(event.request.method + ':' + result));
+            resolve(new Response(event.request.method + ':' +
+                                 event.request.headers.get('Content-Type') + ':' +
+                                 result));
           });
     }));
 }
 
-var logForMultipleRespondWith = '';
-
 function handleMultipleRespondWith(event) {
+  var logForMultipleRespondWith = '';
   for (var i = 0; i < 3; ++i) {
     logForMultipleRespondWith += '(' + i + ')';
     try {
-      event.respondWith(new Response(logForMultipleRespondWith));
+      event.respondWith(new Promise(function(resolve) {
+        setTimeout(function() {
+          resolve(new Response(logForMultipleRespondWith));
+        }, 0);
+      }));
     } catch (e) {
       logForMultipleRespondWith += '[' + e.name + ']';
     }
   }
 }
 
 var lastResponseForUsedCheck = undefined;