Bug 628888 - Ensure external documents loaded after page show get page show update - tests; r=dholbert; a=roc
authorBrian Birtles <birtles@gmail.com>
Fri, 11 Feb 2011 16:02:04 +0900
changeset 62342 1ed3464aaa92e923090738fd53120ef2d0413dd5
parent 62341 65938282acdbf127a3874d9068b19bcbcb1d83fc
child 62343 69e9525dff19aeeb1344eb92b132d9da17fcf296
push id18701
push userbbirtles@mozilla.com
push dateFri, 11 Feb 2011 07:02:29 +0000
treeherdermozilla-central@1ed3464aaa92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, roc
bugs628888
milestone2.0b12pre
first release with
nightly linux32
1ed3464aaa92 / 4.0b12pre / 20110211030400 / files
nightly linux64
1ed3464aaa92 / 4.0b12pre / 20110211030400 / files
nightly mac
1ed3464aaa92 / 4.0b12pre / 20110211030400 / files
nightly win32
1ed3464aaa92 / 4.0b12pre / 20110211030400 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 628888 - Ensure external documents loaded after page show get page show update - tests; r=dholbert; a=roc
content/smil/test/Makefile.in
content/smil/test/smilExtDoc_helper.svg
content/smil/test/test_smilExtDoc.xhtml
--- a/content/smil/test/Makefile.in
+++ b/content/smil/test/Makefile.in
@@ -49,16 +49,17 @@ include $(topsrcdir)/config/rules.mk
 	  db_smilCSSFromBy.js \
 	  db_smilCSSFromTo.js \
 	  db_smilCSSPaced.js \
 	  db_smilCSSPropertyList.js \
 	  db_smilMappedAttrList.js \
 	  smilAnimateMotionValueLists.js \
 	  smilTestUtils.js \
 	  smilXHR_helper.svg \
+	  smilExtDoc_helper.svg \
 	  test_smilAccessKey.xhtml \
 	  test_smilAnimateMotion.xhtml \
 	  test_smilAnimateMotionInvalidValues.xhtml \
 	  test_smilAnimateMotionOverrideRules.xhtml \
 	  test_smilBackwardsSeeking.xhtml \
 	  test_smilChangeAfterFrozen.xhtml \
 	  test_smilContainerBinding.xhtml \
 	  test_smilCrossContainer.xhtml \
@@ -68,16 +69,17 @@ include $(topsrcdir)/config/rules.mk
 	  test_smilCSSInherit.xhtml \
 	  test_smilCSSInvalidValues.xhtml \
 	  test_smilCSSPaced.xhtml \
 	  test_smilMappedAttrFromTo.xhtml \
 	  test_smilMappedAttrFromBy.xhtml \
 	  test_smilMappedAttrPaced.xhtml \
 	  test_smilReset.xhtml \
 	  test_smilRestart.xhtml \
+	  test_smilExtDoc.xhtml \
 	  test_smilFillMode.xhtml \
 	  test_smilGetStartTime.xhtml \
 	  test_smilGetSimpleDuration.xhtml \
 	  test_smilKeySplines.xhtml \
 	  test_smilKeyTimes.xhtml \
 	  test_smilKeyTimesPacedMode.xhtml \
 	  test_smilRepeatTiming.xhtml \
 	  test_smilSetCurrentTime.xhtml \
new file mode 100644
--- /dev/null
+++ b/content/smil/test/smilExtDoc_helper.svg
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+  <filter id="filter">
+    <feFlood flood-color="red">
+      <set attributeName="flood-color" to="lime" begin="0.001"/>
+    </feFlood>
+  </filter>
+</svg>
new file mode 100644
--- /dev/null
+++ b/content/smil/test/test_smilExtDoc.xhtml
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=628888
+-->
+<head>
+  <title>Test for Bug 628888 - Animations in external document sometimes don't run</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body style="margin:0px">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=628888">Mozilla Bug 628888</a>
+<p id="display"></p>
+<div id="content" style="background: red; width: 50px; height: 50px"/>
+  
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/* Test for Bug 628888 - Animations in external document sometimes don't run
+ *
+ * This bug concerns a condition where an external document is loaded after the
+ * page show event is dispatched, leaving the external document paused.
+ *
+ * To reproduce the bug we attach an external document with animation after the
+ * page show event has fired.
+ *
+ * However, it is difficult to test if the animation is playing or not since we
+ * don't receive events from animations running in an external document.
+ *
+ * Our approach is to simply render the result to a canvas (which requires
+ * elevated privileges and that is why we are using a MochiTest rather
+ * than a reftest) and poll one of the pixels to see if it changes colour.
+ *
+ * This should mean the test succeeds quickly but fails slowly.
+ */
+
+const POLL_INTERVAL     = 100;   // ms
+const POLL_TIMEOUT      = 10000; // ms
+var accumulatedWaitTime = 0;
+
+function pageShow()
+{
+  var content = document.getElementById("content");
+  content.style.filter = "url(smilExtDoc_helper.svg#filter)";
+  window.setTimeout(checkResult, 0);
+}
+
+function checkResult()
+{
+  var content = document.getElementById("content");
+  var bbox = content.getBoundingClientRect();
+
+  var canvas = document.createElement("canvas");
+  var ctx = canvas.getContext("2d");
+
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+  ctx.drawWindow(window, bbox.left, bbox.top, bbox.width, bbox.height,
+                 "rgb(255,255,255)");
+
+  var imgd = ctx.getImageData(bbox.width/2, bbox.height/2, 1, 1);
+  var isGreen = (imgd.data[0] == 0) &&
+                (imgd.data[1] == 255) &&
+                (imgd.data[2] == 0);
+  if (isGreen) {
+    ok(true, "Filter is animated as expected");
+  } else if (accumulatedWaitTime >= POLL_TIMEOUT) {
+    ok(false, "No animation detected after waiting " + POLL_TIMEOUT + "ms");
+  } else {
+    accumulatedWaitTime += POLL_INTERVAL;
+    window.setTimeout(checkResult, POLL_INTERVAL);
+    return;
+  }
+  // Hide our content since mochitests normally try to be visually "quiet"
+  content.style.display = 'none';
+  SimpleTest.finish();
+}
+window.addEventListener('pageshow', pageShow, false);
+SimpleTest.waitForExplicitFinish();
+]]>
+</script>
+</pre>
+</body>
+</html>