browser/metro/base/tests/mochitest/browser_form_selects.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 "use strict";
michael@0 7
michael@0 8 function test() {
michael@0 9 runTests();
michael@0 10 }
michael@0 11
michael@0 12 gTests.push({
michael@0 13 desc: "form multi-select test 1",
michael@0 14 setUp: function () {
michael@0 15 },
michael@0 16 tearDown: function () {
michael@0 17 },
michael@0 18 run: function () {
michael@0 19 yield addTab(chromeRoot + "browser_form_selects.html");
michael@0 20 yield waitForCondition(function () {
michael@0 21 return !Browser.selectedTab.isLoading();
michael@0 22 });
michael@0 23
michael@0 24 let win = Browser.selectedTab.browser.contentWindow;
michael@0 25 let tabdoc = Browser.selectedTab.browser.contentWindow.document;
michael@0 26 let select = tabdoc.getElementById("selectelement");
michael@0 27
michael@0 28 // display the touch menu
michael@0 29 let promise = waitForEvent(tabdoc, "popupshown");
michael@0 30 sendNativeTap(select);
michael@0 31 yield promise;
michael@0 32
michael@0 33 // tap every option
michael@0 34 for (let node of SelectHelperUI._listbox.childNodes) {
michael@0 35 sendNativeTap(node);
michael@0 36 }
michael@0 37
michael@0 38 yield waitForCondition2(function () {
michael@0 39 return Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected;
michael@0 40 }, "waiting for last option to select");
michael@0 41
michael@0 42 // check the menu state
michael@0 43 for (let node of SelectHelperUI._listbox.childNodes) {
michael@0 44 ok(node.selected, "option is selected");
michael@0 45 }
michael@0 46
michael@0 47 // check the underlying form state
michael@0 48 for (let index = 1; index < 10; index++) {
michael@0 49 let option = tabdoc.getElementById("opt" + index);
michael@0 50 ok(option.selected, "opt" + index + " form option selected");
michael@0 51 }
michael@0 52
michael@0 53 // tap every option again
michael@0 54 for (let node of SelectHelperUI._listbox.childNodes) {
michael@0 55 sendNativeTap(node);
michael@0 56 }
michael@0 57
michael@0 58 yield waitForCondition2(function () {
michael@0 59 return !Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected;
michael@0 60 }, "waiting for last option to deselect");
michael@0 61
michael@0 62 // check the menu state
michael@0 63 for (let node of SelectHelperUI._listbox.childNodes) {
michael@0 64 ok(!node.selected, "option is not selected");
michael@0 65 }
michael@0 66
michael@0 67 // check the underlying form state
michael@0 68 for (let index = 1; index < 10; index++) {
michael@0 69 let option = tabdoc.getElementById("opt" + index);
michael@0 70 ok(!option.selected, "opt" + index + " form option not selected");
michael@0 71 }
michael@0 72
michael@0 73 }
michael@0 74 });
michael@0 75

mercurial