toolkit/content/tests/chrome/test_textbox_dictionary.xul

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 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 XUL Widget Test for textbox with Add and Undo Add to Dictionary
michael@0 6 -->
michael@0 7 <window title="Textbox Add and Undo Add to Dictionary Test" width="500" height="600"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 11
michael@0 12 <hbox>
michael@0 13 <textbox id="t1" value="Hellop" oncontextmenu="runContextMenuTest()" spellcheck="true"/>
michael@0 14 </hbox>
michael@0 15
michael@0 16 <!-- test results are displayed in the html:body -->
michael@0 17 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
michael@0 18
michael@0 19 <!-- test code goes here -->
michael@0 20 <script type="application/javascript"><![CDATA[
michael@0 21
michael@0 22 SimpleTest.waitForExplicitFinish();
michael@0 23
michael@0 24 var textbox;
michael@0 25 var testNum;
michael@0 26
michael@0 27 function bringUpContextMenu(element)
michael@0 28 {
michael@0 29 synthesizeMouseAtCenter(element, { type: "contextmenu", button: 2});
michael@0 30 }
michael@0 31
michael@0 32 function leftClickElement(element)
michael@0 33 {
michael@0 34 synthesizeMouseAtCenter(element, { button: 0 });
michael@0 35 }
michael@0 36
michael@0 37 function startTests()
michael@0 38 {
michael@0 39 textbox = document.getElementById("t1");
michael@0 40 textbox.focus();
michael@0 41 testNum = 0;
michael@0 42
michael@0 43 Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
michael@0 44 onSpellCheck(textbox, function () {
michael@0 45 bringUpContextMenu(textbox);
michael@0 46 });
michael@0 47 }
michael@0 48
michael@0 49 function runContextMenuTest()
michael@0 50 {
michael@0 51 SimpleTest.executeSoon( function() {
michael@0 52 // The textbox has its children in an hbox XUL element, so get that first
michael@0 53 var hbox = document.getAnonymousNodes(textbox).item(0);
michael@0 54
michael@0 55 var contextMenu = document.getAnonymousElementByAttribute(hbox, "anonid", "input-box-contextmenu");
michael@0 56
michael@0 57 switch(testNum)
michael@0 58 {
michael@0 59 case 0: // "Add to Dictionary" button
michael@0 60 var addToDict = contextMenu.querySelector("[anonid=spell-add-to-dictionary]");
michael@0 61 ok(!addToDict.hidden, "Is Add to Dictionary visible?");
michael@0 62
michael@0 63 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
michael@0 64 ok(!separator.hidden, "Is separator visible?");
michael@0 65
michael@0 66 addToDict.doCommand();
michael@0 67
michael@0 68 contextMenu.hidePopup();
michael@0 69 testNum++;
michael@0 70
michael@0 71 onSpellCheck(textbox, function () {
michael@0 72 bringUpContextMenu(textbox);
michael@0 73 });
michael@0 74 break;
michael@0 75
michael@0 76 case 1: // "Undo Add to Dictionary" button
michael@0 77 var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]");
michael@0 78 ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?");
michael@0 79
michael@0 80 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
michael@0 81 ok(!separator.hidden, "Is separator hidden?");
michael@0 82
michael@0 83 undoAddDict.doCommand();
michael@0 84
michael@0 85 contextMenu.hidePopup();
michael@0 86 onSpellCheck(textbox, function () {
michael@0 87 SimpleTest.finish();
michael@0 88 });
michael@0 89 break;
michael@0 90 }
michael@0 91 });
michael@0 92 }
michael@0 93
michael@0 94 SimpleTest.waitForFocus(startTests);
michael@0 95
michael@0 96 ]]></script>
michael@0 97
michael@0 98 </window>

mercurial