content/html/document/test/browser_bug592641.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Test for bug 592641 - Image document doesn't show dimensions of cached images
     3 // Globals
     4 var testPath = "http://mochi.test:8888/browser/content/html/document/test/";
     5 var ctx = {loadsDone : 0};
     7 // Entry point from Mochikit
     8 function test() {
    10   waitForExplicitFinish();
    12   ctx.tab1 = gBrowser.addTab(testPath + "bug592641_img.jpg");
    13   ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
    14   ctx.tab1Browser.addEventListener("load", load1Soon, true);
    15 }
    17 function checkTitle(title) {
    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 }
    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 }
    31 function load1Done() {
    32   // Check the title
    33   var title = ctx.tab1Browser.contentWindow.document.title;
    34   checkTitle(title);
    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 }
    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 }
    50 function load2Done() {
    51   // Check the title
    52   var title = ctx.tab2Browser.contentWindow.document.title;
    53   checkTitle(title);
    55   // Clean up
    56   gBrowser.removeTab(ctx.tab1);
    57   gBrowser.removeTab(ctx.tab2);
    59   // Test done
    60   finish();
    61 }

mercurial