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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/tests/mochitest/browser_form_selects.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +"use strict";
    1.10 +
    1.11 +function test() {
    1.12 +  runTests();
    1.13 +}
    1.14 +
    1.15 +gTests.push({
    1.16 +  desc: "form multi-select test 1",
    1.17 +  setUp: function () {
    1.18 +  },
    1.19 +  tearDown: function () {
    1.20 +  },
    1.21 +  run: function () {
    1.22 +    yield addTab(chromeRoot + "browser_form_selects.html");
    1.23 +    yield waitForCondition(function () {
    1.24 +      return !Browser.selectedTab.isLoading();
    1.25 +    });
    1.26 +
    1.27 +    let win = Browser.selectedTab.browser.contentWindow;
    1.28 +    let tabdoc = Browser.selectedTab.browser.contentWindow.document;
    1.29 +    let select = tabdoc.getElementById("selectelement");
    1.30 +
    1.31 +    // display the touch menu
    1.32 +    let promise = waitForEvent(tabdoc, "popupshown");
    1.33 +    sendNativeTap(select);
    1.34 +    yield promise;
    1.35 +
    1.36 +    // tap every option
    1.37 +    for (let node of SelectHelperUI._listbox.childNodes) {
    1.38 +      sendNativeTap(node);
    1.39 +    }
    1.40 +
    1.41 +    yield waitForCondition2(function () {
    1.42 +      return Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected;
    1.43 +      }, "waiting for last option to select");
    1.44 +
    1.45 +    // check the menu state
    1.46 +    for (let node of SelectHelperUI._listbox.childNodes) {
    1.47 +      ok(node.selected, "option is selected");
    1.48 +    }
    1.49 +
    1.50 +    // check the underlying form state
    1.51 +    for (let index = 1; index < 10; index++) {
    1.52 +      let option = tabdoc.getElementById("opt" + index);
    1.53 +      ok(option.selected, "opt" + index + " form option selected");
    1.54 +    }
    1.55 +
    1.56 +    // tap every option again
    1.57 +    for (let node of SelectHelperUI._listbox.childNodes) {
    1.58 +      sendNativeTap(node);
    1.59 +    }
    1.60 +
    1.61 +    yield waitForCondition2(function () {
    1.62 +      return !Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected;
    1.63 +      }, "waiting for last option to deselect");
    1.64 +
    1.65 +    // check the menu state
    1.66 +    for (let node of SelectHelperUI._listbox.childNodes) {
    1.67 +      ok(!node.selected, "option is not selected");
    1.68 +    }
    1.69 +
    1.70 +    // check the underlying form state
    1.71 +    for (let index = 1; index < 10; index++) {
    1.72 +      let option = tabdoc.getElementById("opt" + index);
    1.73 +      ok(!option.selected, "opt" + index + " form option not selected");
    1.74 +    }
    1.75 +
    1.76 +  }
    1.77 +});
    1.78 +

mercurial