From 5d2f11ce8daed1dba5ae456635e8fc83d23194d1 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 25 Jun 2018 10:16:25 +1000 Subject: [PATCH] Bug 1464722 part 6 - Enable scrollbar colors test on mac. r=spohl MozReview-Commit-ID: IfBhLvGzr5u --HG-- extra : rebase_source : 088455347ba1975bcec946bba5dc2a40892d0faf --- widget/tests/mochitest.ini | 2 +- widget/tests/test_scrollbar_colors.html | 61 +++++++++++++++++-------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/widget/tests/mochitest.ini b/widget/tests/mochitest.ini index b293dccb614e..5e797b13f37b 100644 --- a/widget/tests/mochitest.ini +++ b/widget/tests/mochitest.ini @@ -10,4 +10,4 @@ skip-if = toolkit != "cocoa" 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 diff --git a/widget/tests/test_scrollbar_colors.html b/widget/tests/test_scrollbar_colors.html index aa14408050a7..d1e6b6b3e43f 100644 --- a/widget/tests/test_scrollbar_colors.html +++ b/widget/tests/test_scrollbar_colors.html @@ -46,24 +46,47 @@ const WIN_REFERENCES = [ ["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(); + }); +}