Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Tests that there is a transform being applied to the tabs as they zoom in
5 // and out.
7 let tab, frontChanged, transformChanged;
9 function test() {
10 waitForExplicitFinish();
12 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
13 TabView.toggle();
14 }
16 function onTabViewWindowLoaded() {
17 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
19 let contentWindow = document.getElementById("tab-view").contentWindow;
20 tab = contentWindow.UI.getActiveTab();
21 ok(tab, "We have an active tab");
23 frontChanged = transformChanged = false;
24 tab.$container[0].addEventListener("DOMAttrModified", checkForFrontAddition,
25 false);
26 tab.$canvas[0].addEventListener("DOMAttrModified", checkForTransformAddition,
27 false);
29 window.addEventListener("tabviewhidden", onTabViewHidden, false);
30 TabView.toggle();
31 }
33 function checkForFrontAddition(aEvent) {
34 if (aEvent.attrName == "class" &&
35 aEvent.target.classList.contains("front")) {
36 frontChanged = true;
37 }
38 }
40 function checkForTransformAddition(aEvent) {
41 if (aEvent.attrName == "style" && aEvent.target.style.transform) {
42 transformChanged = true;
43 }
44 }
46 function onTabViewHidden() {
47 window.removeEventListener("tabviewhidden", onTabViewHidden, false);
49 ok(frontChanged, "the CSS class 'front' was added while zooming in");
50 ok(transformChanged, "the CSS class 'transform' was modified while " +
51 "zooming in");
53 frontChanged = transformChanged = false;
54 tab.$container[0].removeEventListener("DOMAttrModified",
55 checkForFrontAddition, false);
56 tab.$container[0].addEventListener("DOMAttrModified", checkForFrontRemoval,
57 false);
59 window.addEventListener("tabviewshown", onTabViewShownAgain, false);
60 TabView.toggle();
61 }
63 function checkForFrontRemoval(aEvent) {
64 if (aEvent.attrName == "class" &&
65 !aEvent.target.classList.contains("front")) {
66 frontChanged = true;
67 }
68 }
70 function onTabViewShownAgain() {
71 window.removeEventListener("tabviewshown", onTabViewShownAgain, false);
73 ok(frontChanged, "the CSS class 'front' was removed while zooming out");
74 ok(transformChanged, "the CSS class 'transform' was removed while zooming " +
75 "out");
77 tab.$container[0].removeEventListener("DOMAttrModified",
78 checkForFrontRemoval, false);
79 tab.$canvas[0].removeEventListener("DOMAttrModified",
80 checkForTransformAddition, false);
82 window.addEventListener("tabviewhidden", onTabViewHiddenAgain, false);
83 TabView.toggle();
84 }
86 function onTabViewHiddenAgain() {
87 window.removeEventListener("tabviewhidden", onTabViewHiddenAgain, false);
89 finish();
90 }