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: gTests.push({ michael@0: desc: "form multi-select test 1", michael@0: setUp: function () { michael@0: }, michael@0: tearDown: function () { michael@0: }, michael@0: run: function () { michael@0: yield addTab(chromeRoot + "browser_form_selects.html"); michael@0: yield waitForCondition(function () { michael@0: return !Browser.selectedTab.isLoading(); michael@0: }); michael@0: michael@0: let win = Browser.selectedTab.browser.contentWindow; michael@0: let tabdoc = Browser.selectedTab.browser.contentWindow.document; michael@0: let select = tabdoc.getElementById("selectelement"); michael@0: michael@0: // display the touch menu michael@0: let promise = waitForEvent(tabdoc, "popupshown"); michael@0: sendNativeTap(select); michael@0: yield promise; michael@0: michael@0: // tap every option michael@0: for (let node of SelectHelperUI._listbox.childNodes) { michael@0: sendNativeTap(node); michael@0: } michael@0: michael@0: yield waitForCondition2(function () { michael@0: return Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected; michael@0: }, "waiting for last option to select"); michael@0: michael@0: // check the menu state michael@0: for (let node of SelectHelperUI._listbox.childNodes) { michael@0: ok(node.selected, "option is selected"); michael@0: } michael@0: michael@0: // check the underlying form state michael@0: for (let index = 1; index < 10; index++) { michael@0: let option = tabdoc.getElementById("opt" + index); michael@0: ok(option.selected, "opt" + index + " form option selected"); michael@0: } michael@0: michael@0: // tap every option again michael@0: for (let node of SelectHelperUI._listbox.childNodes) { michael@0: sendNativeTap(node); michael@0: } michael@0: michael@0: yield waitForCondition2(function () { michael@0: return !Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected; michael@0: }, "waiting for last option to deselect"); michael@0: michael@0: // check the menu state michael@0: for (let node of SelectHelperUI._listbox.childNodes) { michael@0: ok(!node.selected, "option is not selected"); michael@0: } michael@0: michael@0: // check the underlying form state michael@0: for (let index = 1; index < 10; index++) { michael@0: let option = tabdoc.getElementById("opt" + index); michael@0: ok(!option.selected, "opt" + index + " form option not selected"); michael@0: } michael@0: michael@0: } michael@0: }); michael@0: