Bug 1880216 - Migrate Fenix docs into Sphinx. r=owlish,geckoview-reviewers,android...
[gecko.git] / dom / html / test / browser_bug592641.js
blob761af6a568ea500aa4a5d342cdc0d338c10d99f1
1 // Test for bug 592641 - Image document doesn't show dimensions of cached images
3 // Globals
4 var testPath = "http://mochi.test:8888/browser/dom/html/test/";
5 var ctx = { loadsDone: 0 };
7 // Entry point from Mochikit
8 function test() {
9   waitForExplicitFinish();
11   ctx.tab1 = BrowserTestUtils.addTab(gBrowser, testPath + "bug592641_img.jpg");
12   ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
13   BrowserTestUtils.browserLoaded(ctx.tab1Browser).then(load1Soon);
16 function checkTitle(title) {
17   ctx.loadsDone++;
18   ok(
19     /^bug592641_img\.jpg \(JPEG Image, 1500\u00A0\u00D7\u00A01500 pixels\)/.test(
20       title
21     ),
22     "Title should be correct on load #" + ctx.loadsDone + ", was: " + title
23   );
26 function load1Soon() {
27   // onload is fired in OnStopDecode, so let's use executeSoon() to make sure
28   // that any other OnStopDecode event handlers get the chance to fire first.
29   executeSoon(load1Done);
32 function load1Done() {
33   // Check the title
34   var title = ctx.tab1Browser.contentTitle;
35   checkTitle(title);
37   // Try loading the same image in a new tab to make sure things work in
38   // the cached case.
39   ctx.tab2 = BrowserTestUtils.addTab(gBrowser, testPath + "bug592641_img.jpg");
40   ctx.tab2Browser = gBrowser.getBrowserForTab(ctx.tab2);
41   BrowserTestUtils.browserLoaded(ctx.tab2Browser).then(load2Soon);
44 function load2Soon() {
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);
50 function load2Done() {
51   // Check the title
52   var title = ctx.tab2Browser.contentTitle;
53   checkTitle(title);
55   // Clean up
56   gBrowser.removeTab(ctx.tab1);
57   gBrowser.removeTab(ctx.tab2);
59   // Test done
60   finish();