Bug 1511138 - Fix / update tests. r=smaug
☠☠ backed out by 5fcc6bd202c4 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 30 Nov 2018 18:02:33 +0100
changeset 449655 4ef293b908879b56b27c1f473127db680c099a60
parent 449654 4df286b234b3daf6c315ae2f3f58f857664f88c7
child 449656 a99600391704f8752e6f05e312fe8e8cd588715a
push id35179
push useraciure@mozilla.com
push dateSun, 09 Dec 2018 21:43:27 +0000
treeherdermozilla-central@53fd96ca5aa4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1511138
milestone65.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 1511138 - Fix / update tests. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D13550
browser/components/extensions/test/browser/browser_ext_popup_background.js
dom/base/test/test_bug564863.xhtml
dom/tests/mochitest/general/test_offsets.js
layout/reftests/cssom/computed-style-cross-window-ref.html
layout/reftests/cssom/computed-style-cross-window.html
layout/style/test/chrome/bug418986-2.js
layout/style/test/test_bug1203766.html
layout/style/test/test_default_bidi_css.html
testing/web-platform/meta/css/cssom/getComputedStyle-detached-subtree.html.ini
testing/web-platform/tests/css/css-fonts/font-variant-alternates-parsing.html
--- a/browser/components/extensions/test/browser/browser_ext_popup_background.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_background.js
@@ -15,17 +15,20 @@ async function testPanel(browser, standA
            "rgb(255, 255, 255)", "Arrow fill should be set to #fff when no background is supplied and popup is standAlone");
       } else {
         let default_background =
           getComputedStyle(document.documentElement).getPropertyValue("--arrowpanel-background");
         // Need to apply the color to a node and get the computed value
         // to resolve CSS named colors such as -moz-field.
         let span = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
         span.style.color = default_background;
+        span.style.display = "none";
+        document.documentElement.appendChild(span);
         let default_background_computed = getComputedStyle(span).color;
+        span.remove();
 
         is(getComputedStyle(arrow).fill, default_background_computed, "Arrow fill should be the default one");
       }
       return;
     }
 
     is(getComputedStyle(arrowContent).backgroundColor, background, "Arrow content should have correct background");
     is(getComputedStyle(arrow).fill, background, "Arrow should have correct background");
--- a/dom/base/test/test_bug564863.xhtml
+++ b/dom/base/test/test_bug564863.xhtml
@@ -76,21 +76,22 @@ function checkHasId(test) {
   is($("div_id"), div, "div getElementById " + test);
   is($("a_id"),   a,   "a getElementById " + test);
   is($("xul_id"), xul, "xul getElementById " + test);
   is($("svg_id"), svg, "svg getElementById " + test);
   is($("ns_id"),  nsx, "ns getElementById " + test);
 }
 
 function checkHasIdNoGEBI(test) {
-  is(div_cs.color, "rgb(10, 10, 10)", "div color " + test);
-  is(a_cs.color,   "rgb(20, 20, 20)", "a color " + test);
-  is(xul_cs.color, "rgb(30, 30, 30)", "xul color " + test);
-  is(svg_cs.color, "rgb(40, 40, 40)", "svg color " + test);
-  is(nsx_cs.color, "rgb(50, 50, 50)", "nsx color " + test);
+  const connected = test != "removed node";
+  is(div_cs.color, connected ? "rgb(10, 10, 10)" : "", "div color " + test);
+  is(a_cs.color,   connected ? "rgb(20, 20, 20)" : "", "a color " + test);
+  is(xul_cs.color, connected ? "rgb(30, 30, 30)" : "", "xul color " + test);
+  is(svg_cs.color, connected ? "rgb(40, 40, 40)" : "", "svg color " + test);
+  is(nsx_cs.color, connected ? "rgb(50, 50, 50)" : "", "nsx color " + test);
 
   is(div.id, "div_id", "div id " + test);
   is(a.id,   "a_id",   "a id " + test);
   is(xul.id, "xul_id", "xul id " + test);
   is(svg.id, "svg_id", "svg id " + test);
   is (nsx.getAttribute("id"), "ns_id", "ns id " + test);
 }
 
