|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* Any copyright is dedicated to the Public Domain. |
|
4 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
5 |
|
6 "use strict"; |
|
7 |
|
8 let gWindow = null; |
|
9 |
|
10 /////////////////////////////////////////////////// |
|
11 // form input tests |
|
12 /////////////////////////////////////////////////// |
|
13 |
|
14 function setUpAndTearDown() { |
|
15 emptyClipboard(); |
|
16 if (gWindow) |
|
17 clearSelection(gWindow); |
|
18 yield waitForCondition(function () { |
|
19 return !SelectionHelperUI.isSelectionUIVisible; |
|
20 }); |
|
21 InputSourceHelper.isPrecise = false; |
|
22 InputSourceHelper.fireUpdate(); |
|
23 } |
|
24 |
|
25 gTests.push({ |
|
26 desc: "normalize browser", |
|
27 setUp: setUpAndTearDown, |
|
28 tearDown: setUpAndTearDown, |
|
29 run: function test() { |
|
30 info(chromeRoot + "browser_selection_caretfocus.html"); |
|
31 yield addTab(chromeRoot + "browser_selection_caretfocus.html"); |
|
32 |
|
33 yield waitForCondition(function () { |
|
34 return !BrowserUI.isStartTabVisible; |
|
35 }); |
|
36 |
|
37 yield hideContextUI(); |
|
38 |
|
39 gWindow = Browser.selectedTab.browser.contentWindow; |
|
40 }, |
|
41 }); |
|
42 |
|
43 function tapText(aIndex) { |
|
44 gWindow = Browser.selectedTab.browser.contentWindow; |
|
45 let id = "Text" + aIndex; |
|
46 info("tapping " + id); |
|
47 let element = gWindow.document.getElementById(id); |
|
48 if (element.contentDocument) { |
|
49 element = element.contentDocument.getElementById("textarea"); |
|
50 gWindow = element.ownerDocument.defaultView; |
|
51 } |
|
52 sendElementTap(gWindow, element, 100, 10); |
|
53 return element; |
|
54 } |
|
55 |
|
56 gTests.push({ |
|
57 desc: "focus navigation", |
|
58 setUp: setUpAndTearDown, |
|
59 tearDown: setUpAndTearDown, |
|
60 run: function test() { |
|
61 for (let iteration = 0; iteration < 3; iteration++) { |
|
62 for (let input = 1; input <= 6; input++) { |
|
63 let element = tapText(input); |
|
64 if (input == 6) { |
|
65 // div |
|
66 yield waitForCondition(function () { |
|
67 return !SelectionHelperUI.isActive; |
|
68 }); |
|
69 } else { |
|
70 // input |
|
71 yield SelectionHelperUI.pingSelectionHandler(); |
|
72 yield waitForCondition(function () { |
|
73 return SelectionHelperUI.isCaretUIVisible; |
|
74 }); |
|
75 ok(element == gWindow.document.activeElement, "element has focus"); |
|
76 } |
|
77 } |
|
78 } |
|
79 }, |
|
80 }); |
|
81 |
|
82 function test() { |
|
83 if (!isLandscapeMode()) { |
|
84 todo(false, "browser_selection_tests need landscape mode to run."); |
|
85 return; |
|
86 } |
|
87 // XXX need this until bugs 886624 and 859742 are fully resolved |
|
88 setDevPixelEqualToPx(); |
|
89 runTests(); |
|
90 } |