1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug624931.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Tests that there is a transform being applied to the tabs as they zoom in 1.8 +// and out. 1.9 + 1.10 +let tab, frontChanged, transformChanged; 1.11 + 1.12 +function test() { 1.13 + waitForExplicitFinish(); 1.14 + 1.15 + window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.16 + TabView.toggle(); 1.17 +} 1.18 + 1.19 +function onTabViewWindowLoaded() { 1.20 + window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.21 + 1.22 + let contentWindow = document.getElementById("tab-view").contentWindow; 1.23 + tab = contentWindow.UI.getActiveTab(); 1.24 + ok(tab, "We have an active tab"); 1.25 + 1.26 + frontChanged = transformChanged = false; 1.27 + tab.$container[0].addEventListener("DOMAttrModified", checkForFrontAddition, 1.28 + false); 1.29 + tab.$canvas[0].addEventListener("DOMAttrModified", checkForTransformAddition, 1.30 + false); 1.31 + 1.32 + window.addEventListener("tabviewhidden", onTabViewHidden, false); 1.33 + TabView.toggle(); 1.34 +} 1.35 + 1.36 +function checkForFrontAddition(aEvent) { 1.37 + if (aEvent.attrName == "class" && 1.38 + aEvent.target.classList.contains("front")) { 1.39 + frontChanged = true; 1.40 + } 1.41 +} 1.42 + 1.43 +function checkForTransformAddition(aEvent) { 1.44 + if (aEvent.attrName == "style" && aEvent.target.style.transform) { 1.45 + transformChanged = true; 1.46 + } 1.47 +} 1.48 + 1.49 +function onTabViewHidden() { 1.50 + window.removeEventListener("tabviewhidden", onTabViewHidden, false); 1.51 + 1.52 + ok(frontChanged, "the CSS class 'front' was added while zooming in"); 1.53 + ok(transformChanged, "the CSS class 'transform' was modified while " + 1.54 + "zooming in"); 1.55 + 1.56 + frontChanged = transformChanged = false; 1.57 + tab.$container[0].removeEventListener("DOMAttrModified", 1.58 + checkForFrontAddition, false); 1.59 + tab.$container[0].addEventListener("DOMAttrModified", checkForFrontRemoval, 1.60 + false); 1.61 + 1.62 + window.addEventListener("tabviewshown", onTabViewShownAgain, false); 1.63 + TabView.toggle(); 1.64 +} 1.65 + 1.66 +function checkForFrontRemoval(aEvent) { 1.67 + if (aEvent.attrName == "class" && 1.68 + !aEvent.target.classList.contains("front")) { 1.69 + frontChanged = true; 1.70 + } 1.71 +} 1.72 + 1.73 +function onTabViewShownAgain() { 1.74 + window.removeEventListener("tabviewshown", onTabViewShownAgain, false); 1.75 + 1.76 + ok(frontChanged, "the CSS class 'front' was removed while zooming out"); 1.77 + ok(transformChanged, "the CSS class 'transform' was removed while zooming " + 1.78 + "out"); 1.79 + 1.80 + tab.$container[0].removeEventListener("DOMAttrModified", 1.81 + checkForFrontRemoval, false); 1.82 + tab.$canvas[0].removeEventListener("DOMAttrModified", 1.83 + checkForTransformAddition, false); 1.84 + 1.85 + window.addEventListener("tabviewhidden", onTabViewHiddenAgain, false); 1.86 + TabView.toggle(); 1.87 +} 1.88 + 1.89 +function onTabViewHiddenAgain() { 1.90 + window.removeEventListener("tabviewhidden", onTabViewHiddenAgain, false); 1.91 + 1.92 + finish(); 1.93 +} 1.94 +