Bug 1331899 - Ensure that asserts in referer-policy tests occur in a test(), r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Thu, 12 Jan 2017 17:58:52 +0000
changeset 375130 e019af713fb2688e3b9614716111c3bd89320881
parent 375129 da044e3791dc7d3201feb8f19853fbd3605bbf5f
child 375131 e3eb95a2fa40d6ff908041ef9a4e395363279299
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs1331899
milestone53.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 1331899 - Ensure that asserts in referer-policy tests occur in a test(), r=Ms2ger MozReview-Commit-ID: 1LkrePKavGP
testing/web-platform/tests/referrer-policy/generic/common.js
testing/web-platform/tests/referrer-policy/generic/referrer-policy-test-case.js
--- a/testing/web-platform/tests/referrer-policy/generic/common.js
+++ b/testing/web-platform/tests/referrer-policy/generic/common.js
@@ -106,17 +106,17 @@ function queryIframe(url, callback, refe
       return;
 
     callback(event.data, url);
     window.removeEventListener("message", listener);
   }
   window.addEventListener("message", listener);
 }
 
-function queryImage(url, callback, attributes, referrerPolicy) {
+function queryImage(url, callback, attributes, referrerPolicy, test) {
   // For images, we'll test:
   // - images in a `srcdoc` frame to ensure that it uses the referrer
   //   policy of its parent,
   // - images in a top-level document,
   // - and images in a `srcdoc` frame with its own referrer policy to
   //   override its parent.
 
   var noSrcDocPolicy = new Promise((resolve, reject) => {
@@ -147,21 +147,21 @@ function queryImage(url, callback, attri
   });
 
   var pagePolicy = new Promise((resolve, reject) => {
     loadImageInWindow(url, function (img) {
       resolve(decodeImageData(extractImageData(img)));
     }, attributes, window);
   });
 
-  Promise.all([noSrcDocPolicy, srcDocPolicy, pagePolicy]).then(values => {
+  Promise.all([noSrcDocPolicy, srcDocPolicy, pagePolicy]).then(test.step_func(values => {
     assert_equals(values[0].headers.referer, values[2].headers.referer, "Referrer inside 'srcdoc' without its own policy should be the same as embedder's referrer.");
     assert_equals((iframePolicy === "no-referrer" ? undefined : document.location.href), values[1].headers.referer, "Referrer inside 'srcdoc' should use the iframe's policy if it has one");
     callback(wrapResult(url, values[2]), url);
-  });
+  }));
 }
 
 function queryXhr(url, callback) {
   var xhr = new XMLHttpRequest();
   xhr.open('GET', url, true);
   xhr.onreadystatechange = function(e) {
     if (this.readyState == 4 && this.status == 200) {
       var server_data = JSON.parse(this.responseText);
--- a/testing/web-platform/tests/referrer-policy/generic/referrer-policy-test-case.js
+++ b/testing/web-platform/tests/referrer-policy/generic/referrer-policy-test-case.js
@@ -65,34 +65,36 @@ function ReferrerPolicyTestCase(scenario
                           "?redirection=" + t._scenario["redirection"] +
                           "&cache_destroyer=" + (new Date()).getTime();
     },
 
     _constructExpectedReferrerUrl: function() {
       t._expectedReferrerUrl = referrerUrlResolver[t._scenario.referrer_url]();
     },
 
-    _invokeSubresource: function(callback) {
+    _invokeSubresource: function(callback, test) {
       var invoker = subresourceInvoker[t._scenario.subresource];
 
       // Depending on the delivery method, extend the subresource element with
       // these attributes.
       var elementAttributesForDeliveryMethod = {
         "attr-referrer":  {referrerPolicy: t._scenario.referrer_policy},
         "rel-noreferrer": {rel: "noreferrer"}
       };
 
       var delivery_method = t._scenario.delivery_method;
 
       if (delivery_method in elementAttributesForDeliveryMethod) {
         invoker(t._subresourceUrl,
                 callback,
-                elementAttributesForDeliveryMethod[delivery_method], t._scenario.referrer_policy);
+                elementAttributesForDeliveryMethod[delivery_method],
+                t._scenario.referrer_policy,
+                test);
       } else {
-        invoker(t._subresourceUrl, callback, null, t._scenario.referrer_policy);
+        invoker(t._subresourceUrl, callback, null, t._scenario.referrer_policy, test);
       }
 
     },
 
     start: function() {
       t._constructSubresourceUrl();
       t._constructExpectedReferrerUrl();
 
@@ -111,15 +113,15 @@ function ReferrerPolicyTestCase(scenario
                         t._scenario.referrer_url + "'.");
           assert_equals(result.headers.referer,
                         t._expectedReferrerUrl,
                         "Reported Referrer URL from HTTP header is '" +
                         t._expectedReferrerUrl + "'");
         }, "Reported Referrer URL is as expected: " + t._scenario.referrer_url);
 
         test.done();
-      })
+      }, test);
 
     }
   }
 
   return t;
 }