content/html/document/test/browser_bug592641.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:3d3615422767
1 // Test for bug 592641 - Image document doesn't show dimensions of cached images
2
3 // Globals
4 var testPath = "http://mochi.test:8888/browser/content/html/document/test/";
5 var ctx = {loadsDone : 0};
6
7 // Entry point from Mochikit
8 function test() {
9
10 waitForExplicitFinish();
11
12 ctx.tab1 = gBrowser.addTab(testPath + "bug592641_img.jpg");
13 ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
14 ctx.tab1Browser.addEventListener("load", load1Soon, true);
15 }
16
17 function checkTitle(title) {
18
19 ctx.loadsDone++;
20 ok(/^bug592641_img\.jpg \(JPEG Image, 1500\u00A0\u00D7\u00A01500 pixels\)/.test(title),
21 "Title should be correct on load #" + ctx.loadsDone);
22 }
23
24 function load1Soon() {
25 ctx.tab1Browser.removeEventListener("load", load1Soon, true);
26 // onload is fired in OnStopDecode, so let's use executeSoon() to make sure
27 // that any other OnStopDecode event handlers get the chance to fire first.
28 executeSoon(load1Done);
29 }
30
31 function load1Done() {
32 // Check the title
33 var title = ctx.tab1Browser.contentWindow.document.title;
34 checkTitle(title);
35
36 // Try loading the same image in a new tab to make sure things work in
37 // the cached case.
38 ctx.tab2 = gBrowser.addTab(testPath + "bug592641_img.jpg");
39 ctx.tab2Browser = gBrowser.getBrowserForTab(ctx.tab2);
40 ctx.tab2Browser.addEventListener("load", load2Soon, true);
41 }
42
43 function load2Soon() {
44 ctx.tab2Browser.removeEventListener("load", load2Soon, true);
45 // onload is fired in OnStopDecode, so let's use executeSoon() to make sure
46 // that any other OnStopDecode event handlers get the chance to fire first.
47 executeSoon(load2Done);
48 }
49
50 function load2Done() {
51 // Check the title
52 var title = ctx.tab2Browser.contentWindow.document.title;
53 checkTitle(title);
54
55 // Clean up
56 gBrowser.removeTab(ctx.tab1);
57 gBrowser.removeTab(ctx.tab2);
58
59 // Test done
60 finish();
61 }

mercurial