layout/base/tests/chrome/test_bug370436.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial