Bug 1464722 part 6 - Enable scrollbar colors test on mac. r?spohl draft
authorXidorn Quan <me@upsuper.org>
Mon, 25 Jun 2018 10:16:25 +1000
changeset 810031 8c53ad505a7781bf05d09682b5af27723e799da9
parent 810030 7f14abc673f5e1144b1ad2e7e1bb63d3f6e2ea3f
child 811798 bccc1fe546bdb1f389893cb68da99b1e67019edb
child 811799 968c537a2ace25acc3fc48c03598d08a96eb76b4
child 811976 4a7b47cb3fb2b97e7c3d625e4a728c453d775116
push id113864
push userxquan@mozilla.com
push dateMon, 25 Jun 2018 00:30:18 +0000
reviewersspohl
bugs1464722
milestone62.0a1
Bug 1464722 part 6 - Enable scrollbar colors test on mac. r?spohl MozReview-Commit-ID: IfBhLvGzr5u
widget/tests/mochitest.ini
widget/tests/test_scrollbar_colors.html
--- a/widget/tests/mochitest.ini
+++ b/widget/tests/mochitest.ini
@@ -5,9 +5,9 @@ support-files = utils.js
 subsuite = clipboard
 skip-if = toolkit == "cocoa" || (toolkit == 'android' && debug) # Mac: Bug 933303, Android bug 1285414
 [test_keypress_event_with_alt_on_mac.html]
 skip-if = toolkit != "cocoa"
 [test_picker_no_crash.html]
 skip-if = toolkit != "windows" || e10s # Bug 1267491
 support-files = window_picker_no_crash_child.html
 [test_scrollbar_colors.html]
-skip-if = os == 'mac' || os == 'linux' || os == 'android' # bug 1460109
+skip-if = os == 'linux' || os == 'android' # bug 1460109
--- a/widget/tests/test_scrollbar_colors.html
+++ b/widget/tests/test_scrollbar_colors.html
@@ -41,29 +41,52 @@ const WIN_REFERENCES = [
   // Yellow background
   ["255,255,0", 6889],
   // Blue scrollbar face
   ["0,0,255", 540],
   // Cyan scrollbar track
   ["0,255,255", 2487],
 ];
 
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({
-  "set": [["layout.css.scrollbar-colors.enabled", true]],
-}, function() {
-  document.querySelector('#style').textContent = `
-    .outer {
-      scrollbar-face-color: blue;
-      scrollbar-track-color: cyan;
-    }
-  `;
+const MAC_REFERENCES = [
+  // Yellow background
+  ["255,255,0", 7225],
+  // Blue scrollbar face
+  ["0,0,255", 416],
+  // Cyan scrollbar track
+  ["0,255,255", 1760],
+];
 
-  let outer = document.querySelector('.outer');
-  let canvas = snapshotRect(window, outer.getBoundingClientRect());
-  let stats = countPixels(canvas);
-  for (let [color, count] of WIN_REFERENCES) {
-    let value = stats.get(color);
-    is(value, count, `Pixel count of color ${color}`);
-  }
-  SimpleTest.finish();
-});
+let outer = document.querySelector('.outer');
+let outerRect = outer.getBoundingClientRect();
+if (outerRect.width == outer.clientWidth &&
+    outerRect.height == outer.clientHeight) {
+  ok(true, "Using overlay scrollbar, skip this test");
+} else {
+  SimpleTest.waitForExplicitFinish();
+  SpecialPowers.pushPrefEnv({
+    "set": [["layout.css.scrollbar-colors.enabled", true]],
+  }, function() {
+    document.querySelector('#style').textContent = `
+      .outer {
+        scrollbar-face-color: blue;
+        scrollbar-track-color: cyan;
+      }
+    `;
+
+    let canvas = snapshotRect(window, outerRect);
+    let stats = countPixels(canvas);
+    let references;
+    if (navigator.platform.startsWith("Win")) {
+      references = WIN_REFERENCES;
+    } else if (navigator.platform.startsWith("Mac")) {
+      references = MAC_REFERENCES;
+    } else {
+      ok(false, "Unsupported platform");
+    }
+    for (let [color, count] of references) {
+      let value = stats.get(color);
+      is(value, count, `Pixel count of color ${color}`);
+    }
+    SimpleTest.finish();
+  });
+}
 </script>