--- a/dom/tests/mochitest/general/test_offsets.js
+++ b/dom/tests/mochitest/general/test_offsets.js
@@ -211,12 +211,12 @@ function checkCoords(element, type, left
     ok(element[type + "Width"] == 0 && element[type + "Height"] == 0,
        element.id + " has zero " + type + " width and height");
 }
 
 function gcs(element, prop)
 {
   var propVal = (element instanceof SVGElement && (prop == "width" || prop == "height")) ?
                    element.getAttribute(prop) : getComputedStyle(element, "")[prop];
-  if (propVal == "auto")
+  if (propVal == "auto" || element.id == "nonappended")
     return 0;
   return parseFloat(propVal);
 }
--- a/layout/reftests/cssom/computed-style-cross-window-ref.html
+++ b/layout/reftests/cssom/computed-style-cross-window-ref.html
@@ -13,38 +13,30 @@ var gRunCount = 2;
 function run() {
   if (--gRunCount != 0)
     return;
 
   var i = document.getElementById("i");
 
   var pout = document.getElementById("out");
   var poutnone = document.getElementById("outnone");
-  var poutdet = document.createElement("p");
   var pin = i.contentDocument.getElementsByTagName("p")[0];
   var pinnone = i.contentDocument.getElementsByTagName("p")[1];
-  var pindet = i.contentDocument.createElement("p");
 
   document.getElementById("res1").style.color =
     window.getComputedStyle(pin).color;
 
   document.getElementById("res2").style.color =
     i.contentWindow.getComputedStyle(pout).color;
 
   document.getElementById("res3").style.color =
     window.getComputedStyle(pinnone).color;
 
   document.getElementById("res4").style.color =
     i.contentWindow.getComputedStyle(poutnone).color;
-
-  document.getElementById("res5").style.color =
-    window.getComputedStyle(pindet).color;
-
-  document.getElementById("res6").style.color =
-    i.contentWindow.getComputedStyle(poutdet).color;
 }
 
 </script>
 <body onload="run()">
 
 <p id="out">This is a paragraph outside the iframe.</p>
 <div style="display:none"><p id="outnone">This is a paragraph outside the iframe.</p></div>
 
@@ -60,16 +52,8 @@ is.</div>
 
 <div style="color:fuchsia">This paragraph is the color that
 outerWindow.getComputedStyle says the display:none paragraph inside the
 iframe is.</div>
 
 <div style="color:blue">This paragraph is the color that
 iframeWindow.getComputedStyle says the display:none paragraph outside
 the iframe is.</div>
-
-<div style="color:blue">This paragraph is the color that
-outerWindow.getComputedStyle says the detached paragraph inside the
-iframe is.</div>
-
-<div style="color:fuchsia">This paragraph is the color that
-iframeWindow.getComputedStyle says the detached paragraph outside
-the iframe is.</div>
--- a/layout/reftests/cssom/computed-style-cross-window.html
+++ b/layout/reftests/cssom/computed-style-cross-window.html
@@ -14,39 +14,31 @@ var gRunCount = 2;
 function run() {
   if (--gRunCount != 0)
     return;
 
   var i = document.getElementById("i");
 
   var pout = document.getElementById("out");
   var poutnone = document.getElementById("outnone");
-  var poutdet = document.createElement("p");
   var pin = i.contentDocument.getElementsByTagName("p")[0];
   var pinnone = i.contentDocument.getElementsByTagName("p")[1];
-  var pindet = i.contentDocument.createElement("p");
 
   document.getElementById("res1").style.color =
     window.getComputedStyle(pin).color;
 
   document.getElementById("res2").style.color =
     i.contentWindow.getComputedStyle(pout).color;
 
   document.getElementById("res3").style.color =
     window.getComputedStyle(pinnone).color;
 
   document.getElementById("res4").style.color =
     i.contentWindow.getComputedStyle(poutnone).color;
 
-  document.getElementById("res5").style.color =
-    window.getComputedStyle(pindet).color;
-
-  document.getElementById("res6").style.color =
-    i.contentWindow.getComputedStyle(poutdet).color;
-
   document.documentElement.removeAttribute("class");
 }
 
 </script>
 <body onload="run()">
 
 <p id="out">This is a paragraph outside the iframe.</p>
 <div style="display:none"><p id="outnone">This is a paragraph outside the iframe.</p></div>
