content/html/document/test/browser_bug592641.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/test/browser_bug592641.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +// Test for bug 592641 - Image document doesn't show dimensions of cached images
     1.5 +
     1.6 +// Globals
     1.7 +var testPath = "http://mochi.test:8888/browser/content/html/document/test/";
     1.8 +var ctx = {loadsDone : 0};
     1.9 +
    1.10 +// Entry point from Mochikit
    1.11 +function test() {
    1.12 +
    1.13 +  waitForExplicitFinish();
    1.14 +
    1.15 +  ctx.tab1 = gBrowser.addTab(testPath + "bug592641_img.jpg");
    1.16 +  ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
    1.17 +  ctx.tab1Browser.addEventListener("load", load1Soon, true);
    1.18 +}
    1.19 +
    1.20 +function checkTitle(title) {
    1.21 +
    1.22 +  ctx.loadsDone++;
    1.23 +  ok(/^bug592641_img\.jpg \(JPEG Image, 1500\u00A0\u00D7\u00A01500 pixels\)/.test(title),
    1.24 +     "Title should be correct on load #" + ctx.loadsDone);
    1.25 +}
    1.26 +
    1.27 +function load1Soon() {
    1.28 +  ctx.tab1Browser.removeEventListener("load", load1Soon, true);
    1.29 +  // onload is fired in OnStopDecode, so let's use executeSoon() to make sure
    1.30 +  // that any other OnStopDecode event handlers get the chance to fire first.
    1.31 +  executeSoon(load1Done);
    1.32 +}
    1.33 +
    1.34 +function load1Done() {
    1.35 +  // Check the title
    1.36 +  var title = ctx.tab1Browser.contentWindow.document.title;
    1.37 +  checkTitle(title);
    1.38 +
    1.39 +  // Try loading the same image in a new tab to make sure things work in
    1.40 +  // the cached case.
    1.41 +  ctx.tab2 = gBrowser.addTab(testPath + "bug592641_img.jpg");
    1.42 +  ctx.tab2Browser = gBrowser.getBrowserForTab(ctx.tab2);
    1.43 +  ctx.tab2Browser.addEventListener("load", load2Soon, true);
    1.44 +}
    1.45 +
    1.46 +function load2Soon() {
    1.47 +  ctx.tab2Browser.removeEventListener("load", load2Soon, true);
    1.48 +  // onload is fired in OnStopDecode, so let's use executeSoon() to make sure
    1.49 +  // that any other OnStopDecode event handlers get the chance to fire first.
    1.50 +  executeSoon(load2Done);
    1.51 +}
    1.52 +
    1.53 +function load2Done() {
    1.54 +  // Check the title
    1.55 +  var title = ctx.tab2Browser.contentWindow.document.title;
    1.56 +  checkTitle(title);
    1.57 +
    1.58 +  // Clean up
    1.59 +  gBrowser.removeTab(ctx.tab1);
    1.60 +  gBrowser.removeTab(ctx.tab2);
    1.61 +
    1.62 +  // Test done
    1.63 +  finish();
    1.64 +}

mercurial