Bug 552605 - Write tests to make sure we reload images that are redirected with a Cache-Control: no-cache header. r=bz
authorJoe Drew <joe@drew.ca>
Fri, 01 Jul 2011 13:03:43 -0400
changeset 72718 39bd0f6314c3f84dc0d5d3c26c0be628dd0e6ea2
parent 72717 6b905a3845cd4825147b24287f2488134144f3f0
child 72719 47e231b4821ef917f9419e2a332853602cccc975
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs552605
milestone7.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 552605 - Write tests to make sure we reload images that are redirected with a Cache-Control: no-cache header. r=bz
docshell/test/chrome/89419.html
docshell/test/chrome/Makefile.in
docshell/test/chrome/blue.png
docshell/test/chrome/bug89419.sjs
docshell/test/chrome/bug89419_window.xul
docshell/test/chrome/red.png
docshell/test/chrome/test_bug89419.xul
modules/libpr0n/test/mochitest/Makefile.in
modules/libpr0n/test/mochitest/bug89419-iframe.html
modules/libpr0n/test/mochitest/bug89419.sjs
modules/libpr0n/test/mochitest/test_bug89419-1.html
modules/libpr0n/test/mochitest/test_bug89419-2.html
testing/mochitest/tests/SimpleTest/WindowSnapshot.js
new file mode 100644
--- /dev/null
+++ b/docshell/test/chrome/89419.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>Bug 89419</title>
+</head>
+<body>
+<img src="http://mochi.test:8888/tests/docshell/test/chrome/bug89419.sjs">
+</body>
--- a/docshell/test/chrome/Makefile.in
+++ b/docshell/test/chrome/Makefile.in
@@ -39,30 +39,36 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir	= docshell/test/chrome 
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _HTTP_FILES =	\
+                bug89419.sjs \
+                blue.png \
+                red.png \
 		92598_nostore.html \
 		92598_nostore.html^headers^ \
 		112564_nocache.html \
 		112564_nocache.html^headers^ \
 		215405_nostore.html \
 		215405_nostore.html^headers^ \
 		215405_nocache.html \
 		215405_nocache.html^headers^ \
 		582176_dummy.html \
 		582176_xml.xml \
 		582176_xslt.xsl \
 		$(NULL)
 
 _TEST_FILES =	\
+                test_bug89419.xul \
+                bug89419_window.xul \
+                89419.html \
 		test_bug92598.xul \
 		bug92598_window.xul \
 		92598_nostore.html \
 		test_bug112564.xul \
 		bug112564_window.xul \
 		test_bug113934.xul \
 		bug113934_window.xul \
 		test_bug215405.xul \