@@ -63,16 +55,8 @@ is.</div>
 
 <div id="res3">This paragraph is the color that
 outerWindow.getComputedStyle says the display:none paragraph inside the
 iframe is.</div>
 
 <div id="res4">This paragraph is the color that
 iframeWindow.getComputedStyle says the display:none paragraph outside
 the iframe is.</div>
-
-<div id="res5">This paragraph is the color that
-outerWindow.getComputedStyle says the detached paragraph inside the
-iframe is.</div>
-
-<div id="res6">This paragraph is the color that
-iframeWindow.getComputedStyle says the detached paragraph outside
-the iframe is.</div>
--- a/layout/style/test/chrome/bug418986-2.js
+++ b/layout/style/test/chrome/bug418986-2.js
@@ -226,21 +226,17 @@ var generateCSSLines = function (resisti
     lines += windows_versions.map(val => "(-moz-os-version: " + val + ")").join(", ") +
              " { #-moz-os-version { background-color: " + (resisting ? "red" : "green") + ";} }\n";
   }
   return lines;
 };
 
 // __green__.
 // Returns the computed color style corresponding to green.
-var green = (function () {
-  let temp = document.createElement("span");
-  temp.style.backgroundColor = "green";
-  return getComputedStyle(temp).backgroundColor;
-})();
+var green = "rgb(0, 128, 0)";
 
 // __testCSS(resisting)__.
 // Creates a series of divs and CSS using media queries to set their
 // background color. If all media queries match as expected, then
 // all divs should have a green background color.
 var testCSS = function (resisting) {
   document.getElementById("display").appendChild(generateHtmlLines(resisting));
   document.getElementById("test-css").textContent = generateCSSLines(resisting);
@@ -252,17 +248,19 @@ var testCSS = function (resisting) {
 };
 
 // __testOSXFontSmoothing(resisting)__.
 // When fingerprinting resistance is enabled, the `getComputedStyle`
 // should always return `undefined` for `MozOSXFontSmoothing`.
 var testOSXFontSmoothing = function (resisting) {
   let div = document.createElement("div");
   div.style.MozOsxFontSmoothing = "unset";
+  document.documentElement.appendChild(div);
   let readBack = window.getComputedStyle(div).MozOsxFontSmoothing;
+  div.remove();
   let smoothingPref = SpecialPowers.getBoolPref("layout.css.osx-font-smoothing.enabled", false);
   is(readBack, resisting ? "" : (smoothingPref ? "auto" : ""),
                "-moz-osx-font-smoothing");
 };
 
 // __sleep(timeoutMs)__.
 // Returns a promise that resolves after the given timeout.
 var sleep = function (timeoutMs) {
--- a/layout/style/test/test_bug1203766.html
+++ b/layout/style/test/test_bug1203766.html
@@ -31,82 +31,82 @@ body > .a { display: none; color: green;
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(function() {
 
   // Element that goes from being out of the document to in the document.
   var e = document.createElement("div");
   e.className = "x";
   var cs = getComputedStyle(e);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   document.body.appendChild(e);
   is(cs.color, "rgb(0, 128, 0)");
 
   // Element that goes from in the document (and display:none) to out of
   // the document.
   e = document.querySelector(".y");
   cs = getComputedStyle(e);
   is(cs.color, "rgb(255, 0, 0)");
   e.remove();
-  is(cs.color, "rgb(0, 128, 0)");
+  is(cs.color, "");
 
   // Element that is removed from an out-of-document tree.
   e = document.createElement("div");
   f = document.createElement("span");
   f.className = "z";
   e.appendChild(f);
   cs = getComputedStyle(f);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   f.remove();
-  is(cs.color, "rgb(0, 128, 0)");
+  is(cs.color, "");
 
   // Element going from not in document to in document and display:none.
   e = document.createElement("div");
   e.className = "a";
   cs = getComputedStyle(e);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   document.body.appendChild(e);
   is(cs.color, "rgb(0, 128, 0)");
 
   // Element going from not in document to in document and child of
   // display:none element.
   e = document.createElement("div");
   e.className = "c";
   cs = getComputedStyle(e);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   document.querySelector(".b").appendChild(e);
   is(cs.color, "rgb(0, 128, 0)");
 
   // Element that is added to an out-of-document tree.
   e = document.createElement("div");
   e.className = "d";
   f = document.createElement("span");
   f.className = "e";
   cs = getComputedStyle(f);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   e.appendChild(f);
-  is(cs.color, "rgb(0, 128, 0)");
+  is(cs.color, "");
 
   // Element that is outside the document when an attribute is modified to
   // cause a different rule to match.
   e = document.createElement("div");
   e.className = "f";
   cs = getComputedStyle(e);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   e.className = "g";
-  is(cs.color, "rgb(0, 128, 0)");
+  is(cs.color, "");
 
   // Element that is outside the document when an ancestor is modified to
   // cause a different rule to match.
   e = document.createElement("div");
   e.className = "h";
   f = document.createElement("span");
   f.className = "i";
   e.appendChild(f);
   cs = getComputedStyle(f);
-  is(cs.color, "rgb(255, 0, 0)");
+  is(cs.color, "");
   e.className = "j";
-  is(cs.color, "rgb(0, 128, 0)");
+  is(cs.color, "");
 
   SimpleTest.finish();
 });
 </script>
 </pre>
--- a/layout/style/test/test_default_bidi_css.html
+++ b/layout/style/test/test_default_bidi_css.html
@@ -16,16 +16,17 @@
 
 /** Test for default bidi css  **/
 function styleOf(name, attributes) {
     var element = document.createElement(name);
     for (var name in attributes) {
         var value = attributes[name];
         element.setAttribute(name, value);
     }
+    document.body.appendChild(element);
     return getComputedStyle(element);
 }
 
 var tests = [
     ['div', {}, 'ltr', 'isolate'],
     ['div', {'dir': 'ltr'}, 'ltr', 'isolate'],
     ['div', {'dir': 'rtl'}, 'rtl', 'isolate'],
     ['div', {'dir': 'auto'}, 'ltr', 'isolate'],
--- a/testing/web-platform/meta/css/cssom/getComputedStyle-detached-subtree.html.ini
+++ b/testing/web-platform/meta/css/cssom/getComputedStyle-detached-subtree.html.ini
@@ -1,15 +1,9 @@
 [getComputedStyle-detached-subtree.html]
-  [getComputedStyle returns no style for detached element]
-    expected: FAIL
-
   [getComputedStyle returns no style for element in non-rendered iframe (display: none)]
     expected: FAIL
 
   [getComputedStyle returns no style for element outside the flat tree]
     expected: FAIL
 
   [getComputedStyle returns no style for descendant outside the flat tree]
     expected: FAIL
-
-  [getComputedStyle returns no style for shadow tree outside of flattened tree]
-    expected: FAIL
--- a/testing/web-platform/tests/css/css-fonts/font-variant-alternates-parsing.html
+++ b/testing/web-platform/tests/css/css-fonts/font-variant-alternates-parsing.html
@@ -1,18 +1,19 @@
 <!doctype html>
 <meta charset="utf-8">
 <title>CSS Test:  font-variant-alternates: historical-forms; parses case-insensitively</title>
 <link rel="author" title="Emilio Cobos Álvarez" href="emilio@crisal.io">
 <link rel="help" href="https://www.w3.org/TR/css-fonts-4/#font-variant-alternates-prop">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
+<div></div>
 <script>
 test(function() {
-  let div = document.createElement('div');
+  let div = document.querySelector('div');
   div.style.fontVariantAlternates = "Historical-Forms";
   assert_equals(
     getComputedStyle(div).fontVariantAlternates,
     "historical-forms",
     "historical-forms is parsed case-insensitively"
   );
 });
 </script>