Bug 712871. (Hv1b) Port m-c changeset d957a1dd0894 (semicolon), Reoder cases and elements to make things clearer. r=neil.
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 27 Dec 2011 21:28:08 +0100
changeset 10300 378ab7f9d3bb14a77fe77b70fc0801e91ecd976d
parent 10299 07bbbe99496fd8dd5360710abcd771314b867c15
child 10301 acd227a49aad5d9d0e3555d945ea5a5ad821a73b
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs712871
Bug 712871. (Hv1b) Port m-c changeset d957a1dd0894 (semicolon), Reoder cases and elements to make things clearer. r=neil. m-c changeset d957a1dd0894: add missing semicolons
suite/browser/test/mochitest/subtst_contextmenu.html
suite/browser/test/mochitest/test_contextmenu.html
--- a/suite/browser/test/mochitest/subtst_contextmenu.html
+++ b/suite/browser/test/mochitest/subtst_contextmenu.html
@@ -6,18 +6,16 @@
 <body>
 Browser context menu subtest.
 
 <div id="test-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div>
 <a id="test-link" href="http://mozilla.com">Click the monkey!</a>
 <a id="test-mailto" href="mailto:codemonkey@mozilla.com">Mail the monkey!</a><br>
 <input id="test-input"><br>
 <img id="test-image" src="ctxmenu-image.png">
-<a href="http://mozilla.com"><img id="test-image-link" alt="Click the monkey!" src="ctxmenu-image.png"></a>
-<a href="mailto:codemonkey@mozilla.com"><img id="test-image-mailto" alt="Mail the monkey!" src="ctxmenu-image.png"></a><br>
 <canvas id="test-canvas" width="100" height="100" style="background-color: blue"></canvas>
 <video controls id="test-video-ok"  src="video.ogg" width="100" height="100" style="background-color: green"></video>
 <video controls id="test-video-bad" src="bogus.duh" width="100" height="100" style="background-color: orange"></video>
 <video controls id="test-video-bad2" width="100" height="100" style="background-color: yellow">
   <source src="bogus.duh" type="video/durrrr;">
 </video>
 <iframe id="test-iframe" width="98"  height="98" style="border: 1px solid black"></iframe>
 <textarea id="test-textarea">chssseesbbbie</textarea> <!-- a weird word which generates only one suggestion -->
@@ -54,10 +52,14 @@ Browser context menu subtest.
     </menu>
     <menu>
     </menu>
     <menuitem label="Hidden item" hidden></menuitem>
     <menuitem></menuitem>
   </menu>
 </div>
 
+<!-- SeaMonkey specific elements -->
+<a href="http://mozilla.com"><img id="test-image-link" alt="Click the monkey!" src="ctxmenu-image.png"></a>
+<a href="mailto:codemonkey@mozilla.com"><img id="test-image-mailto" alt="Mail the monkey!" src="ctxmenu-image.png"></a><br>
+
 </body>
 </html>
--- a/suite/browser/test/mochitest/test_contextmenu.html
+++ b/suite/browser/test/mochitest/test_contextmenu.html
@@ -259,17 +259,17 @@ function runTest(testNum) {
                           "context-savepage",     true,
                           "context-sendpage",     true,
                           "---",                  null,
                           "context-viewbgimage",  false,
                           "context-selectall",    true,
                           "---",                  null,
                           "context-viewsource",   true,
                           "context-viewinfo",     true]);
