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.

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

mercurial