michael@0: // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: runTests(); michael@0: } michael@0: michael@0: function setup() { michael@0: yield waitForCondition(function () { michael@0: return Elements.tabList && Elements.tabList.strip; michael@0: }); michael@0: michael@0: if (!ContextUI.tabbarVisible) { michael@0: ContextUI.displayTabs(); michael@0: } michael@0: } michael@0: function tearDown() { michael@0: cleanUpOpenedTabs(); michael@0: } michael@0: michael@0: function isElementVisible(elm) { michael@0: return elm.ownerDocument.defaultView.getComputedStyle(elm).getPropertyValue("visibility") == "visible"; michael@0: } michael@0: michael@0: michael@0: gTests.push({ michael@0: desc: "No scrollbuttons when tab strip doesnt require overflow", michael@0: setUp: setup, michael@0: run: function () { michael@0: let tabStrip = Elements.tabList.strip; michael@0: let tabs = Elements.tabList.strip.querySelectorAll("documenttab"); michael@0: michael@0: // sanity check tab count: michael@0: is(tabs.length, 1, "1 tab present"); michael@0: michael@0: // test imprecise mode michael@0: let imprecisePromise = waitForObserver("metro_imprecise_input"); michael@0: notifyImprecise(); michael@0: yield imprecisePromise; michael@0: michael@0: ok(!isElementVisible(tabStrip._scrollButtonUp), "left scrollbutton is hidden in imprecise mode"); michael@0: ok(!isElementVisible(tabStrip._scrollButtonDown), "right scrollbutton is hidden in imprecise mode"); michael@0: michael@0: // test precise mode michael@0: let precisePromise = waitForObserver("metro_precise_input"); michael@0: notifyPrecise(); michael@0: yield precisePromise; michael@0: michael@0: ok(!isElementVisible(tabStrip._scrollButtonUp), "Bug 952297 - left scrollbutton is hidden in precise mode"); michael@0: ok(!isElementVisible(tabStrip._scrollButtonDown), "right scrollbutton is hidden in precise mode"); michael@0: }, michael@0: tearDown: tearDown michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "Scrollbuttons not visible when tabstrip has overflow in imprecise input mode", michael@0: setUp: function(){ michael@0: yield setup(); michael@0: // ensure we're in imprecise mode michael@0: let imprecisePromise = waitForObserver("metro_imprecise_input"); michael@0: notifyImprecise(); michael@0: yield imprecisePromise; michael@0: }, michael@0: run: function () { michael@0: // add enough tabs to get overflow in the tabstrip michael@0: let strip = Elements.tabList.strip; michael@0: ok(strip && strip.scrollClientSize && strip.scrollSize, "Sanity check tabstrip strip is present and expected properties available"); michael@0: michael@0: while (strip.scrollSize <= strip.scrollClientSize) { michael@0: yield addTab("about:mozilla"); michael@0: } michael@0: michael@0: ok(!isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton is hidden in imprecise mode"); michael@0: ok(!isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton is hidden in imprecise mode"); michael@0: michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "Scrollbuttons become visible when tabstrip has overflow in precise input mode", michael@0: setUp: function(){ michael@0: yield setup(); michael@0: // ensure we're in precise mode michael@0: let precisePromise = waitForObserver("metro_precise_input"); michael@0: notifyPrecise(); michael@0: yield precisePromise; michael@0: }, michael@0: run: function () { michael@0: let strip = Elements.tabList.strip; michael@0: ok(strip && strip.scrollClientSize && strip.scrollSize, "Sanity check tabstrip is present and expected properties available"); michael@0: michael@0: // add enough tabs to get overflow in the tabstrip michael@0: while (strip.scrollSize <= strip.scrollClientSize) { michael@0: yield addTab("about:mozilla"); michael@0: } michael@0: michael@0: ok(isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton should be visible in precise mode"); michael@0: ok(isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton should be visible in precise mode"); michael@0: michael@0: // select the first tab michael@0: Browser.selectedTab = Browser.tabs[0]; michael@0: yield waitForMs(1000); // XXX maximum duration of arrowscrollbox _scrollAnim michael@0: ok(Elements.tabList.strip._scrollButtonUp.disabled, "left scrollbutton should be disabled when 1st tab is selected and tablist has overflow"); michael@0: ok(!Elements.tabList.strip._scrollButtonDown.disabled, "right scrollbutton should be enabled when 1st tab is selected and tablist has overflow"); michael@0: michael@0: // select the last tab michael@0: Browser.selectedTab = Browser.tabs[Browser.tabs.length - 1]; michael@0: yield waitForMs(1000); // XXX maximum duration of arrowscrollbox _scrollAnim michael@0: ok(!Elements.tabList.strip._scrollButtonUp.disabled, "left scrollbutton should be enabled when 1st tab is selected and tablist has overflow"); michael@0: ok(Elements.tabList.strip._scrollButtonDown.disabled, "right scrollbutton should be disabled when last tab is selected and tablist has overflow"); michael@0: michael@0: } michael@0: });