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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial