michael@0: // Test for bug 592641 - Image document doesn't show dimensions of cached images michael@0: michael@0: // Globals michael@0: var testPath = "http://mochi.test:8888/browser/content/html/document/test/"; michael@0: var ctx = {loadsDone : 0}; michael@0: michael@0: // Entry point from Mochikit michael@0: function test() { michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: ctx.tab1 = gBrowser.addTab(testPath + "bug592641_img.jpg"); michael@0: ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1); michael@0: ctx.tab1Browser.addEventListener("load", load1Soon, true); michael@0: } michael@0: michael@0: function checkTitle(title) { michael@0: michael@0: ctx.loadsDone++; michael@0: ok(/^bug592641_img\.jpg \(JPEG Image, 1500\u00A0\u00D7\u00A01500 pixels\)/.test(title), michael@0: "Title should be correct on load #" + ctx.loadsDone); michael@0: } michael@0: michael@0: function load1Soon() { michael@0: ctx.tab1Browser.removeEventListener("load", load1Soon, true); michael@0: // onload is fired in OnStopDecode, so let's use executeSoon() to make sure michael@0: // that any other OnStopDecode event handlers get the chance to fire first. michael@0: executeSoon(load1Done); michael@0: } michael@0: michael@0: function load1Done() { michael@0: // Check the title michael@0: var title = ctx.tab1Browser.contentWindow.document.title; michael@0: checkTitle(title); michael@0: michael@0: // Try loading the same image in a new tab to make sure things work in michael@0: // the cached case. michael@0: ctx.tab2 = gBrowser.addTab(testPath + "bug592641_img.jpg"); michael@0: ctx.tab2Browser = gBrowser.getBrowserForTab(ctx.tab2); michael@0: ctx.tab2Browser.addEventListener("load", load2Soon, true); michael@0: } michael@0: michael@0: function load2Soon() { michael@0: ctx.tab2Browser.removeEventListener("load", load2Soon, true); michael@0: // onload is fired in OnStopDecode, so let's use executeSoon() to make sure michael@0: // that any other OnStopDecode event handlers get the chance to fire first. michael@0: executeSoon(load2Done); michael@0: } michael@0: michael@0: function load2Done() { michael@0: // Check the title michael@0: var title = ctx.tab2Browser.contentWindow.document.title; michael@0: checkTitle(title); michael@0: michael@0: // Clean up michael@0: gBrowser.removeTab(ctx.tab1); michael@0: gBrowser.removeTab(ctx.tab2); michael@0: michael@0: // Test done michael@0: finish(); michael@0: }