1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/events/test_textattrchange.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +<html> 1.5 + 1.6 +<head> 1.7 + <title>Text attribute changed event for misspelled text</title> 1.8 + 1.9 + <link rel="stylesheet" type="text/css" 1.10 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.11 + 1.12 + <script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="../common.js"></script> 1.19 + <script type="application/javascript" 1.20 + src="../role.js"></script> 1.21 + <script type="application/javascript" 1.22 + src="../states.js"></script> 1.23 + <script type="application/javascript" 1.24 + src="../events.js"></script> 1.25 + <script type="application/javascript" 1.26 + src="../attributes.js"></script> 1.27 + 1.28 + <script type="application/javascript"> 1.29 + 1.30 + const nsIDOMNSEditableElement = 1.31 + Components.interfaces.nsIDOMNSEditableElement; 1.32 + 1.33 + Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm"); 1.34 + 1.35 + function spelledTextInvoker(aID) 1.36 + { 1.37 + this.DOMNode = getNode(aID); 1.38 + 1.39 + this.eventSeq = [ 1.40 + new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode) 1.41 + ]; 1.42 + 1.43 + this.invoke = function spelledTextInvoker_invoke() 1.44 + { 1.45 + var editor = this.DOMNode.QueryInterface(nsIDOMNSEditableElement).editor; 1.46 + var spellChecker = new InlineSpellChecker(editor); 1.47 + spellChecker.enabled = true; 1.48 + 1.49 + //var spellchecker = editor.getInlineSpellChecker(true); 1.50 + //spellchecker.enableRealTimeSpell = true; 1.51 + 1.52 + this.DOMNode.value = "valid text inalid tixt"; 1.53 + } 1.54 + 1.55 + this.finalCheck = function spelledTextInvoker_finalCheck() 1.56 + { 1.57 + var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize, 1.58 + kNormalFontWeight, 1.59 + kInputFontFamily); 1.60 + testDefaultTextAttrs(aID, defAttrs); 1.61 + 1.62 + var attrs = { }; 1.63 + var misspelledAttrs = { 1.64 + "invalid": "spelling" 1.65 + }; 1.66 + 1.67 + testTextAttrs(aID, 0, attrs, defAttrs, 0, 11); 1.68 + testTextAttrs(aID, 11, misspelledAttrs, defAttrs, 11, 17); 1.69 + testTextAttrs(aID, 17, attrs, defAttrs, 17, 18); 1.70 + testTextAttrs(aID, 18, misspelledAttrs, defAttrs, 18, 22); 1.71 + } 1.72 + 1.73 + this.getID = function spelledTextInvoker_getID() 1.74 + { 1.75 + return "text attribute change for misspelled text"; 1.76 + } 1.77 + } 1.78 + 1.79 + /** 1.80 + * Do tests. 1.81 + */ 1.82 + //gA11yEventDumpID = "eventdump"; // debug stuff 1.83 + //gA11yEventDumpToConsole = true; 1.84 + 1.85 + var gQueue = null; 1.86 + function doTests() 1.87 + { 1.88 + // Synth focus before spellchecking turning on to make sure editor 1.89 + // gets a time for initialization. 1.90 + 1.91 + gQueue = new eventQueue(); 1.92 + gQueue.push(new synthFocus("input")); 1.93 + gQueue.push(new spelledTextInvoker("input")); 1.94 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.95 + } 1.96 + 1.97 + SimpleTest.waitForExplicitFinish(); 1.98 + addA11yLoadEvent(doTests); 1.99 + </script> 1.100 +</head> 1.101 + 1.102 +<body> 1.103 + 1.104 + <a target="_blank" 1.105 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759" 1.106 + title="Implement text attributes"> 1.107 + Mozilla Bug 345759 1.108 + </a> 1.109 + <p id="display"></p> 1.110 + <div id="content" style="display: none"></div> 1.111 + <pre id="test"> 1.112 + </pre> 1.113 + 1.114 + <input id="input"/> 1.115 + 1.116 + <div id="eventdump"></div> 1.117 +</body> 1.118 +</html>