Bug 715410 Test for |Undo Add To Dictionary| test_contextmenu.html r=Neil
authorEdmund Wong <ewong@pw-wspx.org>
Tue, 25 Sep 2012 21:23:18 +0800
changeset 11125 d61f5d649d859f7a1ab49dba3d097370e22ef431
parent 11124 80da40ae69bef7ea4329459f3a87a940b2d4742b
child 11126 68361e51699b69b8a86b40179e215ca4a7e21086
push id8346
push userphilip.chee@gmail.com
push dateTue, 25 Sep 2012 13:24:42 +0000
treeherdercomm-central@562b2bdd8712 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs715410
Bug 715410 Test for |Undo Add To Dictionary| test_contextmenu.html r=Neil
suite/browser/test/mochitest/test_contextmenu.html
--- a/suite/browser/test/mochitest/test_contextmenu.html
+++ b/suite/browser/test/mochitest/test_contextmenu.html
@@ -14,16 +14,18 @@ Browser context menu tests.
 <div id="content">
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Login Manager: multiple login autocomplete. **/
 
+Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
+
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 function openContextMenuFor(element, shiftkey, shouldWaitForFocus) {
     // Context menu should be closed before we open it again.
     is(contextMenu.state, "closed", "checking if popup is closed");
 
     if (lastElement)
@@ -241,32 +243,33 @@ function runTest(testNum) {
   switch (testNum) {
     case 1:
         // Invoke context menu for next test.
         openContextMenuFor(text);
         break;
 
     case 2:
         // Context menu for plain text
-        checkContextMenu(["popupwindow-reject",   true,
+        plainTextItems = ["popupwindow-reject",   true,
                           "---",                  null,
                           "context-back",         false,
                           "context-forward",      false,
                           "context-reload",       true,
                           "context-stop",         false,
                           "---",                  null,
                           "context-bookmarkpage", true,
                           "context-savepage",     true,
                           "context-sendpage",     true,
                           "---",                  null,
                           "context-viewbgimage",  false,
                           "context-selectall",    true,
                           "---",                  null,
                           "context-viewsource",   true,
-                          "context-viewinfo",     true]);
+                          "context-viewinfo",     true];
+        checkContextMenu(plainTextItems);
         closeContextMenu();
         openContextMenuFor(link); // Invoke context menu for next test.
         break;
 
     case 3:
         // Context menu for text link
         checkContextMenu(["popupwindow-reject",    true,
                           "---",                   null,
@@ -533,20 +536,27 @@ function runTest(testNum) {
                                "---",                       null,
                                "context-bookmarkframe",     true,
                                "context-saveframe",         true,
                                "context-sendframe",         true,
                                "---",                       null,
                                "context-viewframesource",   true,
                                "context-viewframeinfo",     true], null]));
         closeContextMenu();
+        openContextMenuFor(text); // Invoke context menu for next test.
+        break;
+
+    case 15:
+        // Re-check context menu for plain text to make sure it hasn't changed
+        checkContextMenu(plainTextItems);
+        closeContextMenu();        
         openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck.
         break;
 
-    case 15:
+    case 16:
         // Context menu for textarea
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "*chubbiness",         true, // spelling suggestion
                           "---",                 null,
                           "spell-add-to-dictionary", true,
                           "spell-ignore-word",   true,
                           "---",                 null,
@@ -561,21 +571,51 @@ function runTest(testNum) {
                           "context-selectall",   true,
                           "---",                 null,
                           "spell-check-enabled", true,
                           "spell-dictionaries",  true,
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null]);
 
+        contextMenu.ownerDocument.getElementById("spell-add-to-dictionary").doCommand(); // Add to dictionary
         closeContextMenu();
-        openContextMenuFor(contenteditable); // Invoke context menu for next test.
+        openContextMenuFor(textarea, false, true); // Invoke context menu for next test.
         break;
 
-    case 16:
+    case 17:
+        // Context menu for textarea after a word has been added
+        // to the dictionary
+        checkContextMenu(["popupwindow-reject",  true,
+                          "---",                 null,
+                          "spell-undo-add-to-dictionary", true,
+                          "---",                 null,
+                          "context-undo",        false,
+                          "context-redo",        false,
+                          "---",                 null,
+                          "context-cut",         false,
+                          "context-copy",        false,
+                          "context-paste",       null, // ignore clipboard state
+                          "context-delete",      false,
+                          "---",                 null,
+                          "context-selectall",   true,
+                          "---",                 null,
+                          "spell-check-enabled", true,
+                          "spell-dictionaries",  true,
+                              ["spell-check-dictionary-en-US", true,
+                               "---",                          null,
+                               "spell-add-dictionaries",       true], null,
+                         ]);
+
+        contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary
+        closeContextMenu();
+        openContextMenuFor(contenteditable);
+        break;
+
+    case 18:
         // Context menu for contenteditable
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "spell-no-suggestions", false,
                           "---",                 null,
                           "spell-add-to-dictionary", true,
                           "spell-ignore-word",   true,
                           "---",                 null,
@@ -594,17 +634,17 @@ function runTest(testNum) {
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null]);
 
         closeContextMenu();
         openContextMenuFor(inputspell); // Invoke context menu for next test.
         break;
 
