4 https://bugzilla.mozilla.org/show_bug.cgi?id=867758
7 <title>Test for Bug
867758</title>
8 <script type=
"application/javascript" src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <script type=
"application/javascript" src=
"chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
10 <script type=
"application/javascript" src=
"imgutils.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=867758">Mozilla Bug
867758</a>
19 <script type=
"application/javascript;version=1.8">
20 /** Test for Bug
867758**/
22 SimpleTest.waitForExplicitFinish();
24 const FAILURE_TIMEOUT =
120000; // Fail early after
120 seconds (
2 minutes)
26 const Cc = Components.classes;
27 const Ci = Components.interfaces;
28 const Cu = Components.utils;
29 const gContent = document.getElementById(
"content");
31 var gDispatched = false;
32 var gRanEvent = false;
37 var gFinished = false;
38 var gFirstRequest = null;
40 function cleanUpAndFinish() {
44 var imgLoadingContent = gImg1.QueryInterface(Ci.nsIImageLoadingContent);
45 imgLoadingContent.removeObserver(gOuter);
47 imgLoadingContent = gImg2.QueryInterface(Ci.nsIImageLoadingContent);
48 imgLoadingContent.removeObserver(gOuter);
55 function frameUpdate(aRequest) {
57 var util = window.getInterface(Ci.nsIDOMWindowUtils);
58 util.runBeforeNextEvent(function() {
62 gFirstRequest = aRequest;
63 } else if (aRequest != gFirstRequest) {
64 ok(!gRanEvent,
"Should not have run event before all frame update events occurred!");
70 ok(false,
"timing out after " + FAILURE_TIMEOUT +
"ms. ");
78 // Create, customize & attach decoder observer
79 var obs = new ImageDecoderObserverStub();
80 obs.frameUpdate = frameUpdate;
82 gOuter = Cc[
"@mozilla.org/image/tools;1"].getService(Ci.imgITools).createScriptedObserver(obs);
83 var imgLoadingContent = gImg1.QueryInterface(Ci.nsIImageLoadingContent);
84 imgLoadingContent.addObserver(gOuter);
86 imgLoadingContent = gImg2.QueryInterface(Ci.nsIImageLoadingContent);
87 imgLoadingContent.addObserver(gOuter);
89 // We want to test the cold loading behavior, so clear cache in case an
90 // earlier test got our image in there already.
93 // These are two copies of the same image; hence, they have the same frame rate.
94 gImg1.src =
"animated1.gif";
95 gImg2.src =
"animated2.gif";
97 gContent.appendChild(gImg1);
98 gContent.appendChild(gImg2);
100 // In case something goes wrong, fail earlier than mochitest timeout,
101 // and with more information.
102 setTimeout(failTest, FAILURE_TIMEOUT);
105 window.onload = main;