browser/components/tabview/test/browser_tabview_bug625269.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:887113d727e9
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function test() {
5 waitForExplicitFinish();
6 newWindowWithTabView(onTabViewShown, null, 850);
7 }
8
9 function onTabViewShown(win) {
10 registerCleanupFunction(function () win.close());
11
12 let contentWindow = win.TabView.getContentWindow();
13 let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
14
15 function checkResized(diffX, diffY, shouldResize, text, callback) {
16 let {width: origWidth, height: origHeight} = currentGroup.getBounds();
17
18 resizeWindow(win, diffX, diffY, function () {
19 let {width: newWidth, height: newHeight} = currentGroup.getBounds();
20 let resized = (origWidth != newWidth || origHeight != newHeight);
21
22 is(resized, shouldResize, text + ": The group should " +
23 (shouldResize ? "" : "not ") + "have been resized");
24
25 callback();
26 });
27 }
28
29 function next() {
30 let test = tests.shift();
31
32 if (test)
33 checkResized.apply(this, test.concat([next]));
34 else
35 finishTest();
36 }
37
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 }
44
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 ];
53
54 // setup
55 currentGroup.setSize(600, 600, true);
56 currentGroup.setUserSize();
57
58 // run the tests
59 next();
60 }
61
62 // ----------
63 function resizeWindow(win, diffX, diffY, callback) {
64 let targetWidth = win.outerWidth + diffX;
65 let targetHeight = win.outerHeight + diffY;
66
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