Bug 1326189 - (wip) add tests for applying caret-color to visited link.
MozReview-Commit-ID: 46DfVPNC46W
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-visited/caret-color-on-visited-1-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<style>
+@font-face {
+ font-family: Ahem;
+ src: url(../fonts/Ahem.ttf);
+}
+div {
+ font: 16px/1 Ahem;
+ width: 1em;
+ background: green;
+}
+</style>
+<div><span></span></div>
+<script>
+let $div = document.querySelector('div');
+let $span = document.querySelector('span');
+$div.style.height = $span.getBoundingClientRect().height + 'px';
+</script>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-visited/caret-color-on-visited-1.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<style>
+@font-face {
+ font-family: Ahem;
+ src: url(../fonts/Ahem.ttf);
+}
+a {
+ /*display: block;*/
+ caret-color: red;
+ /*font: 16px/1 Ahem;*/
+ outline: none;
+ border: 0 none;
+ resize: none;
+ padding: 0;
+ margin: 0;
+ height: 16px;
+}
+a:visited {
+ caret-color: green;
+}
+textarea {
+ font: 16px/1 Ahem;
+ outline: none;
+ border: 0 none;
+ resize: none;
+ padding: 0;
+ margin: 0;
+}
+</style>
+<a href="visited-page.html" contenteditable><textarea></textarea></a>
+<script>
+ // document.querySelector('a').focus();
+ document.querySelector('textarea').focus();
+</script>
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -39,16 +39,18 @@ TEST_HARNESS_FILES.testing.mochitest.tes
TEST_HARNESS_FILES.testing.mochitest.tests.layout.style.test['css-visited'] += [
'/layout/reftests/css-visited/border-1-ref.html',
'/layout/reftests/css-visited/border-1.html',
'/layout/reftests/css-visited/border-2-ref.html',
'/layout/reftests/css-visited/border-2a.html',
'/layout/reftests/css-visited/border-2b.html',
'/layout/reftests/css-visited/border-collapse-1-ref.html',
'/layout/reftests/css-visited/border-collapse-1.html',
+ '/layout/reftests/css-visited/caret-color-on-visited-1-ref.html',
+ '/layout/reftests/css-visited/caret-color-on-visited-1.html',
'/layout/reftests/css-visited/color-choice-1-ref.html',
'/layout/reftests/css-visited/color-choice-1.html',
'/layout/reftests/css-visited/color-on-bullets-1-ref.html',
'/layout/reftests/css-visited/color-on-bullets-1.html',
'/layout/reftests/css-visited/color-on-link-1-ref.html',
'/layout/reftests/css-visited/color-on-link-1.html',
'/layout/reftests/css-visited/color-on-link-before-1.html',
'/layout/reftests/css-visited/color-on-text-decoration-1-ref.html',
--- a/layout/style/test/test_visited_reftests.html
+++ b/layout/style/test/test_visited_reftests.html
@@ -18,25 +18,29 @@ https://bugzilla.mozilla.org/show_bug.cg
// Because link-coloring for visited links is asynchronous, running
// reftests that involve link coloring requires that we poll for the
// correct result until all links are styled correctly.
// A requirement of these reftests is that the reference rendering is
// styled correctly when loaded. We only poll for the tests.
+// Enlarge the caret width for caret related tests.
+SpecialPowers.pushPrefEnv({'set': [['ui.caretWidth', 16]]});
+
var gTests = [
// there's also an implicit "load visited-page.html" at the start,
// thanks to the code below.
// IMPORTANT NOTE: For these tests, the test and reference are not
// snapshotted in the same way. The REFERENCE (second file) is
// assumed to be complete when loaded, but we poll for visited link
// coloring on the TEST (first file) until the test passes.
"== pseudo-classes-02.svg pseudo-classes-02-ref.svg",
+ "== caret-color-on-visited-1.html caret-color-on-visited-1-ref.html",
"!= color-on-link-1-ref.html color-on-visited-1-ref.html",
"== color-on-link-1.html color-on-link-1-ref.html",
"== color-on-link-before-1.html color-on-link-1-ref.html",
"== color-on-visited-1.html color-on-visited-1-ref.html",
"== color-on-visited-before-1.html color-on-visited-1-ref.html",
"!= content-color-on-link-before-1-ref.html content-color-on-visited-before-1-ref.html",
"== content-color-on-link-before-1.html content-color-on-link-before-1-ref.html",
"== content-color-on-visited-before-1.html content-color-on-visited-before-1-ref.html",
@@ -116,17 +120,17 @@ function visitedPageLoad()
for (var i = 0; i < gTests.length; ++i) {
startTest(i);
}
RemoveFinishDependency();
}
function takeSnapshot(iframe_element)
{
- return snapshotWindow(iframe_element.contentWindow, false);
+ return snapshotWindow(iframe_element.contentWindow, true);
}
function passes(op, shot1, shot2)
{
var [correct, s1, s2] = compareSnapshots(shot1, shot2, op == "==");
return correct;
}
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1674,16 +1674,20 @@ toolbar#nav-bar {
'prefs_general.js')]
prefs = {}
for path in preferences:
prefs.update(Preferences.read_prefs(path))
prefs.update(self.extraPrefs(options.extraPrefs))
+ # Disable the caret blinking since it causes false positives for image diffs
+ prefs['ui.caretBlinkTime'] = -1
+ prefs['ui.caretWidth'] = 1
+
# Bug 1262954: For windows XP + e10s disable acceleration
if platform.system() in ("Windows", "Microsoft") and \
'5.1' in platform.version() and options.e10s:
prefs['layers.acceleration.disabled'] = True
# interpolate preferences
interpolation = {
"server": "%s:%s" %