1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_textbox_dictionary.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for textbox with Add and Undo Add to Dictionary 1.9 + --> 1.10 +<window title="Textbox Add and Undo Add to Dictionary Test" width="500" height="600" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.14 + 1.15 + <hbox> 1.16 + <textbox id="t1" value="Hellop" oncontextmenu="runContextMenuTest()" spellcheck="true"/> 1.17 + </hbox> 1.18 + 1.19 + <!-- test results are displayed in the html:body --> 1.20 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.21 + 1.22 + <!-- test code goes here --> 1.23 + <script type="application/javascript"><![CDATA[ 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +var textbox; 1.28 +var testNum; 1.29 + 1.30 +function bringUpContextMenu(element) 1.31 +{ 1.32 + synthesizeMouseAtCenter(element, { type: "contextmenu", button: 2}); 1.33 +} 1.34 + 1.35 +function leftClickElement(element) 1.36 +{ 1.37 + synthesizeMouseAtCenter(element, { button: 0 }); 1.38 +} 1.39 + 1.40 +function startTests() 1.41 +{ 1.42 + textbox = document.getElementById("t1"); 1.43 + textbox.focus(); 1.44 + testNum = 0; 1.45 + 1.46 + Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); 1.47 + onSpellCheck(textbox, function () { 1.48 + bringUpContextMenu(textbox); 1.49 + }); 1.50 +} 1.51 + 1.52 +function runContextMenuTest() 1.53 +{ 1.54 + SimpleTest.executeSoon( function() { 1.55 + // The textbox has its children in an hbox XUL element, so get that first 1.56 + var hbox = document.getAnonymousNodes(textbox).item(0); 1.57 + 1.58 + var contextMenu = document.getAnonymousElementByAttribute(hbox, "anonid", "input-box-contextmenu"); 1.59 + 1.60 + switch(testNum) 1.61 + { 1.62 + case 0: // "Add to Dictionary" button 1.63 + var addToDict = contextMenu.querySelector("[anonid=spell-add-to-dictionary]"); 1.64 + ok(!addToDict.hidden, "Is Add to Dictionary visible?"); 1.65 + 1.66 + var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]"); 1.67 + ok(!separator.hidden, "Is separator visible?"); 1.68 + 1.69 + addToDict.doCommand(); 1.70 + 1.71 + contextMenu.hidePopup(); 1.72 + testNum++; 1.73 + 1.74 + onSpellCheck(textbox, function () { 1.75 + bringUpContextMenu(textbox); 1.76 + }); 1.77 + break; 1.78 + 1.79 + case 1: // "Undo Add to Dictionary" button 1.80 + var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]"); 1.81 + ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?"); 1.82 + 1.83 + var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]"); 1.84 + ok(!separator.hidden, "Is separator hidden?"); 1.85 + 1.86 + undoAddDict.doCommand(); 1.87 + 1.88 + contextMenu.hidePopup(); 1.89 + onSpellCheck(textbox, function () { 1.90 + SimpleTest.finish(); 1.91 + }); 1.92 + break; 1.93 + } 1.94 + }); 1.95 +} 1.96 + 1.97 +SimpleTest.waitForFocus(startTests); 1.98 + 1.99 + ]]></script> 1.100 + 1.101 +</window>