browser/components/tabview/test/browser_tabview_bug625269.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function test() {
     5   waitForExplicitFinish();
     6   newWindowWithTabView(onTabViewShown, null, 850);
     7 }
     9 function onTabViewShown(win) {
    10   registerCleanupFunction(function () win.close());
    12   let contentWindow = win.TabView.getContentWindow();
    13   let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
    15   function checkResized(diffX, diffY, shouldResize, text, callback) {
    16     let {width: origWidth, height: origHeight} = currentGroup.getBounds();
    18     resizeWindow(win, diffX, diffY, function () {
    19       let {width: newWidth, height: newHeight} = currentGroup.getBounds();
    20       let resized = (origWidth != newWidth || origHeight != newHeight);
    22       is(resized, shouldResize, text + ": The group should " +
    23          (shouldResize ? "" : "not ") + "have been resized");
    25       callback();
    26     });
    27   }
    29   function next() {
    30     let test = tests.shift();
    32     if (test)
    33       checkResized.apply(this, test.concat([next]));
    34     else
    35       finishTest();
    36   }
    38   function finishTest() {
    39     // reset the usersize of the group, so this should clear the "cramped" feeling.
    40     currentGroup.setSize(100, 100, true);
    41     currentGroup.setUserSize();
    42     checkResized(400, 400, false, "After clearing the cramp", finish);
    43   }
    45   let tests = [
    46     // diffX, diffY, shouldResize, text
    47     [ -50,  -50, false, "A little smaller"],
    48     [  50,   50, false, "A little bigger"],
    49     [-400, -400, true,  "Much smaller"],
    50     [ 400,  400, true,  "Bigger after much smaller"],
    51     [-400, -400, true,  "Much smaller"]
    52   ];
    54   // setup
    55   currentGroup.setSize(600, 600, true);
    56   currentGroup.setUserSize();
    58   // run the tests
    59   next();
    60 }
    62 // ----------
    63 function resizeWindow(win, diffX, diffY, callback) {
    64   let targetWidth = win.outerWidth + diffX;
    65   let targetHeight = win.outerHeight + diffY;
    67   (function tryResize() {
    68     let {outerWidth: width, outerHeight: height} = win;
    69     if (width != targetWidth || height != targetHeight) {
    70       win.resizeTo(targetWidth, targetHeight);
    71       executeSoon(tryResize);
    72     } else {
    73       callback();
    74     }
    75   })();
    76 }

mercurial