new file mode 100644
index 0000000000000000000000000000000000000000..8df58f3a5fc71ed2fc8d76cbe4e2629527b8292f
GIT binary patch
literal 2745
zc$@*b3P$ybP)<h;3K|Lk000e1NJLTq00031000390ssI2kattw00004XF*Lt006O%
z3;baP000U@X+uL$Nkc;*P;zf(X>4Tx02tGqk9Sy8X%@!6dvAK7B}6)xUPF}-K%|5!
zAVs<;#3Vo{A%p}JyCN#6C@RtvK}H1}aC9g#Rz$HdAU5m+G6<;S;3%S^vO)J*eRk*B
zot^iO^ZlOlo%a*~D1L!LQ3k98K)OgO3G?+tqhn%Gd=G#D5#WF=09;;{IB0=SIFQTV
zn}cS_i@;Yw0KB<969Krv^b0{z@c&7fCzeR%Z9?R1&lhCz<eVqxv>d5;CO<A``jXTc
zhA}fNkuNA`wHZ$O!j_+FzOefY^V3CqInV4Y=BM*#xKqxXvSk7}BY|?x&lU=D<a|@k
zhH0{Np`72&c+&;kEC4W+nY>iMOO~^ZoGFs<Fpiw(06?H5eZxz>VX0uLbmk~dhIpAo
zn3OC<O?hUht&<ZQ^%LZz38YeH2$z@2mGDtcM!J|QS_Z(En?Fk>E6mpu_4nqmY@Jvv
zrk#~7_^SW<`4<%(6N`SKSD^rsKM<q)YwpkLGHL)|PXK^y|C(D;20-fu0Mzb%%^B_o
zKrs)1mfmmfVaT^dlciFzv$b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S9+|hUIndMvZ`aX!Rox#!)tuk99~OWo4WSrbvEmY
z*S%gJwZ1)1J8w<i&<5WP4fzWBlKlRSE*q;hVKxaj^=!7^T(<dB0l(l%p-o{);fF1}
zEmyYMZY|w9y)AKDPZ6tV-*((~(e~Rr+;$u;RxZvh9@-hSvt<{$t6<mb-SN9Gm&`7y
z+C$nS+cQuaSlU)*Shl_FLwR!ftqRYIrb?~K&6SgT`FpSLbKlokrCn86^?tu_|D9^z
z>XsVgnvw&!1K9_j)JE2JeaHT;?x4oO!h;_Vi4F}M4m;dg=U7))uT@{v05`}Q#*V}t
zx%R!+_ic^L#_A?UQ{ho?RCe^~4+%fqJ{EAS<2d_x<Bvu^RyNa`3tFI-Wi8{a$*luz
zF>QS(=AGzhcWH0_$?B&=C-qKNoKihibeeQJ@AUMU+%pqr#b=+NOFB2y5#MqDeDwL7
zouQpQ7XmI^y6AK9e3wVpnM<yhPF{AteBuiGO6yhD)s}9D?&hBzes1nz^|bUl_O@Mf
zy4Kz|r|<N2x9jI_c-^>o)BonxTk~)A-Hy0@r$4TL;12)J=-srtFYjgFo4UW|0ro+`
zL#2l$kF*}u{9^V?(*SGW)S%a3_u~bR?+@{Yp8cBj>xbdIC)6h;Bf2AXqjsYw$9%@F
zJze;8_?h_G)bsq`lz*#yVfy07-`#)j9*-U$ekpl5{l}J9>aPyHp8dLGB4pyxoAftR
zlLc?p-yVL)e%JLr>ix)6&IkO5(vM~z+dl<-dN7?nJ^c>@nDhMTEkxM>000SaNLh0L
z01FcU01FcV0GgZ_0000CNkl<Z2-jm^koXS(0W$#@5yrGX00000NkvXXu0mjf#vwI2
new file mode 100644
--- /dev/null
+++ b/docshell/test/chrome/bug89419.sjs
@@ -0,0 +1,13 @@
+function handleRequest(request, response)
+{
+  var redirectstate = "/docshell/test/chrome/bug89419.sjs";
+  response.setStatusLine("1.1", 302, "Found");
+  if (getState(redirectstate) == "") {
+    response.setHeader("Location", "red.png", false);
+    setState(redirectstate, "red");
+  } else {
+    response.setHeader("Location", "blue.png", false);
+    setState(redirectstate, "");
+  }
+  response.setHeader("Cache-Control", "no-cache", false);
+}
new file mode 100644
--- /dev/null
+++ b/docshell/test/chrome/bug89419_window.xul
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<window id="89419Test"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        width="600"
+        height="600"
+        onload="setTimeout(nextTest,0);"
+        title="bug 89419 test">
+
+  <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
+  <script type="application/javascript" src="docshell_helpers.js" />
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
+
+  <script type="application/javascript"><![CDATA[
+    // Define the generator-iterator for the tests.
+    var tests = testIterator();
+
+    ////
+    // Execute the next test in the generator function.
+    //
+    function nextTest() {
+      tests.next();
+    }
+
+    ////
+    // Generator function for test steps for bug 89419:
+    // A visited link should have the :visited style applied
+    // to it when displayed on a page which was fetched from
+    // the bfcache.
+    //
+    function testIterator()
+    {
+      // Load a test page containing an image referring to the sjs that returns
+      // a different redirect every time it's loaded.
+      doPageNavigation({
+        uri: getHttpUrl("89419.html"),
+        onNavComplete: nextTest,
+        preventBFCache: true
+      });
+      yield;
+
+      var first = snapshotWindow(TestWindow.getWindow());
+
+      doPageNavigation({
+        uri: "about:blank",
+        onNavComplete: nextTest
+      });
+      yield;
+
+      var second = snapshotWindow(TestWindow.getWindow());
+      function snapshotsEqual(snap1, snap2) {
+        return compareSnapshots(snap1, snap2, true)[0];
+      }
+      ok(!snapshotsEqual(first, second), "about:blank should not be the same as the image web page");
+
+      doPageNavigation({
+        back: true,
+        onNavComplete: nextTest
+      });
+      yield;
+
+      var third = snapshotWindow(TestWindow.getWindow());
+      ok(!snapshotsEqual(third, second), "going back should not be the same as about:blank");
+      ok(snapshotsEqual(first, third), "going back should be the same as the initial load");
+
+      // Tell the framework the test is finished.  Include the final 'yield'
+      // statement to prevent a StopIteration exception from being thrown.
+      finish();
+      yield;
+    }
+
+  ]]></script>
+
+  <browser type="content-primary" flex="1" id="content" src="about:blank"/>
+</window>
new file mode 100644
index 0000000000000000000000000000000000000000..aa9ce252631ec850b02009a4a2fe9dd5e79cf09f
GIT binary patch
literal 82
zc%17D@N?(olHy`uVBq!ia0vp^j3CUx1SBVv2j2s6ii6yp7}lMWc?sn3c)B=-a9mIR
casB`U12ZEdgT&q54M1@QPgg&ebxsLQ0F+!45&!@I
new file mode 100644
--- /dev/null
+++ b/docshell/test/chrome/test_bug89419.xul
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet
+  href="chrome://mochikit/content/tests/SimpleTest/test.css"
+  type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=89419.xul
+-->
+<window title="Mozilla Bug 89419"
+  xmlns:html="http://www.w3.org/1999/xhtml"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <title>Test for Bug 89419</title>
+  <script type="application/javascript"
+    src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript"
+    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<body  xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank"
+   href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">
+   Mozilla Bug 89419</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 89419 **/
+
+SimpleTest.waitForExplicitFinish();
+window.open("bug89419_window.xul", "bug89419",
+            "chrome,width=600,height=600");
+
+]]>
+</script>
+
+</window>
--- a/modules/libpr0n/test/mochitest/Makefile.in
+++ b/modules/libpr0n/test/mochitest/Makefile.in
@@ -71,16 +71,20 @@ include $(topsrcdir)/config/rules.mk
                 test_bug497665.html \
                 bug497665-iframe.html \
                 bug497665.sjs \
                 test_bug553982.html \
                 test_bug601470.html \
                 test_bug614392.html \
                 test_bug657191.html \
                 bug657191.sjs \
+                bug89419-iframe.html \
+                bug89419.sjs \
+                test_bug89419-1.html \
+                test_bug89419-2.html \
                 $(NULL)
 
 # Tests disabled due to intermittent orange
 # test_bug435296.html disabled - See bug 578591
 # test_bug478398.html disabled - See bug 579139
 
 _CHROME_FILES = imgutils.js \
                 lime-anim-100x100.svg \
new file mode 100644
--- /dev/null
+++ b/modules/libpr0n/test/mochitest/bug89419-iframe.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>Bug 89419 iframe</title>
+<body>
+<img src="bug89419.sjs" width="100" height="100" />
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/libpr0n/test/mochitest/bug89419.sjs
@@ -0,0 +1,13 @@
+function handleRequest(request, response)
+{
+  var redirectstate = "/modules/libpr0n/test/mochitest/bug89419.sjs";
+  response.setStatusLine("1.1", 302, "Found");
+  if (getState(redirectstate) == "") {
+    response.setHeader("Location", "red.png", false);
+    setState(redirectstate, "red");
+  } else {
+    response.setHeader("Location", "blue.png", false);
+    setState(redirectstate, "");
+  }
+  response.setHeader("Cache-Control", "no-cache", false);
+}
new file mode 100644
--- /dev/null
+++ b/modules/libpr0n/test/mochitest/test_bug89419-1.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=89419
+-->
+<head>
+  <title>Test for Bug 89419</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 89419</a>
+<p id="display"></p>
+<pre id="test">
+<script type="application/javascript">
+
+var first, second, third;
+var correct, val1, val2;
+
+SimpleTest.waitForExplicitFinish();
+
+function checkFirst()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  first = snapshotWindow(iframeelem.contentWindow, false);
+
+  iframeelem.onload = checkSecond;
+  iframeelem.contentWindow.location.reload(false);
+}
+
+function checkSecond()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  second = snapshotWindow(iframeelem.contentWindow, false);
+
+  // Check that we actually reloaded.
+  [correct, val1, val2] = compareSnapshots(first, second, false);
+  ok(correct, "Image should have changed after the first reload.");
+
+  iframeelem.onload = checkThird;
+  iframeelem.contentWindow.location.reload(false);
+}
+
+function checkThird()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  third = snapshotWindow(iframeelem.contentWindow, false);
+
+  // Check that we actually reloaded.
+  [correct, val1, val2] = compareSnapshots(second, third, false);
+  ok(correct, "Image should have changed after the second reload.");
+
+  // Make sure we looped back to the first image.
+  [correct, val1, val2] = compareSnapshots(first, third, true);
+  ok(correct, "Third image should match first image.");
+
+  SimpleTest.finish();
+}
+
+</script>
+</pre>
+<div id="content"> <!-- style="display: none" -->
+<iframe id="test-iframe" src="bug89419-iframe.html" onload="checkFirst()"></iframe>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/modules/libpr0n/test/mochitest/test_bug89419-2.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=89419
+-->
+<head>
+  <title>Test for Bug 89419</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 89419</a>
+<p id="display"></p>
+<pre id="test">
+<script type="application/javascript">
+
+var first, second, third;
+var correct, val1, val2;
+
+SimpleTest.waitForExplicitFinish();
+
+function checkFirst()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  first = snapshotWindow(iframeelem.contentWindow, false);
+
+  iframeelem.onload = checkSecond;
+  iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
+}
+
+function checkSecond()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  second = snapshotWindow(iframeelem.contentWindow, false);
+
+  // Check that we actually reloaded.
+  [correct, val1, val2] = compareSnapshots(first, second, false);
+  ok(correct, "Image should have changed after the first reload.");
+
+  iframeelem.onload = checkThird;
+  iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
+}
+
+function checkThird()
+{
+  var iframeelem = document.getElementById('test-iframe');
+  third = snapshotWindow(iframeelem.contentWindow, false);
+
+  // Check that we actually reloaded.
+  [correct, val1, val2] = compareSnapshots(second, third, false);
+  ok(correct, "Image should have changed after the second reload.");
+
+  // Make sure we looped back to the first image.
+  [correct, val1, val2] = compareSnapshots(first, third, true);
+  ok(correct, "Third image should match first image.");
+
+  SimpleTest.finish();
+}
+
+</script>
+</pre>
+<div id="content"> <!-- style="display: none" -->
+<iframe id="test-iframe" src="bug89419-iframe.html" onload="checkFirst()"></iframe>
+</div>
+</body>
+</html>
--- a/testing/mochitest/tests/SimpleTest/WindowSnapshot.js
+++ b/testing/mochitest/tests/SimpleTest/WindowSnapshot.js
@@ -1,14 +1,14 @@
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
 var gWindowUtils;
 
 try {
-  gWindowUtils = window.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIDOMWindowUtils);
+  gWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
   if (gWindowUtils && !gWindowUtils.compareCanvases)
     gWindowUtils = null;
 } catch (e) {
   gWindowUtils = null;
 }
 
 function snapshotWindow(win, withCaret) {
   // drawWindow requires privileges, as might innerWidth/innerHeight if it's