-        closeContextMenu()
+        closeContextMenu();
         openContextMenuFor(link); // Invoke context menu for next test.
         break;
 
     case 3:
         // Context menu for text link
         checkContextMenu(["popupwindow-reject",    true,
                           "---",                   null,
                           "context-openlinkintab", true,
@@ -280,33 +280,33 @@ function runTest(testNum) {
                           "context-sendlink",      true,
                           "context-copylink",      true,
                           "---",                   null,
                           "context-bookmarkpage",  true,
                           "context-savepage",      true,
                           "context-sendpage",      true,
                           "---",                   null,
                           "context-metadata",      true]);
-        closeContextMenu()
+        closeContextMenu();
         openContextMenuFor(mailto); // Invoke context menu for next test.
         break;
 
     case 4:
         // Context menu for text mailto-link
         checkContextMenu(["popupwindow-reject",    true,
                           "---",                   null,
                           "context-copyemail",     true,
                           "context-copylink",      true,
                           "---",                   null,
                           "context-bookmarkpage",  true,
                           "context-savepage",      true,
                           "context-sendpage",      true,
                           "---",                   null,
                           "context-metadata",      true]);
-        closeContextMenu()
+        closeContextMenu();
         openContextMenuFor(input); // Invoke context menu for next test.
         break;
 
     case 5:
         // Context menu for text input field
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "context-undo",        false,
@@ -315,17 +315,17 @@ function runTest(testNum) {
                           "context-cut",         false,
                           "context-copy",        false,
                           "context-paste",       null, // ignore clipboard state
                           "context-delete",      false,
                           "---",                 null,
                           "context-selectall",   false,
                           "---",                 null,
                           "spell-check-enabled", true]);
-        closeContextMenu()
+        closeContextMenu();
         openContextMenuFor(img); // Invoke context menu for next test.
         break;
 
     case 6:
         // Context menu for an image
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-reloadimage",  true,
@@ -339,87 +339,34 @@ function runTest(testNum) {
                          ["context-setWallpaper", true] : []).concat(
                          ["---",                  null,
                           "context-bookmarkpage", true,
                           "context-savepage",     true,
                           "context-sendpage",     true,
                           "---",                  null,
                           "context-metadata",     true]));
         closeContextMenu();
-        openContextMenuFor(img_link); // Invoke context menu for next test.
+        openContextMenuFor(canvas); // Invoke context menu for next test.
         break;
 
     case 7:
-        // 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,
-                          "context-sendlink",      true,
-                          "context-copylink",      true,
-                          "---",                   null,
-                          "context-reloadimage",  true,
-                          "context-viewimage",    true,
-                          "context-blockimage",   true,
-                          "context-copyimage",    true,
-                          "---",                  null,
-                          "context-saveimage",    true,
-                          "context-sendimage",    true].concat(
-                         ("@mozilla.org/suite/shell-service;1" in Components.classes) ?
-                         ["context-setWallpaper", true] : []).concat(
-                         ["---",                  null,
-                          "context-bookmarkpage", true,
-                          "---",                  null,
-                          "context-metadata",     true]));
-        closeContextMenu();
-        openContextMenuFor(img_mailto); // Invoke context menu for next test.
-        break;
-
-    case 8:
-        // 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,
-                          "context-blockimage",   true,
-                          "context-copyimage",    true,
-                          "---",                  null,
-                          "context-saveimage",    true,
-                          "context-sendimage",    true].concat(
-                         ("@mozilla.org/suite/shell-service;1" in Components.classes) ?
-                         ["context-setWallpaper", true] : []).concat(
-                         ["---",                  null,
-                          "context-bookmarkpage", true,
-                          "---",                  null,
-                          "context-metadata",     true]));
-        closeContextMenu();
-        openContextMenuFor(canvas); // Invoke context menu for next test.
-        break;
-
-    case 9:
         // Context menu for a canvas
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-viewimage",    true,
                           "context-saveimage",    true,
                           "context-sendimage",    true,
                           "context-bookmarkpage", true,
                           "context-sendpage",     true,
                           "context-selectall",    true]);
         closeContextMenu();
         openContextMenuFor(video_ok); // Invoke context menu for next test.
         break;
 
