Bug 1206961 - Update web platform tests (r=bkelly)
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Wed, 27 Apr 2016 19:41:25 +0200
changeset 295190 bf69c3219b5e
parent 295189 65911fba8069
child 295191 d4e2eee69d23
push id30220
push usercbook@mozilla.com
push date2016-04-28 14:31 +0000
treeherdermozilla-central@4292da9df16b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1206961
milestone49.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 1206961 - Update web platform tests (r=bkelly)
testing/web-platform/meta/service-workers/service-worker/fetch-request-css-images.https.html.ini
testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html
testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html
testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html
--- a/testing/web-platform/meta/service-workers/service-worker/fetch-request-css-images.https.html.ini
+++ b/testing/web-platform/meta/service-workers/service-worker/fetch-request-css-images.https.html.ini
@@ -1,5 +1,9 @@
 [fetch-request-css-images.https.html]
   type: testharness
-  [Verify FetchEvent for css images.]
-    expected: FAIL
-
+  expected: TIMEOUT
+  [Verify FetchEvent for css image (shapeOutside).]
+    expected: TIMEOUT
+  [Verify FetchEvent for css image-set (backgroundImage).]
+    expected: TIMEOUT
+  [Verify FetchEvent for css image-set (shapeOutside).]
+    expected: TIMEOUT
--- a/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-css-images.https.html
@@ -1,99 +1,176 @@
 <!DOCTYPE html>
 <title>Service Worker: FetchEvent for css image</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="resources/get-host-info.sub.js"></script>
 <script src="resources/test-helpers.sub.js?pipe=sub"></script>
 <script>
-var url_count = 0;
-var expected_results = {};
+var SCOPE = 'resources/fetch-request-resources-iframe.https.html';
+var SCRIPT = 'resources/fetch-request-resources-worker.js';
+var host_info = get_host_info();
+var LOCAL_URL =
+  host_info['HTTPS_ORIGIN'] + base_path() + 'resources/dummy?test';
+var REMOTE_URL =
+  host_info['HTTPS_REMOTE_ORIGIN'] + base_path() + 'resources/dummy?test';
 
