Bug 641731 tests: reftests for :visited status in image documents. r=dbaron
authorDaniel Holbert <dholbert@cs.stanford.edu>
Sat, 29 Oct 2011 02:44:27 -0700
changeset 79421 f606afe21762e80b3bb0d34c56be09c2313d96e3
parent 79420 2052ffffcb6bf245889a92814e06e9408992d1cc
child 79422 78ffa0184082691b34e3d8b1ba0fa64352794393
push id21395
push userbmo@edmorley.co.uk
push dateSun, 30 Oct 2011 16:33:37 +0000
treeherdermozilla-central@945f64763a70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs641731
milestone10.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 641731 tests: reftests for :visited status in image documents. r=dbaron
layout/reftests/svg/as-image/reftest.list
layout/reftests/svg/as-image/svg-image-visited-1-helper.svg
layout/reftests/svg/as-image/svg-image-visited-1.html
layout/reftests/svg/as-image/svg-image-visited-2-helper.svg
layout/reftests/svg/as-image/svg-image-visited-2.html
layout/style/test/Makefile.in
layout/style/test/test_visited_reftests.html
--- a/layout/reftests/svg/as-image/reftest.list
+++ b/layout/reftests/svg/as-image/reftest.list
@@ -110,8 +110,19 @@ random == img-and-image-1.html img-and-i
 == svg-image-datauri-1.html            lime100x100.svg
 HTTP == svg-image-datauri-1.html       lime100x100.svg
 fails-if(Android) == svg-image-external-1.html           lime100x100.svg
 HTTP == svg-image-external-1.html      blue100x100.svg
 == svg-stylesheet-datauri-1.html       lime100x100.svg
 HTTP == svg-stylesheet-datauri-1.html  lime100x100.svg
 random == svg-stylesheet-external-1.html      lime100x100.svg # see bug 629885 comment 9
 HTTP == svg-stylesheet-external-1.html blue100x100.svg
+
+# test that :visited status is ignored in image documents
+# We load the images directly first, to be sure history is populated.
+# It's also good to verify that the helper images don't match lime100x100.svg
+# in non-image contexts, but for that to work, we have to reliably count on
+# :visited styles loading (asynchronously), so we test that in
+# layout/style/test/test_visited_reftests.html instead of the reftest harness.
+!= svg-image-visited-1-helper.svg about:blank
+== svg-image-visited-1.html       lime100x100.svg
+!= svg-image-visited-2-helper.svg about:blank
+== svg-image-visited-2.html       lime100x100.svg
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/svg-image-visited-1-helper.svg
@@ -0,0 +1,23 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     height="100" width="100">
+  <style>
+  <![CDATA[
+      a:link {/* Note: an a:link block was needed to trigger bug 641731. */ }
+      a:link    > rect  { fill: lime; }
+      a:visited > rect  { fill: red;  }
+  ]]>
+  </style>
+
+  <!-- Note: the <a> element below links to _this document_, so it'll
+       normally be treated as visited. However, in an image context, we want to
+       ignore visitedness. -->
+  <a xlink:href="" id="foo">
+    <rect x="0" y="0"  width="100" height="100" fill="orange"/>
+  </a>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/svg-image-visited-1.html
@@ -0,0 +1,21 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html class="reftest-wait">
+  <head>
+    <title>Test for bug 641731</title>
+    <script>
+      function snapshot() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+
+  <!-- Wait 100ms before taking snapshot, to be sure we've allowed time for
+       :visited style inside the image to resolve (which it hopefully won't) -->
+  <body style="margin: 0" onload="setTimeout(snapshot, 100)">
+    <img src="svg-image-visited-1-helper.svg">
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/svg-image-visited-2-helper.svg
@@ -0,0 +1,22 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     height="100" width="100">
+  <style>
+  <![CDATA[
+      a:link    > rect  { fill: lime; }
+      a:visited > rect  { fill: red;  }
+  ]]>
+  </style>
+
+  <!-- Note: the <a> element below links to _this document_, so it'll
+       normally be treated as visited. However, in an image context, we want to
+       ignore visitedness. -->
+  <a xlink:href="" id="foo">
+    <rect x="0" y="0"  width="100" height="100" fill="orange"/>
+  </a>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/as-image/svg-image-visited-2.html
@@ -0,0 +1,21 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/licenses/publicdomain/
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html class="reftest-wait">
+  <head>
+    <title>Test for bug 641731</title>
+    <script>
+      function snapshot() {
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+
+  <!-- Wait 100ms before taking snapshot, to be sure we've allowed time for
+       :visited style inside the image to resolve (which it hopefully won't) -->
+  <body style="margin: 0" onload="setTimeout(snapshot, 100)">
+    <img src="svg-image-visited-2-helper.svg">
+  </body>
+</html>
--- a/layout/style/test/Makefile.in
+++ b/layout/style/test/Makefile.in
@@ -228,16 +228,19 @@ GARBAGE += css_properties.js
 		visited_image_loading_frame_empty.html \
 		test_load_events_on_stylesheets.html \
 		$(NULL)
 
 _VISITED_REFTEST_FILES = \
 		$(shell find $(topsrcdir)/layout/reftests/css-visited/ -name '*.html' -o -name '*.xhtml') \
 		$(topsrcdir)/layout/reftests/svg/pseudo-classes-02.svg \
 		$(topsrcdir)/layout/reftests/svg/pseudo-classes-02-ref.svg \
+		$(topsrcdir)/layout/reftests/svg/as-image/lime100x100.svg \
+		$(topsrcdir)/layout/reftests/svg/as-image/svg-image-visited-1-helper.svg \
+		$(topsrcdir)/layout/reftests/svg/as-image/svg-image-visited-2-helper.svg \
 		$(NULL)
 
 ifneq (mobile,$(MOZ_BUILD_APP))
 _BROWSER_FILES = \
 		browser_bug453896.js \
 		bug453896_iframe.html \
 		media_queries_iframe.html \
 		$(NULL)
--- a/layout/style/test/test_visited_reftests.html
+++ b/layout/style/test/test_visited_reftests.html
@@ -70,16 +70,18 @@ var gTests = [
   "== selector-any-sibling-1.html selector-any-sibling-1-ref.html",
   "== selector-any-sibling-2.html selector-any-sibling-2-ref.html",
   "== subject-of-selector-descendant-1.html subject-of-selector-1-ref.html",
   "== subject-of-selector-descendant-2.xhtml subject-of-selector-descendant-2-ref.xhtml",
   "== subject-of-selector-child-1.html subject-of-selector-1-ref.html",
   "== subject-of-selector-adj-sibling-1.html subject-of-selector-1-ref.html",
   "== subject-of-selector-any-sibling-1.html subject-of-selector-1-ref.html",
   "== inherit-keyword-1.xhtml inherit-keyword-1-ref.html",
+  "!= svg-image-visited-1-helper.svg lime100x100.svg",
+  "!= svg-image-visited-2-helper.svg lime100x100.svg",
   // FIXME: commented out because dynamic changes on the non-first-line
   // part of the test don't work right when the link becomes visited.
   //"== first-line-1.html first-line-1-ref.html",
   "== white-to-transparent-1.html white-to-transparent-1-ref.html",
   "== link-root-1.xhtml link-root-1-ref.xhtml",
   "== mathml-links.html mathml-links-ref.html",
 ];