Bug 1369350 Add additional delay to test_dont_use_document_colors.html since nsPresContext delays applying prefs. r=dbaron
authorBen Kelly <ben@wanderview.com>
Thu, 08 Jun 2017 05:47:16 -0700
changeset 411087 b8c1a978f8fe1a95517ed608561b5ce9e1876230
parent 411086 9819afb3f5235e4bd32a960c57795f2ecb5f4258
child 411088 505c2ccffae36c0226dd946c50771928b83c2d3d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1369350
milestone55.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 1369350 Add additional delay to test_dont_use_document_colors.html since nsPresContext delays applying prefs. r=dbaron
layout/style/test/test_dont_use_document_colors.html
--- a/layout/style/test/test_dont_use_document_colors.html
+++ b/layout/style/test/test_dont_use_document_colors.html
@@ -36,26 +36,38 @@
 <div id="six" dir="rtl">Hello</div>
 <div id="seven">Hello</div>
 
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout('nsPresContext internally delays applying prefs using an nsITimer');
 
 var cs1 = getComputedStyle(document.getElementById("one"), "");
 var cs2 = getComputedStyle(document.getElementById("two"), "");
 var cs3 = getComputedStyle(document.getElementById("three"), "");
 var cs4 = getComputedStyle(document.getElementById("four"), "");
 var cs5 = getComputedStyle(document.getElementById("five"), "");
 var cs6 = getComputedStyle(document.getElementById("six"), "");
 var cs7 = getComputedStyle(document.getElementById("seven"), "");
 
-SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 1]]}, part1);
+function pushPrefEnvAndWait(args, cb) {
+  SpecialPowers.pushPrefEnv(args, _ => {
+    // The nsPresContext delays applying a preference change until after a 0ms
+    // nsITimer fires.  The SpecialPowers.pushPrefEnv() uses setTimeout(f, 0)
+    // which may execute as a simple runnable dispatch and fire before the
+    // 0ms nsITimer.  Therefore wait an additional 1ms to allow the nsPresContext
+    // to apply the preferences.
+    setTimeout(cb, 1);
+  });
+}
+
+pushPrefEnvAndWait({'set': [['browser.display.document_color_use', 1]]}, part1);
 
 var transparentBackgroundColor;
 var inputBackgroundColor, inputColor, inputBorderTopColor;
 var inputBorderRightColor, inputBorderLeftColor, inputBorderBottomColor;
 
 function part1()
 {
 
@@ -116,17 +128,17 @@ function part1()
           "border-bottom-color applies");
     transparentBackgroundColor = cs2.backgroundColor;
     inputBackgroundColor = cs4.backgroundColor;
     inputColor = cs4.color;
     inputBorderTopColor = cs4.borderTopColor;
     inputBorderRightColor = cs4.borderRightColor;
     inputBorderLeftColor = cs4.borderLeftColor;
     inputBorderBottomColor = cs4.borderBottomColor;
-    SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 2]]}, part2);
+    pushPrefEnvAndWait({'set': [['browser.display.document_color_use', 2]]}, part2);
 }
 
 function part2()
 {
     isnot(cs1.backgroundColor, cs2.backgroundColor, "background-color transparency preserved (opaque)");
     is(cs2.backgroundColor, transparentBackgroundColor, "background-color transparency is preserved (transparent)");
     is(cs1.color, cs2.color, "color is blocked");
     is(cs1.borderTopColor, cs2.borderTopColor, "border-top-color is blocked");