-function css_image_test(frame, url, type, expexted_mode,
-                        expected_credentials) {
-  var actual_url = url + (++url_count);
-  expected_results[actual_url] = {
-      url: actual_url,
-      mode: expexted_mode,
+function css_image_test(expected_results, frame, url, type,
+                        expected_mode, expected_credentials) {
+  expected_results[url] = {
+      url: url,
+      mode: expected_mode,
       credentials: expected_credentials,
-      message: 'CSSImage load (url:' + actual_url + ' type:' + type + ')'
+      message: 'CSSImage load (url:' + url + ' type:' + type + ')'
     };
-  return frame.contentWindow.load_css_image(actual_url, type);
+  return frame.contentWindow.load_css_image(url, type);
+}
+
+function css_image_set_test(expected_results, frame, url, type,
+                            expected_mode, expected_credentials) {
+  expected_results[url] = {
+      url: url,
+      mode: expected_mode,
+      credentials: expected_credentials,
+      message: 'CSSImageSet load (url:' + url + ' type:' + type + ')'
+    };
+  return frame.contentWindow.load_css_image_set(url, type);
 }
 
-function css_image_set_test(frame, url, type, expexted_mode,
-                            expected_credentials) {
-  var actual_url = url + (++url_count);
-  expected_results[actual_url] = {
-      url: actual_url,
-      mode: expexted_mode,
-      credentials: expected_credentials,
-      message: 'CSSImageSet load (url:' + actual_url + ' type:' + type + ')'
-    };
-  return frame.contentWindow.load_css_image_set(actual_url, type);
+function create_message_promise(t, expected_results, frame,
+                                worker, test_count, scope) {
+  return new Promise(function(resolve) {
+    var channel = new MessageChannel();
+    channel.port1.onmessage = t.step_func(function(msg) {
+      if (msg.data.ready) {
+        resolve();
+        return;
+      }
+      var result = msg.data;
+      var expected = expected_results[result.url];
+      if (!expected) {
+        return;
+      }
+      assert_equals(
+          result.mode, expected.mode,
+          'mode of ' + expected.message +  ' must be ' +
+          expected.mode + '.');
+      assert_equals(
+          result.credentials, expected.credentials,
+          'credentials of ' + expected.message +  ' must be ' +
+          expected.credentials + '.');
+      --test_count;
+      delete expected_results[result.url];
+      if (test_count == 0) {
+        frame.remove();
+        service_worker_unregister_and_done(t, scope);
+      }
+    });
+    worker.postMessage(
+      {port: channel.port2}, [channel.port2]);
+  });
 }
 
 async_test(function(t) {
-    var SCOPE = 'resources/fetch-request-resources-iframe.https.html';
-    var SCRIPT = 'resources/fetch-request-resources-worker.js';
-    var host_info = get_host_info();
-    var LOCAL_URL =
-      host_info['HTTPS_ORIGIN'] + base_path() + 'resources/dummy?test';
-    var REMOTE_URL =
-      host_info['HTTPS_REMOTE_ORIGIN'] + base_path() + 'resources/dummy?test';
+    var scope = SCOPE + "?img=backgroundImage";
+    var test_count = 2;
+    var expected_results = {};
     var worker;
     var frame;
-    service_worker_unregister_and_register(t, SCRIPT, SCOPE)
+    service_worker_unregister_and_register(t, SCRIPT, scope)
       .then(function(registration) {
           worker = registration.installing;
           return wait_for_state(t, worker, 'activated');
         })
+      .then(function() { return with_iframe(scope); })
+      .then(function(f) {
+          frame = f;
+          return create_message_promise(t, expected_results, frame,
+                                        worker, test_count, scope);
+        })
       .then(function() {
-          return new Promise(function(resolve) {
-              var channel = new MessageChannel();
-              channel.port1.onmessage = t.step_func(function(msg) {
-                if (msg.data.ready) {
-                  resolve();
-                  return;
-                }
-                var result = msg.data;
-                var expected = expected_results[result.url];
-                if (!expected) {
-                  return;
-                }
-                assert_equals(
-                    result.mode, expected.mode,
-                    'mode of ' + expected.message +  ' must be ' +
-                    expected.mode + '.');
-                assert_equals(
-                    result.credentials, expected.credentials,
-                    'credentials of ' + expected.message +  ' must be ' +
-                    expected.credentials + '.');
-                --url_count;
-                delete expected_results[result.url];
-                if (url_count == 0) {
-                  frame.remove();
-                  service_worker_unregister_and_done(t, SCOPE);
-                }
-              });
-              worker.postMessage(
-                {port: channel.port2}, [channel.port2]);
-            });
+        css_image_test(expected_results, frame, LOCAL_URL + Date.now(),
+                       'backgroundImage', 'no-cors', 'include');
+        css_image_test(expected_results, frame, REMOTE_URL + Date.now(),
+                      'backgroundImage', 'no-cors', 'include');
+      })
+      .catch(unreached_rejection(t));
+  }, 'Verify FetchEvent for css image (backgroundImage).');
+
+async_test(function(t) {
+    var scope = SCOPE + "?img=shapeOutside";
+    var test_count = 2;
+    var expected_results = {};
+    var worker;
+    var frame;
+    service_worker_unregister_and_register(t, SCRIPT, scope)
+      .then(function(registration) {
+          worker = registration.installing;
+          return wait_for_state(t, worker, 'activated');
         })
-      .then(function() { return with_iframe(SCOPE); })
+      .then(function() { return with_iframe(scope); })
       .then(function(f) {
-        frame = f;
-
-        css_image_test(f, LOCAL_URL, 'backgroundImage', 'no-cors', 'include');
-        css_image_test(f, REMOTE_URL, 'backgroundImage', 'no-cors', 'include');
-
-        css_image_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin');
-        css_image_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'same-origin');
-
-        css_image_set_test(f, LOCAL_URL, 'backgroundImage', 'no-cors', 'include');
-        css_image_set_test(f, REMOTE_URL, 'backgroundImage', 'no-cors', 'include');
-        css_image_set_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin');
-        css_image_set_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'same-origin');
+          frame = f;
+          return create_message_promise(t, expected_results, frame,
+                                        worker, test_count, scope);
+        })
+      .then(function() {
+         css_image_test(expected_results, frame, LOCAL_URL + Date.now(),
+                        'shapeOutside', 'cors', 'same-origin');
+         css_image_test(expected_results, frame, REMOTE_URL + Date.now(),
+                        'shapeOutside', 'cors', 'same-origin');
       })
       .catch(unreached_rejection(t));
-  }, 'Verify FetchEvent for css images.');
+  }, 'Verify FetchEvent for css image (shapeOutside).');
+
+async_test(function(t) {
+    var scope = SCOPE + "?img_set=backgroundImage";
+    var test_count = 2;
+    var expected_results = {};
+    var worker;
+    var frame;
+    service_worker_unregister_and_register(t, SCRIPT, scope)
+      .then(function(registration) {
+          worker = registration.installing;
+          return wait_for_state(t, worker, 'activated');
+        })
+      .then(function() { return with_iframe(scope); })
+      .then(function(f) {
+          frame = f;
+          return create_message_promise(t, expected_results, frame,
+                                        worker, test_count, scope);
+        })
+      .then(function() {
+         css_image_set_test(expected_results, frame, LOCAL_URL + Date.now(),
+                           'backgroundImage', 'no-cors', 'include');
+         css_image_set_test(expected_results, frame, REMOTE_URL + Date.now(),
+                           'backgroundImage', 'no-cors', 'include');
+      })
+      .catch(unreached_rejection(t));
+  }, 'Verify FetchEvent for css image-set (backgroundImage).');
+
+async_test(function(t) {
+    var scope = SCOPE + "?img_set=shapeOutside";
+    var test_count = 2;
+    var expected_results = {};
+    var worker;
+    var frame;
+    service_worker_unregister_and_register(t, SCRIPT, scope)
+      .then(function(registration) {
+          worker = registration.installing;
+          return wait_for_state(t, worker, 'activated');
+        })
+      .then(function() { return with_iframe(scope); })
+      .then(function(f) {
+          frame = f;
+          return create_message_promise(t, expected_results, frame,
+                                        worker, test_count, scope);
+        })
+      .then(function() {
+         css_image_set_test(expected_results, frame, LOCAL_URL + Date.now(),
+                            'shapeOutside', 'cors', 'same-origin');
+         css_image_set_test(expected_results, frame, REMOTE_URL + Date.now(),
+                           'shapeOutside', 'cors', 'same-origin');
+      })
+      .catch(unreached_rejection(t));
+  }, 'Verify FetchEvent for css image-set (shapeOutside).');
+
 </script>
