Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=370436
5 -->
6 <head>
7 <title>Test for Bug 370436</title>
8 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
11 </head>
12 <body>
14 <script class="testbody" type="application/javascript">
15 <!--
16 words = new Array()
17 const Ci = Components.interfaces;
19 function expandStringOffsetToWord(data, offset)
20 {
21 if (data == undefined) return "";
23 var m1 = data.substr(0, offset).match(/\w+$/) || "";
24 var m2 = data.substr(offset).match(/^\w+/) || "";
25 return m1 + m2;
26 }
28 function onContextMenu(e)
29 {
30 var node = e.rangeParent;
31 var offset = e.rangeOffset;
32 var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
33 is(utils.getClassName(node), "Text", "Shouldn't have SOWs in chrome");
35 var word = expandStringOffsetToWord(node.data, offset);
36 words.push(word);
37 }
39 function startTest()
40 {
41 ta = document.getElementById('blah');
42 ta.focus();
43 ta.selectionStart = ta.selectionEnd = ta.value.length;
45 /* Put cursor at start and middle of "sheep" */
46 synthesizeKey("VK_UP", {})
47 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
48 synthesizeKey("VK_RIGHT", {})
49 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
50 synthesizeKey("VK_RIGHT", {})
51 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
53 /* Put cursor at the end of "hello" */
54 synthesizeKey("VK_UP", {})
55 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
56 synthesizeKey("VK_RIGHT", {})
57 synthesizeKey("VK_RIGHT", {})
58 synthesizeKey("VK_RIGHT", {})
59 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
60 synthesizeKey("VK_RIGHT", {})
61 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
63 /* Put cursor on "welcome" */
64 synthesizeKey("VK_UP", {})
65 synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
67 is(words.pop(), "welcome", "Word 1 selected correctly");
68 is(words.pop(), "world" , "Word 2 selected correctly");
69 is(words.pop(), "hello" , "Word 3 selected correctly");
70 is(words.pop(), "hello" , "Word 4 selected correctly");
71 is(words.pop(), "sheep" , "Word 5 selected correctly");
72 is(words.pop(), "sheep" , "Word 6 selected correctly");
73 is(words.pop(), "sheep" , "Word 7 selected correctly");
75 SimpleTest.finish();
76 }
78 SimpleTest.waitForExplicitFinish()
79 SimpleTest.waitForFocus(startTest)
80 -->
81 </script>
83 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370436">Mozilla Bug 370436</a></p>
85 <textarea id="blah" rows="10" cols="80" oncontextmenu="onContextMenu(event); return false;">
86 welcome
87 hello world
88 sheep
89 </textarea>
90 </body>
91 </html>