Bug 616082 - correct designMode tests, r=marcoz, a=test
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 02 Dec 2010 16:48:06 +0800
changeset 58459 d4d8e47b84ee4fb209285cb6cd90d0f99d2e8b44
parent 58458 06d98df8a568b6c186be54ff6cf53c0ab0f8c3b1
child 58460 8cec27abeda29ec99a1f447e03181133d14d03fe
push id17308
push usersurkov.alexander@gmail.com
push dateThu, 02 Dec 2010 08:48:43 +0000
treeherdermozilla-central@d4d8e47b84ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz, test
bugs616082
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 616082 - correct designMode tests, r=marcoz, a=test
accessible/tests/mochitest/states/test_doc.html
accessible/tests/mochitest/states/test_docarticle.html
accessible/tests/mochitest/test_editabletext_1.html
--- a/accessible/tests/mochitest/states/test_doc.html
+++ b/accessible/tests/mochitest/states/test_doc.html
@@ -9,18 +9,70 @@
           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="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
+  <script type="application/javascript"
+          src="../events.js"></script>
 
   <script type="application/javascript">
+    function designModeOn()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, document)
+      ];
+
+      this.invoke = function designModeOn_invoke()
+      {
+        document.designMode = "on";
+      }
+
+      this.finalCheck = function designModeOn_finalCheck()
+      {
+        testStates(document, 0, EXT_STATE_EDITABLE);
+        testStates("p", 0, EXT_STATE_EDITABLE);
+        testStates("document", 0, EXT_STATE_EDITABLE);
+        testStates("editable_document", 0, EXT_STATE_EDITABLE);
+      }
+
+      this.getID = function designModeOn_getID()
+      {
+        return "design mode on";
+      }
+    }
+
+    function designModeOff()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, document)
+      ];
+
+      this.invoke = function designModeOn_invoke()
+      {
+        document.designMode = "off";
+      }
+
+      this.finalCheck = function designModeOn_finalCheck()
+      {
+        testStates(document, STATE_READONLY);
+        testStates("document", STATE_READONLY);
+        testStates("editable_document", 0, EXT_STATE_EDITABLE);
+      }
+
+      this.getID = function designModeOn_getID()
+      {
+        return "design mode off";
+      }
+    }
+
+    var gQueue = null;
     function doTest()
     {
       // Bug 566542: root accesible should expose active state when focused.
       testStates(getRootAccessible(), 0, EXT_STATE_ACTIVE);
 
       // Bug 509696, 607219.
       testStates(document, STATE_READONLY); // role=""
 
@@ -31,30 +83,21 @@
       document.body.removeAttribute("role");
       testStates(document, STATE_READONLY);
 
       // Bugs 454997 and 467387
       testStates(document, STATE_READONLY);
       testStates("document", STATE_READONLY);
       testStates("editable_document", 0, EXT_STATE_EDITABLE);
 
-      document.designMode = "on";
-
-      testStates(document, 0, EXT_STATE_EDITABLE);
-      testStates("p", 0, EXT_STATE_EDITABLE);
-      testStates("document", 0, EXT_STATE_EDITABLE);
-      testStates("editable_document", 0, EXT_STATE_EDITABLE);
-
-      document.designMode = "off";
-
-      testStates(document, STATE_READONLY);
-      testStates("document", STATE_READONLY);
-      testStates("editable_document", 0, EXT_STATE_EDITABLE);
-
-      SimpleTest.finish();
+      // Design mode on/off trigger document accessible subtree recreation.
+      gQueue = new eventQueue();
+      gQueue.push(new designModeOn());
+      gQueue.push(new designModeOff());
+      gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 
 <body role="">
--- a/accessible/tests/mochitest/states/test_docarticle.html
+++ b/accessible/tests/mochitest/states/test_docarticle.html
@@ -9,45 +9,87 @@
           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="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
+  <script type="application/javascript"
+          src="../events.js"></script>
 
   <script type="application/javascript">
-    function doTest()
+    function designModeOn()
     {
-      var docAcc = getAccessible(document, [nsIAccessibleDocument]);
-      if (docAcc) {
-        testStates(docAcc, STATE_READONLY);
-        testStates("aria_article", STATE_READONLY);
-        testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
-        testStates("article", STATE_READONLY);
-        testStates("editable_article", 0, EXT_STATE_EDITABLE);
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, document)
+      ];
 
+      this.invoke = function designModeOn_invoke()
+      {
         document.designMode = "on";
+      }
 
-        testStates(docAcc, 0, EXT_STATE_EDITABLE);
+      this.finalCheck = function designModeOn_finalCheck()
+      {
+        testStates(document, 0, EXT_STATE_EDITABLE);
         testStates("aria_article", 0, EXT_STATE_EDITABLE);
         testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
         testStates("article", 0, EXT_STATE_EDITABLE);
         testStates("editable_article", 0, EXT_STATE_EDITABLE);
-  
+      }
+
+      this.getID = function designModeOn_getID()
+      {
+        return "design mode on";
+      }
+    }
+
+    function designModeOff()
+    {
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, document)
+      ];
+
+      this.invoke = function designModeOn_invoke()
+      {
         document.designMode = "off";
+      }
 