--- a/testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/fetch-request-resources.https.html
@@ -104,26 +104,24 @@ async_test(function(t) {
               worker.postMessage(
                 {port: channel.port2}, [channel.port2]);
             });
         })
       .then(function() { return with_iframe(SCOPE); })
       .then(function(f) {
         frame = f;
 
-        // TODO: Disable 'no-cors' tests for image until
-        //       AsyncOpen2 and cookie policy is supported.
-        // image_test(f, LOCAL_URL, '', 'no-cors', 'include');
-        // image_test(f, REMOTE_URL, '', 'no-cors', 'include');
+        image_test(f, LOCAL_URL, '', 'no-cors', 'include');
+        image_test(f, REMOTE_URL, '', 'no-cors', 'include');
         css_test(f, LOCAL_URL, '', 'no-cors', 'include');
         css_test(f, REMOTE_URL, '', 'no-cors', 'include');
 
         image_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin');
         image_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include');
-        image_test(f, REMOTE_URL, 'anonymous', 'cors', 'omit');
+        image_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin');
         image_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include');
 
         script_test(f, LOCAL_URL, '', 'no-cors', 'include');
         script_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin');
         script_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include');
         script_test(f, REMOTE_URL, '', 'no-cors', 'include');
         script_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin');
         script_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include');
--- a/testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/fetch-canvas-tainting-iframe.html
@@ -205,16 +205,24 @@ window.addEventListener('message', funct
         
         // CORS response
         create_test_promise(
             image_url +
             '&mode=cors&url=' +
             encodeURIComponent(remote_image_url +
                                '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
             '',
+            LOAD_ERROR), // We expect LOAD_ERROR since the server doesn't respond
+                         // with an Access-Control-Allow-Credentials header.
+        create_test_promise(
+            image_url +
+            '&mode=cors&credentials=same-origin&url=' +
+            encodeURIComponent(remote_image_url +
+                               '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
+            '',
             NOT_TAINTED),
         create_test_promise(
             image_url +
             '&mode=cors&url=' +
             encodeURIComponent(remote_image_url +
                                '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
             'anonymous',
             NOT_TAINTED),
@@ -235,19 +243,28 @@ window.addEventListener('message', funct
             'use-credentials',
             NOT_TAINTED),
         create_test_promise(
             remote_image_url +
             '&mode=cors&url=' +
             encodeURIComponent(remote_image_url +
                                '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
             '',
-            TAINTED), // We expect TAINTED since the default origin behavior here
-                      // is taint, and it doesn't matter what kind of fetch the
-                      // SW performs.
+            LOAD_ERROR), // We expect LOAD_ERROR since the server doesn't respond
+                         // with an Access-Control-Allow-Credentials header.
+        create_test_promise(
+            remote_image_url +
+            '&mode=cors&credentials=same-origin&url=' +
+            encodeURIComponent(remote_image_url +
+                               '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
+            '',
+            TAINTED), // The cross-origin no-cors request is immediately tainted.
+                      // Since this happens before the service worker interception,
+                      // it does not matter what kind of response it returns.
+                      // The result will always be tainted.
         create_test_promise(
             remote_image_url +
             '&mode=cors&url=' +
             encodeURIComponent(remote_image_url +
                                '&ACAOrigin=' + host_info['HTTPS_ORIGIN']),
             'anonymous',
             NOT_TAINTED),
         create_test_promise(