-    case 17:
+    case 19:
         // Context menu for spell-check input
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "*prodigality",        true, // spelling suggestion
                           "---",                 null,
                           "spell-add-to-dictionary", true,
                           "spell-ignore-word",   true,
                           "---",                 null,
@@ -623,23 +663,23 @@ function runTest(testNum) {
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null]);
 
         closeContextMenu();
         openContextMenuFor(link); // Invoke context menu for next test.
         break;
 
-    case 18:
+    case 20:
         executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
         closeContextMenu();
         openContextMenuFor(pagemenu); // Invoke context menu for next test.
         break;
 
-    case 19:
+    case 21:
         // Context menu for element with assigned content context menu
         checkContextMenu(["+Plain item",          {type: "", icon: "", checked: false, disabled: false},
                           "+Disabled item",       {type: "", icon: "", checked: false, disabled: true},
                           "+Item w/ textContent", {type: "", icon: "", checked: false, disabled: false},
                           "---",                  null,
                           "+Checkbox",            {type: "checkbox", icon: "", checked: true, disabled: false},
                           "---",                  null,
                           "+Radio1",              {type: "checkbox", icon: "", checked: true, disabled: false},
@@ -673,17 +713,17 @@ function runTest(testNum) {
                           "context-viewsource",   true,
                           "context-viewinfo",     true]);
 
         invokeItemAction("0");
         closeContextMenu();
         openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
         break;
 
-    case 20:
+    case 22:
         // Context menu for element with assigned content context menu
         // The shift key should bypass content context menu processing
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-back",         false,
                           "context-forward",      false,
                           "context-reload",       true,
                           "context-stop",         false,
@@ -698,17 +738,17 @@ function runTest(testNum) {
                           "context-viewsource",   true,
                           "context-viewinfo",     true]);
         closeContextMenu();
 
         // Continue with SeaMonkey specific cases.
         openContextMenuFor(img_link); // Invoke context menu for next test.
         break;
 
-    case 21:
+    case 23:
         // Context menu for an image with a link
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-openlinkintab", true,
                           "context-openlink",      true,
                           "---",                   null,
                           "context-bookmarklink",  true,
                           "context-savelink",      true,
@@ -727,17 +767,17 @@ function runTest(testNum) {
                          ["---",                  null,
                           "context-bookmarkpage", true,
                           "---",                  null,
                           "context-metadata",     true]));
         closeContextMenu();
         openContextMenuFor(img_mailto); // Invoke context menu for next test.
         break;
 
-    case 22:
+    case 24:
         // Context menu for an image with a mailto: link
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-copyemail",     true,
                           "context-copylink",      true,
                           "---",                   null,
                           "context-reloadimage",  true,
                           "context-viewimage",    true,