|
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/. */ |
|
5 |
|
6 "use strict"; |
|
7 |
|
8 function test() { |
|
9 runTests(); |
|
10 } |
|
11 |
|
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 }); |
|
23 |
|
24 let win = Browser.selectedTab.browser.contentWindow; |
|
25 let tabdoc = Browser.selectedTab.browser.contentWindow.document; |
|
26 let select = tabdoc.getElementById("selectelement"); |
|
27 |
|
28 // display the touch menu |
|
29 let promise = waitForEvent(tabdoc, "popupshown"); |
|
30 sendNativeTap(select); |
|
31 yield promise; |
|
32 |
|
33 // tap every option |
|
34 for (let node of SelectHelperUI._listbox.childNodes) { |
|
35 sendNativeTap(node); |
|
36 } |
|
37 |
|
38 yield waitForCondition2(function () { |
|
39 return Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected; |
|
40 }, "waiting for last option to select"); |
|
41 |
|
42 // check the menu state |
|
43 for (let node of SelectHelperUI._listbox.childNodes) { |
|
44 ok(node.selected, "option is selected"); |
|
45 } |
|
46 |
|
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 } |
|
52 |
|
53 // tap every option again |
|
54 for (let node of SelectHelperUI._listbox.childNodes) { |
|
55 sendNativeTap(node); |
|
56 } |
|
57 |
|
58 yield waitForCondition2(function () { |
|
59 return !Browser.selectedTab.browser.contentWindow.document.getElementById("opt9").selected; |
|
60 }, "waiting for last option to deselect"); |
|
61 |
|
62 // check the menu state |
|
63 for (let node of SelectHelperUI._listbox.childNodes) { |
|
64 ok(!node.selected, "option is not selected"); |
|
65 } |
|
66 |
|
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 } |
|
72 |
|
73 } |
|
74 }); |
|
75 |