tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_bug592641.js (1753B)


      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/dom/html/test/";
      5 var ctx = { loadsDone: 0 };
      6 
      7 // Entry point from Mochikit
      8 function test() {
      9  waitForExplicitFinish();
     10 
     11  ctx.tab1 = BrowserTestUtils.addTab(gBrowser, testPath + "bug592641_img.jpg");
     12  ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
     13  BrowserTestUtils.browserLoaded(ctx.tab1Browser).then(load1Soon);
     14 }
     15 
     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  );
     24 }
     25 
     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);
     30 }
     31 
     32 function load1Done() {
     33  // Check the title
     34  var title = ctx.tab1Browser.contentTitle;
     35  checkTitle(title);
     36 
     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);
     42 }
     43 
     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);
     48 }
     49 
     50 function load2Done() {
     51  // Check the title
     52  var title = ctx.tab2Browser.contentTitle;
     53  checkTitle(title);
     54 
     55  // Clean up
     56  gBrowser.removeTab(ctx.tab1);
     57  gBrowser.removeTab(ctx.tab2);
     58 
     59  // Test done
     60  finish();
     61 }