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