Bug 1326189 - (wip) add tests for applying caret-color to visited link. draft
authorJeremy Chen <jeremychen@mozilla.com>
Thu, 19 Jan 2017 23:07:25 +0800
changeset 463665 995ae4f32b9881e1520cf8a903aeaab8b335575c
parent 463664 6dbd2ddda19b5c74f822df0f753253e21a81fb1a
child 542741 56b804c77242407b94737cd13c28b21e86bc3b7b
push id42137
push userjichen@mozilla.com
push dateThu, 19 Jan 2017 15:08:06 +0000
bugs1326189
milestone53.0a1
Bug 1326189 - (wip) add tests for applying caret-color to visited link. MozReview-Commit-ID: 46DfVPNC46W
layout/reftests/css-visited/caret-color-on-visited-1-ref.html
layout/reftests/css-visited/caret-color-on-visited-1.html
layout/style/test/moz.build
layout/style/test/test_visited_reftests.html
testing/mochitest/runtests.py
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" %