Bug 1189536 - Make fetch-request-xhr.https.html pass; r=bkelly
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 19 Oct 2015 16:15:33 -0400
changeset 303703 3aaf22bdba2ccf6c89fd154d07d67e29202e01ff
parent 303702 3266a8e9def4039b461b31b77ce92506bcd24cb8
child 303704 25488fb579b364e26ba4f7921d5064b249ddc6b9
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
bugs1189536
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 1189536 - Make fetch-request-xhr.https.html pass; r=bkelly
testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-xhr.https.html.ini
testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-request-xhr.https.html
testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js
deleted file mode 100644
--- a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-request-xhr.https.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[fetch-request-xhr.https.html]
-  type: testharness
-  [Verify the body of FetchEvent using XMLHttpRequest]
-    expected: FAIL
-
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-request-xhr.https.html
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-request-xhr.https.html
@@ -12,19 +12,22 @@ async_test(function(t) {
     service_worker_unregister_and_register(t, SCRIPT, SCOPE)
       .then(function(registration) {
           return wait_for_state(t, registration.installing, 'activated');
         })
       .then(function() { return with_iframe(SCOPE); })
       .then(function(frame) {
           var channel = new MessageChannel();
           channel.port1.onmessage = t.step_func(function(e) {
-              assert_equals(e.data.results, 'finish');
-              frame.remove();
-              service_worker_unregister_and_done(t, SCOPE);
+              if (e.data.results === 'finish') {
+                frame.remove();
+                service_worker_unregister_and_done(t, SCOPE);
+              } else if (e.data.results == 'equals') {
+                assert_equals(e.data.got, e.data.expected);
+              }
             });
           frame.contentWindow.postMessage({},
                                           host_info['HTTPS_ORIGIN'],
                                           [channel.port2]);
         })
       .catch(unreached_rejection(t));
   }, 'Verify the body of FetchEvent using XMLHttpRequest');
 </script>
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
@@ -1,13 +1,18 @@
 <script src="../resources/get-host-info.sub.js"></script>
 <script src="test-helpers.sub.js?pipe=sub"></script>
 <script>
+var port;
 var host_info = get_host_info();
 
+function assert_equals(a, b) {
+  port.postMessage({results: 'equals', got: a, expected: b});
+}
+
 function get_boundary(headers) {
   var reg = new RegExp('multipart\/form-data; boundary=(.*)');
   for (var i = 0; i < headers.length; ++i) {
     if (headers[i][0] != 'content-type') {
       continue;
     }
     var regResult = reg.exec(headers[i][1]);
     if (!regResult) {
@@ -52,27 +57,25 @@ function xhr_send(url_base, method, data
       xhr.open(method, url_base + '/dummy?test', true);
       xhr.send(data);
     });
 }
 
 function string_test() {
   return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', 'test string', false)
     .then(function(response) {
-        assert_equals(response.context, 'xmlhttprequest');
         assert_equals(response.method, 'POST');
         assert_equals(response.body, 'test string');
       });
 }
 
 function blob_test() {
   return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', new Blob(['test blob']),
                   false)
     .then(function(response) {
-        assert_equals(response.context, 'xmlhttprequest');
         assert_equals(response.method, 'POST');
         assert_equals(response.body, 'test blob');
       });
 }
 
 function custom_method_test() {
   return xhr_send(host_info['HTTPS_ORIGIN'], 'XXX', 'test string xxx', false)
     .then(function(response) {
@@ -85,25 +88,21 @@ function options_method_test() {
   return xhr_send(host_info['HTTPS_ORIGIN'], 'OPTIONS', 'test string xxx', false)
     .then(function(response) {
         assert_equals(response.method, 'OPTIONS');
         assert_equals(response.body, 'test string xxx');
       });
 }
 
 function form_data_test() {
-  return create_file_system_file('fsfile.txt', 'fs file content')
-    .then(function(file_system_file) {
-        var formData = new FormData();
-        formData.append('sample string', '1234567890');
-        formData.append('sample blob', new Blob(['blob content']));
-        formData.append('sample file', new File(['file content'], 'file.dat'));
-        formData.append('sample fs file', file_system_file);
-        return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', formData, false);
-      })
+    var formData = new FormData();
+    formData.append('sample string', '1234567890');
+    formData.append('sample blob', new Blob(['blob content']));
+    formData.append('sample file', new File(['file content'], 'file.dat'));
+    return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', formData, false)
     .then(function(response) {
         assert_equals(response.method, 'POST');
         var boundary = get_boundary(response.headers);
         var expected_body =
           '--' + boundary + '\r\n' +
           'Content-Disposition: form-data; name="sample string"\r\n' +
           '\r\n' +
           '1234567890\r\n' +
@@ -114,22 +113,16 @@ function form_data_test() {
           '\r\n' +
           'blob content\r\n' +
           '--' + boundary + '\r\n' +
           'Content-Disposition: form-data; name="sample file"; ' +
           'filename="file.dat"\r\n' +
           'Content-Type: application/octet-stream\r\n' +
           '\r\n' +
           'file content\r\n' +
-          '--' + boundary + '\r\n' +
-          'Content-Disposition: form-data; name="sample fs file"; ' +
-          'filename="fsfile.txt"\r\n' +
-          'Content-Type: text/plain\r\n' +
-          '\r\n' +
-          'fs file content\r\n' +
           '--' + boundary + '--\r\n';
         assert_equals(response.body, expected_body);
       });
 }
 
 function mode_credentials_test() {
   return xhr_send(host_info['HTTPS_ORIGIN'], 'GET', '', false)
     .then(function(response){
@@ -139,17 +132,17 @@ function mode_credentials_test() {
       })
     .then(function(response){
         assert_equals(response.mode, 'cors');
         assert_equals(response.credentials, 'include');
         return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'GET', '', false);
       })
     .then(function(response){
         assert_equals(response.mode, 'cors');
-        assert_equals(response.credentials, 'same-origin');
+        assert_equals(response.credentials, 'omit');
         return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'GET', '', true);
       })
     .then(function(response){
         assert_equals(response.mode, 'cors');
         assert_equals(response.credentials, 'include');
       });
 }
 
@@ -167,17 +160,17 @@ function data_url_test() {
         xhr.send();
       })
     .then(function(data) {
         assert_equals(data, 'Foobar');
       });
 }
 
 window.addEventListener('message', function(evt) {
-    var port = evt.ports[0];
+    port = evt.ports[0];
     string_test()
       .then(blob_test)
       .then(custom_method_test)
       .then(options_method_test)
       .then(form_data_test)
       .then(mode_credentials_test)
       .then(data_url_test)
       .then(function() { port.postMessage({results: 'finish'}); })
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/resources/fetch-request-xhr-worker.js
@@ -7,17 +7,16 @@ self.addEventListener('fetch', function(
         var headers = [];
         for (var header of event.request.headers) {
           headers.push(header);
         }
         event.request.text()
           .then(function(result) {
               resolve(new Response(JSON.stringify({
                   method: event.request.method,
-                  context: event.request.context,
                   mode: event.request.mode,
                   credentials: event.request.credentials,
                   headers: headers,
                   body: result
                 })));
             });
       }));
   });