-    case 10:
+    case 8:
         // Context menu for a video (with a VALID media source)
         checkContextMenu(["popupwindow-reject",         true,
                           "---",                        null,
                           "context-media-play",         true,
                           "context-media-mute",         true,
                           "context-media-hidecontrols", true,
                           "context-video-showstats",    true,
                           "context-video-fullscreen",   true,
@@ -429,17 +376,17 @@ function runTest(testNum) {
                           "---",                        null,
                           "context-savevideo",          true,
                           "context-sendvideo",          true,
                           "context-video-saveimage",    true]);
         closeContextMenu();
         openContextMenuFor(video_bad); // Invoke context menu for next test.
         break;
 
-    case 11:
+    case 9:
         // Context menu for a video (with an INVALID media source)
         checkContextMenu(["popupwindow-reject",         true,
                           "---",                        null,
                           "context-media-play",         false,
                           "context-media-mute",         false,
                           "context-media-hidecontrols", false,
                           "context-video-showstats",    false,
                           "context-video-fullscreen",   false,
@@ -449,17 +396,17 @@ function runTest(testNum) {
                           "---",                        null,
                           "context-savevideo",          true,
                           "context-sendvideo",          true,
                           "context-video-saveimage",    false]);
         closeContextMenu();
         openContextMenuFor(video_bad2); // Invoke context menu for next test.
         break;
 
-    case 12:
+    case 10:
         // Context menu for a video (with an INVALID media source)
         checkContextMenu(["popupwindow-reject",         true,
                           "---",                        null,
                           "context-media-play",         false,
                           "context-media-mute",         false,
                           "context-media-hidecontrols", false,
                           "context-video-showstats",    false,
                           "context-video-fullscreen",   false,
@@ -469,17 +416,17 @@ function runTest(testNum) {
                           "---",                        null,
                           "context-savevideo",          false,
                           "context-sendvideo",          false,
                           "context-video-saveimage",    false]);
         closeContextMenu();
         openContextMenuFor(iframe); // Invoke context menu for next test.
         break;
 
-    case 13:
+    case 11:
         // Context menu for an iframe
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-back",         false,
                           "context-forward",      false,
                           "context-reload",       true,
                           "context-stop",         false,
                           "---",                  null,
@@ -505,17 +452,17 @@ function runTest(testNum) {
                                "context-sendframe",         true,
                                "---",                       null,
                                "context-viewframesource",   true,
                                "context-viewframeinfo",     true], null]);
         closeContextMenu();
         openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck.
         break;
 
-    case 14:
+    case 12:
         // Context menu for textarea
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "*chubbiness",         true, // spelling suggestion
                           "---",                 null,
                           "spell-add-to-dictionary", true,
                           "spell-ignore-word",   true,
                           "---",                 null,
@@ -534,17 +481,17 @@ function runTest(testNum) {
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null]);
 
         closeContextMenu();
         openContextMenuFor(contenteditable); // Invoke context menu for next test.
         break;
 
-    case 15:
+    case 13:
         // Context menu for contenteditable
         checkContextMenu(["popupwindow-reject",  true,
                           "---",                 null,
                           "spell-no-suggestions", false,
                           "---",                 null,
                           "spell-add-to-dictionary", true,
                           "spell-ignore-word",   true,
                           "---",                 null,
@@ -563,17 +510,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 16:
+    case 14:
         // 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,
@@ -592,23 +539,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 17:
+    case 15:
         executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
         closeContextMenu();
         openContextMenuFor(pagemenu); // Invoke context menu for next test.
         break;
 
-    case 18:
+    case 16:
         // 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},
@@ -642,17 +589,17 @@ function runTest(testNum) {
                           "context-viewsource",   true,
                           "context-viewinfo",     true]);
 
         invokeItemAction("0");
         closeContextMenu();
         openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
         break;
 
-    case 19:
+    case 17:
         // 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,
@@ -661,16 +608,72 @@ function runTest(testNum) {
                           "context-savepage",     true,
                           "context-sendpage",     true,
                           "---",                  null,
                           "context-viewbgimage",  false,
                           "context-selectall",    true,
                           "---",                  null,
                           "context-viewsource",   true,
                           "context-viewinfo",     true]);
