Bug 1184351 - Remove a race in the picture-tag cases in mixed-content web platform tests. r=jgraham, a=test-only
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 29 Apr 2016 23:13:46 -0400
changeset 333222 32b390cabb649a6d57014cbc27580e22dbcad49a
parent 333221 54232e1311eec1eeea1ba3ea25e9ec6eafcb94fd
child 333223 fcf65f9b9fad4fd143f123c1411a0a1f6b0180a5
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham, test-only
bugs1184351
milestone48.0a2
Bug 1184351 - Remove a race in the picture-tag cases in mixed-content web platform tests. r=jgraham, a=test-only
testing/web-platform/meta/mixed-content/blockable/http-csp/same-host-http/picture-tag/top-level/no-redirect/opt-in-blocks.https.html.ini
testing/web-platform/meta/mixed-content/blockable/no-opt-in/cross-origin-http/picture-tag/top-level/no-redirect/no-opt-in-blocks.https.html.ini
testing/web-platform/meta/mixed-content/blockable/no-opt-in/same-host-http/picture-tag/top-level/no-redirect/no-opt-in-blocks.https.html.ini
testing/web-platform/tests/mixed-content/generic/common.js
deleted file mode 100644
--- a/testing/web-platform/meta/mixed-content/blockable/http-csp/same-host-http/picture-tag/top-level/no-redirect/opt-in-blocks.https.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[opt-in-blocks.https.html]
-  type: testharness
-  disabled:
-    if debug and (os == "linux"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-    if e10s and (os == "linux"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
deleted file mode 100644
--- a/testing/web-platform/meta/mixed-content/blockable/no-opt-in/cross-origin-http/picture-tag/top-level/no-redirect/no-opt-in-blocks.https.html.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-[no-opt-in-blocks.https.html]
-  type: testharness
-  disabled:
-    if e10s and (os == "linux"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-    if e10s and (os == "mac"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-  [opt_in_method: no-opt-in\n                                 origin: cross-origin-http\n                                 source_scheme: https\n                                 context_nesting: top-level\n                                 redirection: no-redirect\n                                 subresource: picture-tag\n                                 expectation: blocked]
-    expected:
-      if debug and (os == "linux"): FAIL
-      if debug and (os == "mac"): FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/mixed-content/blockable/no-opt-in/same-host-http/picture-tag/top-level/no-redirect/no-opt-in-blocks.https.html.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-[no-opt-in-blocks.https.html]
-  type: testharness
-  disabled:
-    if debug and (os == "linux"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-    if e10s and (os == "linux"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-    if e10s and (os == "mac"): https://bugzilla.mozilla.org/show_bug.cgi?id=1184351
-  [opt_in_method: no-opt-in\n                                 origin: same-host-http\n                                 source_scheme: https\n                                 context_nesting: top-level\n                                 redirection: no-redirect\n                                 subresource: picture-tag\n                                 expectation: blocked]
-    expected:
-      if debug and (os == "mac"): FAIL
-
--- a/testing/web-platform/tests/mixed-content/generic/common.js
+++ b/testing/web-platform/tests/mixed-content/generic/common.js
@@ -102,21 +102,32 @@ function bindEvents(element, resolveEven
 function createElement(tagName, attrs, parent, doBindEvents) {
   var element = document.createElement(tagName);
 
   if (doBindEvents)
     bindEvents(element);
 
   // We set the attributes after binding to events to catch any
   // event-triggering attribute changes. E.g. form submission.
-  setAttributes(element, attrs);
+  //
+  // But be careful with images: unlike other elements they will start the load
+  // as soon as the attr is set, even if not in the document yet, and sometimes
+  // complete it synchronously, so the append doesn't have the effect we want.
+  // So for images, we want to set the attrs after appending, whereas for other
+  // elements we want to do it before appending.
+  var isImg = (tagName == "img");
+  if (!isImg)
+    setAttributes(element, attrs);
 
   if (parent)
     parent.appendChild(element);
 
+  if (isImg)
+    setAttributes(element, attrs);
+
   return element;
 }
 
 function createRequestViaElement(tagName, attrs, parent) {
   return createElement(tagName, attrs, parent, true).eventPromise;
 }
 
 /**