browser/components/tabview/test/browser_tabview_bug624931.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:89b15b2e417f
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // Tests that there is a transform being applied to the tabs as they zoom in
5 // and out.
6
7 let tab, frontChanged, transformChanged;
8
9 function test() {
10 waitForExplicitFinish();
11
12 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
13 TabView.toggle();
14 }
15
16 function onTabViewWindowLoaded() {
17 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
18
19 let contentWindow = document.getElementById("tab-view").contentWindow;
20 tab = contentWindow.UI.getActiveTab();
21 ok(tab, "We have an active tab");
22
23 frontChanged = transformChanged = false;
24 tab.$container[0].addEventListener("DOMAttrModified", checkForFrontAddition,
25 false);
26 tab.$canvas[0].addEventListener("DOMAttrModified", checkForTransformAddition,
27 false);
28
29 window.addEventListener("tabviewhidden", onTabViewHidden, false);
30 TabView.toggle();
31 }
32
33 function checkForFrontAddition(aEvent) {
34 if (aEvent.attrName == "class" &&
35 aEvent.target.classList.contains("front")) {
36 frontChanged = true;
37 }
38 }
39
40 function checkForTransformAddition(aEvent) {
41 if (aEvent.attrName == "style" && aEvent.target.style.transform) {
42 transformChanged = true;
43 }
44 }
45
46 function onTabViewHidden() {
47 window.removeEventListener("tabviewhidden", onTabViewHidden, false);
48
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");
52
53 frontChanged = transformChanged = false;
54 tab.$container[0].removeEventListener("DOMAttrModified",
55 checkForFrontAddition, false);
56 tab.$container[0].addEventListener("DOMAttrModified", checkForFrontRemoval,
57 false);
58
59 window.addEventListener("tabviewshown", onTabViewShownAgain, false);
60 TabView.toggle();
61 }
62
63 function checkForFrontRemoval(aEvent) {
64 if (aEvent.attrName == "class" &&
65 !aEvent.target.classList.contains("front")) {
66 frontChanged = true;
67 }
68 }
69
70 function onTabViewShownAgain() {
71 window.removeEventListener("tabviewshown", onTabViewShownAgain, false);
72
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");
76
77 tab.$container[0].removeEventListener("DOMAttrModified",
78 checkForFrontRemoval, false);
79 tab.$canvas[0].removeEventListener("DOMAttrModified",
80 checkForTransformAddition, false);
81
82 window.addEventListener("tabviewhidden", onTabViewHiddenAgain, false);
83 TabView.toggle();
84 }
85
86 function onTabViewHiddenAgain() {
87 window.removeEventListener("tabviewhidden", onTabViewHiddenAgain, false);
88
89 finish();
90 }
91

mercurial