1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug625269.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + newWindowWithTabView(onTabViewShown, null, 850); 1.10 +} 1.11 + 1.12 +function onTabViewShown(win) { 1.13 + registerCleanupFunction(function () win.close()); 1.14 + 1.15 + let contentWindow = win.TabView.getContentWindow(); 1.16 + let currentGroup = contentWindow.GroupItems.getActiveGroupItem(); 1.17 + 1.18 + function checkResized(diffX, diffY, shouldResize, text, callback) { 1.19 + let {width: origWidth, height: origHeight} = currentGroup.getBounds(); 1.20 + 1.21 + resizeWindow(win, diffX, diffY, function () { 1.22 + let {width: newWidth, height: newHeight} = currentGroup.getBounds(); 1.23 + let resized = (origWidth != newWidth || origHeight != newHeight); 1.24 + 1.25 + is(resized, shouldResize, text + ": The group should " + 1.26 + (shouldResize ? "" : "not ") + "have been resized"); 1.27 + 1.28 + callback(); 1.29 + }); 1.30 + } 1.31 + 1.32 + function next() { 1.33 + let test = tests.shift(); 1.34 + 1.35 + if (test) 1.36 + checkResized.apply(this, test.concat([next])); 1.37 + else 1.38 + finishTest(); 1.39 + } 1.40 + 1.41 + function finishTest() { 1.42 + // reset the usersize of the group, so this should clear the "cramped" feeling. 1.43 + currentGroup.setSize(100, 100, true); 1.44 + currentGroup.setUserSize(); 1.45 + checkResized(400, 400, false, "After clearing the cramp", finish); 1.46 + } 1.47 + 1.48 + let tests = [ 1.49 + // diffX, diffY, shouldResize, text 1.50 + [ -50, -50, false, "A little smaller"], 1.51 + [ 50, 50, false, "A little bigger"], 1.52 + [-400, -400, true, "Much smaller"], 1.53 + [ 400, 400, true, "Bigger after much smaller"], 1.54 + [-400, -400, true, "Much smaller"] 1.55 + ]; 1.56 + 1.57 + // setup 1.58 + currentGroup.setSize(600, 600, true); 1.59 + currentGroup.setUserSize(); 1.60 + 1.61 + // run the tests 1.62 + next(); 1.63 +} 1.64 + 1.65 +// ---------- 1.66 +function resizeWindow(win, diffX, diffY, callback) { 1.67 + let targetWidth = win.outerWidth + diffX; 1.68 + let targetHeight = win.outerHeight + diffY; 1.69 + 1.70 + (function tryResize() { 1.71 + let {outerWidth: width, outerHeight: height} = win; 1.72 + if (width != targetWidth || height != targetHeight) { 1.73 + win.resizeTo(targetWidth, targetHeight); 1.74 + executeSoon(tryResize); 1.75 + } else { 1.76 + callback(); 1.77 + } 1.78 + })(); 1.79 +}