Bug 614563 - isolate text attribute change event test from attributes/test_text, r=marcoz, a=test
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 25 Nov 2010 23:58:15 +0800
changeset 58223 c5becae1d0ad56e06d10f39e4f623be8b00c37a8
parent 58222 6038dc8945d82f1b67b931faf2a32f1b5e415260
child 58224 25a981d7de7db80c416fd48a3ba1bb40182ec596
push id17208
push usersurkov.alexander@gmail.com
push dateThu, 25 Nov 2010 15:58:46 +0000
treeherdermozilla-central@c5becae1d0ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz, test
bugs614563
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 614563 - isolate text attribute change event test from attributes/test_text, r=marcoz, a=test
accessible/tests/mochitest/attributes/test_text.html
accessible/tests/mochitest/events.js
accessible/tests/mochitest/events/Makefile.in
accessible/tests/mochitest/events/test_textattrchange.html
--- a/accessible/tests/mochitest/attributes/test_text.html
+++ b/accessible/tests/mochitest/attributes/test_text.html
@@ -12,71 +12,18 @@
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
-
-    const nsIDOMNSEditableElement =
-      Components.interfaces.nsIDOMNSEditableElement;
-
     var gComputedStyle = null;
 
-    var gTextAttrChangedEventHandler = {
-      handleEvent: function gTextAttrChangedEventHandler_handleEvent(aEvent)
-      {
-        this.eventNumber++;
-      },
-
-      eventNumber: 0
-    };
-
-    function testSpellTextAttrs()
-    {
-      registerA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED,
-                                gTextAttrChangedEventHandler);
-
-      ID = "area8";
-  
-      var node = document.getElementById(ID);
-      node.setAttribute("value", "valid text inalid tixt");
-      node.focus();
-
-      var editor = node.QueryInterface(nsIDOMNSEditableElement).editor;
-      var spellchecker = editor.getInlineSpellChecker(true);
-      spellchecker.enableRealTimeSpell = true;
-
-      window.setTimeout(function()
-        {
-          var defAttrs = buildDefaultTextAttrs(node, kInputFontSize);
-          testDefaultTextAttrs(ID, defAttrs);
-
-          var attrs = { };
-          var misspelledAttrs = {
-            "invalid": "spelling"
-          };
-
-          testTextAttrs(ID, 0, attrs, defAttrs, 0, 11);
-          testTextAttrs(ID, 11, misspelledAttrs, defAttrs, 11, 17);
-          testTextAttrs(ID, 17, attrs, defAttrs, 17, 18);
-          testTextAttrs(ID, 18, misspelledAttrs, defAttrs, 18, 22);
-
-          is(gTextAttrChangedEventHandler.eventNumber, 2,
-             "Wrong count of 'text attribute changed' events for " + ID);
-
-          unregisterA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED,
-                                      gTextAttrChangedEventHandler);
-
-          SimpleTest.finish();
-        }, 0);
-    }
-
     function doTest()
     {
       //////////////////////////////////////////////////////////////////////////
       // area1
       var ID = "area1";
       var defAttrs = buildDefaultTextAttrs(ID, "10pt");
       testDefaultTextAttrs(ID, defAttrs);
 
@@ -453,19 +400,17 @@
       // p
       testTextAttrs(ID, 18, { }, { }, 18, 19);
       // bold
       attrs = { "font-weight": kBoldFontWeight };
       testTextAttrs(ID, 19, attrs, defAttrs, 19, 23);
       // p
       testTextAttrs(ID, 23, { }, { }, 23, 24);
 
-      //////////////////////////////////////////////////////////////////////////
-      // test spelling text attributes
-      testSpellTextAttrs(); // Will call SimpleTest.finish();
+      SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body style="font-size: 12pt">
 
@@ -516,18 +461,16 @@
     <span style="background-color: blue">Blue BG color</span>
     <span lang="de">Ich bin/Du bist</span>
     <span lang="en">
       Normal
       <span style="color: magenta">Magenta<b>Bold</b>Magenta</span>
     </span>
   </p>
 
-  <input id="area8"/>
-
   <p id="area9" style="font-size: smaller">Small
     <span style="font-size: 120%">bigger</span> smaller
     <span style="background-color: blue;">background blue</span> normal
     <span style="font-style: italic;">Different styling</span> normal
     <span style="font-family: tahoma;">Different font</span> normal
     <span style="text-decoration: underline;">underlined</span> normal
     <span style="text-decoration: line-through;">strikethrough</span> normal
   </p>
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -11,16 +11,17 @@ const EVENT_NAME_CHANGE = nsIAccessibleE
 const EVENT_MENUPOPUP_START = nsIAccessibleEvent.EVENT_MENUPOPUP_START;
 const EVENT_MENUPOPUP_END = nsIAccessibleEvent.EVENT_MENUPOPUP_END;
 const EVENT_REORDER = nsIAccessibleEvent.EVENT_REORDER;
 const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START;
 const EVENT_SELECTION_ADD = nsIAccessibleEvent.EVENT_SELECTION_ADD;
 const EVENT_SELECTION_WITHIN = nsIAccessibleEvent.EVENT_SELECTION_WITHIN;
 const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
 const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
+const EVENT_TEXT_ATTRIBUTE_CHANGED = nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED;
 const EVENT_TEXT_CARET_MOVED = nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED;
 const EVENT_TEXT_INSERTED = nsIAccessibleEvent.EVENT_TEXT_INSERTED;
 const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED;
 const EVENT_VALUE_CHANGE = nsIAccessibleEvent.EVENT_VALUE_CHANGE;
 
 ////////////////////////////////////////////////////////////////////////////////
 // General
 
--- a/accessible/tests/mochitest/events/Makefile.in
+++ b/accessible/tests/mochitest/events/Makefile.in
@@ -65,14 +65,15 @@ include $(topsrcdir)/config/rules.mk
 		test_focus.xul \
 		test_focus_name.html \
 		test_focusdoc.html \
 		test_mutation.html \
 		test_scroll.xul \
 		test_selection.html \
 		test_statechange.html \
 		test_text.html \
+		test_textattrchange.html \
 		test_tree.xul \
 		test_valuechange.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/events/test_textattrchange.html
@@ -0,0 +1,102 @@
+<html>
+
+<head>
+  <title>Text attribute changed event for misspelled text</title>
+
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+
+  <script type="application/javascript"
+          src="../common.js"></script>
+  <script type="application/javascript"
+          src="../events.js"></script>
+  <script type="application/javascript"
+          src="../attributes.js"></script>
+
+  <script type="application/javascript">
+
+    const nsIDOMNSEditableElement =
+      Components.interfaces.nsIDOMNSEditableElement;
+
+    function spelledTextInvoker(aID)
+    {
+      this.DOMNode = getNode(aID);
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode)
+      ];
+
+      this.invoke = function spelledTextInvoker_invoke()
+      {
+        this.DOMNode.setAttribute("value", "valid text inalid tixt");
+        this.DOMNode.focus();
+
+        var editor = this.DOMNode.QueryInterface(nsIDOMNSEditableElement).editor;
+        var spellchecker = editor.getInlineSpellChecker(true);
+        spellchecker.enableRealTimeSpell = true;
+      }
+
+      this.finalCheck = function spelledTextInvoker_finalCheck()
+      {
+        var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize);
+        testDefaultTextAttrs(aID, defAttrs);
+
+        var attrs = { };
+        var misspelledAttrs = {
+          "invalid": "spelling"
+        };
+
+        testTextAttrs(aID, 0, attrs, defAttrs, 0, 11);
+        testTextAttrs(aID, 11, misspelledAttrs, defAttrs, 11, 17);
+        testTextAttrs(aID, 17, attrs, defAttrs, 17, 18);
+        testTextAttrs(aID, 18, misspelledAttrs, defAttrs, 18, 22);
+      }
+
+      this.getID = function spelledTextInvoker_getID()
+      {
+        return "text attribute change for misspelled text";
+      }
+    }
+
+    /**
+     * Do tests.
+     */
+    //gA11yEventDumpID = "eventdump"; // debug stuff
+
+    var gQueue = null;
+    function doTests()
+    {
+      gQueue = new eventQueue();
+      gQueue.push(new spelledTextInvoker("area8"));
+      gQueue.invoke(); // Will call SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTests);
+  </script>
+</head>
+
+<body>
+
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759"
+     title="Implement text attributes">
+    Mozilla Bug 345759
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <input id="area8"/>
+
+  <div id="eventdump"></div>
+</body>
+</html>