-        testStates(docAcc, STATE_READONLY);
+      this.finalCheck = function designModeOn_finalCheck()
+      {
+        testStates(document, STATE_READONLY);
         testStates("aria_article", STATE_READONLY);
         testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
         testStates("article", STATE_READONLY);
         testStates("editable_article", 0, EXT_STATE_EDITABLE);
       }
-      SimpleTest.finish();
+
+      this.getID = function designModeOn_getID()
+      {
+        return "design mode off";
+      }
+    }
+
+    var gQueue = null;
+
+    function doTest()
+    {
+      testStates(document, STATE_READONLY);
+      testStates("aria_article", STATE_READONLY);
+      testStates("editable_aria_article", 0, EXT_STATE_EDITABLE);
+      testStates("article", STATE_READONLY);
+      testStates("editable_article", 0, EXT_STATE_EDITABLE);
+
+      // Design mode on/off trigger document accessible subtree recreation.
+      gQueue = new eventQueue();
+      gQueue.push(new designModeOn());
+      gQueue.push(new designModeOff());
+      gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 
 <body role="article">
--- a/accessible/tests/mochitest/test_editabletext_1.html
+++ b/accessible/tests/mochitest/test_editabletext_1.html
@@ -1,25 +1,29 @@
 <!DOCTYPE html>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=452161
 -->
 <head>
   <title>nsIAccessibleEditableText chrome tests</title>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+  <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="common.js"></script>
   <script type="application/javascript"
           src="editabletext.js"></script>
+  <script type="application/javascript"
+          src="events.js"></script>
 
   <script type="application/javascript">
     var gParagraphAcc;
 
     function testEditable(aID)
     {
       var et = new nsEditableText(aID);
 
@@ -55,26 +59,32 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       //////////////////////////////////////////////////////////////////////////
 //      // cutNPasteText
 //      et.cutNPasteText(0, 1, 1, "ehhelloo");
 //      et.cutNPasteText(1, 2, 0, "hehelloo");
 //      et.cutNPasteText(7, 8, 8, "hehelloo");
     }
 
+    function testDocEditableNFinishTest(aDoc)
+    {
+      testEditable(aDoc);
+      SimpleTest.finish();
+    }
+
     function doTest()
     {
       testEditable("input");
       // testEditable("div"); XXX: bug 452599
 
-      var frame = document.getElementById("frame");
+      // Design mode on/off trigger document accessible subtree recreation.
+      var frame = getNode("frame");
+      waitForEvent(EVENT_REORDER, frame.contentDocument,
+                   testDocEditableNFinishTest, null, frame.contentDocument);
       frame.contentDocument.designMode = "on";
-      testEditable(frame.contentDocument);
-
-      SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>