+        closeContextMenu();
+
+        // Continue with SeaMonkey specific cases.
+        openContextMenuFor(img_link); // Invoke context menu for next test.
+        break;
+
+    case 18:
+        // 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,
+                          "context-sendlink",      true,
+                          "context-copylink",      true,
+                          "---",                   null,
+                          "context-reloadimage",  true,
+                          "context-viewimage",    true,
+                          "context-blockimage",   true,
+                          "context-copyimage",    true,
+                          "---",                  null,
+                          "context-saveimage",    true,
+                          "context-sendimage",    true].concat(
+                         ("@mozilla.org/suite/shell-service;1" in Components.classes) ?
+                         ["context-setWallpaper", true] : []).concat(
+                         ["---",                  null,
+                          "context-bookmarkpage", true,
+                          "---",                  null,
+                          "context-metadata",     true]));
+        closeContextMenu();
+        openContextMenuFor(img_mailto); // Invoke context menu for next test.
+        break;
+
+    case 19:
+        // 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,
+                          "context-blockimage",   true,
+                          "context-copyimage",    true,
+                          "---",                  null,
+                          "context-saveimage",    true,
+                          "context-sendimage",    true].concat(
+                         ("@mozilla.org/suite/shell-service;1" in Components.classes) ?
+                         ["context-setWallpaper", true] : []).concat(
+                         ["---",                  null,
+                          "context-bookmarkpage", true,
+                          "---",                  null,
+                          "context-metadata",     true]));
+        closeContextMenu();
 
         subwindow.close();
         SimpleTest.finish();
         return;
 
     /*
      * Other things that would be nice to test:
      *  - selected text
@@ -686,19 +689,21 @@ function runTest(testNum) {
         return;
   }
 
 }
 
 
 var testNum = 1;
 var subwindow, chromeWin, contextMenu, lastElement;
-var text, link, mailto, input, img, img_link, img_mailto, canvas, video_ok,
-    video_bad, video_bad2, iframe, textarea, contenteditable, inputspell,
-    pagemenu;
+var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
+    iframe, textarea, contenteditable, inputspell, pagemenu;
+
+// SeaMonkey specific variables.
+var img_link, img_mailto;
 
 function startTest() {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     chromeWin = subwindow
                     .QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIWebNavigation)
                     .QueryInterface(Ci.nsIDocShellTreeItem)
                     .rootTreeItem
@@ -716,28 +721,30 @@ function startTest() {
 
     lastElement = null;
 
     text       = subwindow.document.getElementById("test-text");
     link       = subwindow.document.getElementById("test-link");
     mailto     = subwindow.document.getElementById("test-mailto");
     input      = subwindow.document.getElementById("test-input");
     img        = subwindow.document.getElementById("test-image");
-    img_link   = subwindow.document.getElementById("test-image-link");
-    img_mailto = subwindow.document.getElementById("test-image-mailto");
     canvas     = subwindow.document.getElementById("test-canvas");
     video_ok   = subwindow.document.getElementById("test-video-ok");
     video_bad  = subwindow.document.getElementById("test-video-bad");
     video_bad2 = subwindow.document.getElementById("test-video-bad2");
     iframe     = subwindow.document.getElementById("test-iframe");
     textarea   = subwindow.document.getElementById("test-textarea");
     contenteditable = subwindow.document.getElementById("test-contenteditable");
     inputspell = subwindow.document.getElementById("test-input-spellcheck");
     pagemenu = subwindow.document.getElementById("test-pagemenu");
 
+    // SeaMonkey specific elements.
+    img_link   = subwindow.document.getElementById("test-image-link");
+    img_mailto = subwindow.document.getElementById("test-image-mailto");
+
     contextMenu.addEventListener("popupshown", function() { runTest(++testNum); }, false);
     runTest(1);
 }
 
 // We open this in a separate window, because the Mochitests run inside a frame.
 // The frame causes an extra menu item, and prevents running the test
 // standalone (ie, clicking the test name in the Mochitest window) to see
 // success/failure messages.