Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=610419
5 -->
6 <head>
7 <title>Test for Bug 610419</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" />
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=610419">Mozilla Bug 610419</a>
15 <p id="display"></p>
16 <div id="content">
17 <div id="referenceDiv" style="height: 100px; width: 100px;
18 display: none; background: lime"></div>
19 <img>
20 </div>
21 <pre id="test">
22 <script type="application/javascript;version=1.8">
23 /** Test for Bug 610419**/
25 SimpleTest.waitForExplicitFinish();
27 const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
29 const Cc = Components.classes;
30 const Ci = Components.interfaces;
31 const gImg = document.getElementsByTagName("img")[0];
33 var gMyDecoderObserver; // value will be set in main()
34 var gReferenceSnapshot; // value will be set in takeReferenceSnapshot()
35 var gOnStopFrameCounter = 0;
36 var gIsTestFinished = false;
39 function takeReferenceSnapshot() {
40 // Take a snapshot of the initial (essentially blank) page
41 let blankSnapshot = snapshotWindow(window, false);
43 // Show reference div, & take a snapshot
44 let referenceDiv = document.getElementById("referenceDiv");
45 referenceDiv.style.display = "block";
46 gReferenceSnapshot = snapshotWindow(window, false);
47 ok(compareSnapshots(blankSnapshot, gReferenceSnapshot, false)[0],
48 "reference snapshot shouldn't match blank page snapshot");
50 // Re-hide reference div, and take another snapshot to be sure it's gone
51 referenceDiv.style.display = "none";
52 let blankSnapshot2 = snapshotWindow(window, false);
53 ok(compareSnapshots(blankSnapshot, blankSnapshot2, true)[0],
54 "reference div should disappear when it becomes display:none");
55 }
57 function myOnStopFrame() {
58 gOnStopFrameCounter++;
59 ok(true, "myOnStopFrame called");
60 let currentSnapshot = snapshotWindow(window, false);
61 if (compareSnapshots(currentSnapshot, gReferenceSnapshot, true)[0]) {
62 // SUCCESS!
63 ok(true, "Animated image looks correct, " +
64 "at call #" + gOnStopFrameCounter + " to onStopFrame");
65 cleanUpAndFinish();
66 }
67 else
68 setTimeout(myOnStopFrame, 1);
69 }
71 function failTest() {
72 ok(false, "timing out after " + FAILURE_TIMEOUT + "ms. " +
73 "Animated image still doesn't look correct, " +
74 "after call #" + gOnStopFrameCounter + " to onStopFrame");
75 cleanUpAndFinish();
76 }
78 function cleanUpAndFinish() {
79 // On the off chance that failTest and myOnStopFrame are triggered
80 // back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
81 if (gIsTestFinished) {
82 return;
83 }
84 SimpleTest.finish();
85 gIsTestFinished = true;
86 }
88 function main() {
89 takeReferenceSnapshot();
91 // We want to test the cold loading behavior, so clear cache in case an
92 // earlier test got our image in there already.
93 clearImageCache();
95 setTimeout(myOnStopFrame, 1);
97 // kick off image-loading! myOnStopFrame handles the rest.
98 gImg.setAttribute("src", "lime-anim-100x100.svg");
100 // In case something goes wrong, fail earlier than mochitest timeout,
101 // and with more information.
102 setTimeout(failTest, FAILURE_TIMEOUT);
103 }
105 window.onload = main;
107 </script>
108 </pre>
109 </body>
110 </html>