2 var isWin7OrHigher =
false;
4 let
version =
Cc[
"@mozilla.org/system-info;1"]
5 .getService(
Ci.nsIPropertyBag2)
6 .getProperty(
"version");
7 isWin7OrHigher = (parseFloat(version) >= 6.1);
10 is(!!Win7Features, isWin7OrHigher,
"Win7Features available when it should be");
14 const ENABLE_PREF_NAME =
"browser.taskbar.previews.enable";
17 Cu.import(
"resource://gre/modules/WindowsPreviewPerTab.jsm", temp);
18 let AeroPeek = temp.AeroPeek;
24 is(1, AeroPeek.windows.length,
"Got the expected number of windows");
26 checkPreviews(1,
"Browser starts with one preview");
32 checkPreviews(4,
"Correct number of previews after adding");
34 for each (let preview
in AeroPeek.previews)
35 ok(preview.visible,
"Preview is shown as expected");
38 checkPreviews(4,
"Previews are unchanged when disabling");
40 for each (let preview
in AeroPeek.previews)
41 ok(!preview.visible,
"Preview is not shown as expected after disabling");
44 checkPreviews(4,
"Previews are unchanged when re-enabling");
45 for each (let preview
in AeroPeek.previews)
46 ok(preview.visible,
"Preview is shown as expected after re-enabling");
48 [1,2,3,4].forEach(
function (idx) {
49 gBrowser.selectedTab = gBrowser.mTabs[idx];
50 ok(checkSelectedTab(),
"Current tab is correctly selected");
53 let currentSelectedTab = gBrowser.selectedTab;
54 for each (let idx
in [1,2,3,4]) {
55 let preview = getPreviewForTab(gBrowser.mTabs[0]);
56 let canvas = createThumbnailSurface(preview);
57 let ctx = canvas.getContext(
"2d");
58 preview.controller.drawThumbnail(ctx, canvas.width, canvas.height);
59 ok(currentSelectedTab == gBrowser.selectedTab,
"Drawing thumbnail does not change selection");
60 canvas = getCanvas(preview.controller.width, preview.controller.height);
61 ctx = canvas.getContext(
"2d");
62 preview.controller.drawPreview(ctx);
63 ok(currentSelectedTab == gBrowser.selectedTab,
"Drawing preview does not change selection");
67 getPreviewForTab(gBrowser.selectedTab).controller.onClose();
68 checkPreviews(3,
"Expected number of previews after closing selected tab via controller");
69 ok(gBrowser.mTabs.length == 3,
"Successfully closed a tab");
72 ok(getPreviewForTab(gBrowser.mTabs[0]).controller.onActivate(),
"Activation was accepted");
73 ok(gBrowser.mTabs[0] == gBrowser.selectedTab,
"Correct tab was selected");
77 gBrowser.removeTab(gBrowser.tabContainer.lastChild);
78 checkPreviews(2,
"Expected number of previews after closing unselected via browser");
81 gBrowser.removeTab(gBrowser.tabContainer.firstChild);
82 checkPreviews(1,
"Expected number of previews after closing selected tab via browser");
91 gBrowser.selectedTab = gBrowser.mTabs[0];
94 getPreviewForTab(gBrowser.mTabs[1]).controller.onClose();
102 function checkPreviews(aPreviews,
msg) {
103 let nPreviews = AeroPeek.previews.length;
104 is(aPreviews, gBrowser.mTabs.length,
"Browser has expected number of tabs");
105 is(nPreviews, gBrowser.mTabs.length,
"Browser has one preview per tab");
106 is(nPreviews, aPreviews,
msg ||
"Got expected number of previews");
109 function getPreviewForTab(
tab)
110 window.gTaskbarTabGroup.previewFromTab(
tab);
112 function checkSelectedTab()
113 getPreviewForTab(gBrowser.selectedTab).active;
115 function isTabSelected(idx)
116 gBrowser.selectedTab == gBrowser.mTabs[idx];
118 function createThumbnailSurface(
p) {
119 let thumbnailWidth = 200,
120 thumbnailHeight = 120;
121 let ratio =
p.controller.thumbnailAspectRatio;
123 if (thumbnailWidth/thumbnailHeight > ratio)
124 thumbnailWidth = thumbnailHeight * ratio;
126 thumbnailHeight = thumbnailWidth / ratio;
128 return getCanvas(thumbnailWidth, thumbnailHeight);
132 let
win =
window.QueryInterface(
Ci.nsIDOMWindowInternal);
133 let
doc = win.document;
134 let canvas = doc.createElementNS(
"http://www.w3.org/1999/xhtml",
"canvas");
135 canvas.width =
width;
function doc() browser.contentDocument