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