layout/base/tests/chrome/test_bug370436.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/chrome/test_bug370436.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +	https://bugzilla.mozilla.org/show_bug.cgi?id=370436
     1.8 +-->
     1.9 +<head>
    1.10 +	<title>Test for Bug 370436</title>
    1.11 +	<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>        
    1.12 +	<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>        
    1.13 +	<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +
    1.17 +<script class="testbody" type="application/javascript">
    1.18 +<!--
    1.19 +words = new Array()
    1.20 +const Ci = Components.interfaces;
    1.21 +
    1.22 +function expandStringOffsetToWord(data, offset)
    1.23 +{
    1.24 +	if (data == undefined) return "";
    1.25 +
    1.26 +	var m1 = data.substr(0, offset).match(/\w+$/) || "";
    1.27 +	var m2 = data.substr(offset).match(/^\w+/) || "";
    1.28 +	return m1 + m2;
    1.29 +}
    1.30 +
    1.31 +function onContextMenu(e)
    1.32 +{
    1.33 +	var node = e.rangeParent;
    1.34 +	var offset = e.rangeOffset;
    1.35 +	var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
    1.36 +	is(utils.getClassName(node), "Text", "Shouldn't have SOWs in chrome");
    1.37 +
    1.38 +	var word = expandStringOffsetToWord(node.data, offset);
    1.39 +	words.push(word);
    1.40 +}
    1.41 +
    1.42 +function startTest()
    1.43 +{
    1.44 +	ta = document.getElementById('blah');
    1.45 +	ta.focus();
    1.46 +	ta.selectionStart = ta.selectionEnd = ta.value.length;
    1.47 +
    1.48 +	/* Put cursor at start and middle of "sheep" */
    1.49 +	synthesizeKey("VK_UP", {})
    1.50 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.51 +	synthesizeKey("VK_RIGHT", {})
    1.52 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.53 +	synthesizeKey("VK_RIGHT", {})
    1.54 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.55 +
    1.56 +	/* Put cursor at the end of "hello" */
    1.57 +	synthesizeKey("VK_UP", {})
    1.58 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.59 +	synthesizeKey("VK_RIGHT", {})
    1.60 +	synthesizeKey("VK_RIGHT", {})
    1.61 +	synthesizeKey("VK_RIGHT", {})
    1.62 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.63 +	synthesizeKey("VK_RIGHT", {})
    1.64 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.65 +
    1.66 +	/* Put cursor on "welcome" */
    1.67 +	synthesizeKey("VK_UP", {})
    1.68 +	synthesizeMouse(ta, 0, 0, { type : "contextmenu" });
    1.69 +
    1.70 +	is(words.pop(), "welcome", "Word 1 selected correctly");	
    1.71 +	is(words.pop(), "world"  , "Word 2 selected correctly");	
    1.72 +	is(words.pop(), "hello"  , "Word 3 selected correctly");	
    1.73 +	is(words.pop(), "hello"  , "Word 4 selected correctly");	
    1.74 +	is(words.pop(), "sheep"  , "Word 5 selected correctly");	
    1.75 +	is(words.pop(), "sheep"  , "Word 6 selected correctly");	
    1.76 +	is(words.pop(), "sheep"  , "Word 7 selected correctly");
    1.77 +
    1.78 +	SimpleTest.finish();
    1.79 +}
    1.80 +
    1.81 +SimpleTest.waitForExplicitFinish()
    1.82 +SimpleTest.waitForFocus(startTest)
    1.83 +-->
    1.84 +</script>
    1.85 +
    1.86 +<p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370436">Mozilla Bug 370436</a></p>
    1.87 +
    1.88 +<textarea id="blah" rows="10" cols="80" oncontextmenu="onContextMenu(event); return false;">
    1.89 +welcome
    1.90 +hello world
    1.91 +sheep
    1.92 +</textarea>
    1.93 +</body>
    1.94 +</html>
    1.95 +

mercurial