|
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 let gWindow = null; |
|
8 |
|
9 const kCommonWaitMs = 5000; |
|
10 const kCommonPollMs = 100; |
|
11 |
|
12 /////////////////////////////////////////////////// |
|
13 // content editable tests |
|
14 /////////////////////////////////////////////////// |
|
15 |
|
16 gTests.push({ |
|
17 desc: "normalize browser", |
|
18 run: function test() { |
|
19 info(chromeRoot + "browser_selection_contenteditable.html"); |
|
20 yield addTab(chromeRoot + "browser_selection_contenteditable.html"); |
|
21 yield waitForCondition(function () { |
|
22 return !BrowserUI.isStartTabVisible; |
|
23 }, kCommonWaitMs, kCommonPollMs); |
|
24 |
|
25 yield hideContextUI(); |
|
26 |
|
27 gWindow = Browser.selectedTab.browser.contentWindow; |
|
28 |
|
29 InputSourceHelper.isPrecise = false; |
|
30 InputSourceHelper.fireUpdate(); |
|
31 }, |
|
32 }); |
|
33 |
|
34 gTests.push({ |
|
35 desc: "simple test to make sure content editable selection works", |
|
36 run: function test() { |
|
37 let div = gWindow.document.getElementById("testdiv"); |
|
38 ok(div, "have the div"); |
|
39 |
|
40 sendElementTap(gWindow, div, 284); // end of 'outlook.com' |
|
41 |
|
42 yield waitForCondition(function () { |
|
43 return SelectionHelperUI.isCaretUIVisible; |
|
44 }, kCommonWaitMs, kCommonPollMs); |
|
45 |
|
46 let xpos = SelectionHelperUI.caretMark.xPos; |
|
47 let ypos = SelectionHelperUI.caretMark.yPos + 10; |
|
48 var touchdrag = new TouchDragAndHold(); |
|
49 yield touchdrag.start(gWindow, xpos, ypos, 100, ypos); // start of 'sending' |
|
50 touchdrag.end(); |
|
51 yield waitForCondition(function () { |
|
52 return !SelectionHelperUI.hasActiveDrag; |
|
53 }, kCommonWaitMs, kCommonPollMs); |
|
54 yield SelectionHelperUI.pingSelectionHandler(); |
|
55 let str = getTrimmedSelection(gWindow).toString(); |
|
56 is(str, "sending an email in the outlook.com", "selected string matches"); |
|
57 }, |
|
58 tearDown: function () { |
|
59 emptyClipboard(); |
|
60 if (gWindow) |
|
61 clearSelection(gWindow); |
|
62 yield waitForCondition(function () { |
|
63 return !SelectionHelperUI.isSelectionUIVisible; |
|
64 }, kCommonWaitMs, kCommonPollMs); |
|
65 } |
|
66 }); |
|
67 |
|
68 function test() { |
|
69 if (!isLandscapeMode()) { |
|
70 todo(false, "browser_selection_tests need landscape mode to run."); |
|
71 return; |
|
72 } |
|
73 setDevPixelEqualToPx(); |
|
74 runTests(); |
|
75 } |