michael@0: // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: if (!isLandscapeMode()) { michael@0: todo(false, "browser_snapped_tests need landscape mode to run."); michael@0: return; michael@0: } michael@0: michael@0: runTests(); michael@0: } michael@0: let tabAdded = false; michael@0: michael@0: function setUp() { michael@0: if (!tabAdded) { michael@0: yield addTab(chromeRoot + "res/textdivs01.html"); michael@0: tabAdded = true; michael@0: } michael@0: yield hideContextUI(); michael@0: } michael@0: michael@0: XPCOMUtils.defineLazyServiceGetter(this, "gDOMUtils", michael@0: "@mozilla.org/inspector/dom-utils;1", "inIDOMUtils"); michael@0: michael@0: const kActiveState = 0x00000001; michael@0: const kHoverState = 0x00000004; michael@0: michael@0: gTests.push({ michael@0: desc: "hover states of menus", michael@0: setUp: setUp, michael@0: run: function() { michael@0: // Clicking on menu items should not leave the clicked menu item michael@0: // in the :active or :hover state. michael@0: michael@0: let typesArray = [ michael@0: "copy", michael@0: "paste" michael@0: ]; michael@0: michael@0: let promise = waitForEvent(document, "popupshown"); michael@0: ContextMenuUI.showContextMenu({ michael@0: target: null, michael@0: json: { michael@0: types: typesArray, michael@0: string: '', michael@0: xPos: 1, michael@0: yPos: 1, michael@0: leftAligned: true, michael@0: bottomAligned: true michael@0: }}); michael@0: yield promise; michael@0: michael@0: // should be visible michael@0: ok(ContextMenuUI._menuPopup.visible, "is visible"); michael@0: michael@0: let menuItem = document.getElementById("context-copy"); michael@0: promise = waitForEvent(document, "popuphidden"); michael@0: sendNativeTap(menuItem); michael@0: yield promise; michael@0: michael@0: for (let idx = 0; idx < ContextMenuUI.commands.childNodes.length; idx++) { michael@0: let item = ContextMenuUI.commands.childNodes[idx]; michael@0: let state = gDOMUtils.getContentState(item); michael@0: if ((state & kHoverState) || (state & kActiveState)) { michael@0: ok(false, "found invalid state on context menu item (" + state.toString(2) + ")"); michael@0: } michael@0: } michael@0: michael@0: // Do it again, but this time check the visible menu too and michael@0: // click a different menu item. michael@0: promise = waitForEvent(document, "popupshown"); michael@0: ContextMenuUI.showContextMenu({ michael@0: target: null, michael@0: json: { michael@0: types: typesArray, michael@0: string: '', michael@0: xPos: 1, michael@0: yPos: 1, michael@0: leftAligned: true, michael@0: bottomAligned: true michael@0: }}); michael@0: yield promise; michael@0: michael@0: // should be visible michael@0: ok(ContextMenuUI._menuPopup.visible, "is visible"); michael@0: michael@0: for (let idx = 0; idx < ContextMenuUI.commands.childNodes.length; idx++) { michael@0: let item = ContextMenuUI.commands.childNodes[idx]; michael@0: let state = gDOMUtils.getContentState(item); michael@0: if ((state & kHoverState) || (state & kActiveState)) { michael@0: ok(false, "found invalid state on context menu item (" + state.toString(2) + ")"); michael@0: } michael@0: } michael@0: michael@0: menuItem = document.getElementById("context-paste"); michael@0: promise = waitForEvent(document, "popuphidden"); michael@0: sendNativeTap(menuItem); michael@0: yield promise; michael@0: michael@0: for (let idx = 0; idx < ContextMenuUI.commands.childNodes.length; idx++) { michael@0: let item = ContextMenuUI.commands.childNodes[idx]; michael@0: let state = gDOMUtils.getContentState(item); michael@0: if ((state & kHoverState) || (state & kActiveState)) { michael@0: ok(false, "found invalid state on context menu item (" + state.toString(2) + ")"); michael@0: } michael@0: } michael@0: }, michael@0: tearDown: function () { michael@0: clearNativeTouchSequence(); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "hover states of nav bar buttons", michael@0: setUp: setUp, michael@0: run: function() { michael@0: // show nav bar michael@0: yield showNavBar(); michael@0: michael@0: // tap bookmark button michael@0: sendNativeTap(Appbar.starButton); michael@0: yield waitForMs(100); michael@0: michael@0: // check hover state michael@0: let state = gDOMUtils.getContentState(Appbar.starButton); michael@0: if ((state & kHoverState) || (state & kActiveState)) { michael@0: ok(false, "found invalid state on star button (" + state.toString(2) + ")"); michael@0: } michael@0: michael@0: // tap bookmark button michael@0: sendNativeTap(Appbar.starButton); michael@0: yield waitForMs(100); michael@0: michael@0: // check hover state michael@0: let state = gDOMUtils.getContentState(Appbar.starButton); michael@0: if ((state & kHoverState) || (state & kActiveState)) { michael@0: ok(false, "found invalid state on star button (" + state.toString(2) + ")"); michael@0: } michael@0: }, michael@0: tearDown: function () { michael@0: clearNativeTouchSequence(); michael@0: } michael@0: }); michael@0: