bug 487692 - Fix context menu IDs and accesskeys and add a test for them, add tests for linked images and fix Windows failures, r=Neil
authorRobert Kaiser <kairo@kairo.at>
Thu, 29 Apr 2010 20:04:08 +0200
changeset 5550 87899a3eea57f8144b761242e77bf9a0fbc1d5dc
parent 5549 4660a6ea3a97f178a6e572b13de6560e1b9aaf7f
child 5551 182e43de366ef4eee02fbf8907a3cb4b9ee7df69
push id4297
push userkairo@kairo.at
push dateThu, 29 Apr 2010 18:04:23 +0000
treeherdercomm-central@87899a3eea57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs487692
bug 487692 - Fix context menu IDs and accesskeys and add a test for them, add tests for linked images and fix Windows failures, r=Neil
suite/browser/test/mochitest/subtst_contextmenu.html
suite/browser/test/mochitest/test_contextmenu.html
suite/locales/en-US/chrome/common/contentAreaCommands.dtd
suite/locales/en-US/chrome/common/contentAreaCommands.properties
--- a/suite/browser/test/mochitest/subtst_contextmenu.html
+++ b/suite/browser/test/mochitest/subtst_contextmenu.html
@@ -6,16 +6,18 @@
 <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 id="test-video-ok"  src="video.ogg" width="100" height="100" style="background-color: green"></video>
 <video id="test-video-bad" src="bogus.duh" width="100" height="100" style="background-color: orange"></video>
 <video 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>
 
--- a/suite/browser/test/mochitest/test_contextmenu.html
+++ b/suite/browser/test/mochitest/test_contextmenu.html
@@ -229,42 +229,97 @@ function runTest(testNum) {
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-reloadimage",  true,
                           "context-viewimage",    true,
                           "context-blockimage",   true,
                           "context-copyimage",    true,
                           "---",                  null,
                           "context-saveimage",    true,
-                          "context-sendimage",    true,
-                          "---",                  null,
+                          "context-sendimage",    true].concat(
+                         ("@mozilla.org/suite/shell-service;1" in Components.classes) ?
+                         ["context-setWallpaper", true] : []).concat(
+                         ["---",                  null,
                           "context-bookmarkpage", true,
                           "context-savepage",     true,
                           "context-sendpage",     true,
                           "---",                  null,
-                          "context-metadata",     true]);
+                          "context-metadata",     true]));
+        closeContextMenu();
+        openContextMenuFor(img_link); // Invoke context menu for next test.
+        break;
+
+    case 7:
+        // Context menu for an image with a link
+        checkContextMenu(["popupwindow-reject",   true,
+                          "---",                  null,
+                          "context-openlink",      true,
+                          "context-openlinkintab", 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 7:
+    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 8:
+    case 10:
         // 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-showcontrols", true,
                           "context-video-fullscreen",   true,
                           "---",                        null,
@@ -272,17 +327,17 @@ function runTest(testNum) {
                           "context-copyvideourl",       true,
                           "---",                        null,
                           "context-savevideo",          true,
                           "context-sendvideo",          true]);
         closeContextMenu();
         openContextMenuFor(video_bad); // Invoke context menu for next test.
         break;
 
-    case 9:
+    case 11:
         // 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-showcontrols", false,
                           "context-video-fullscreen",   false,
                           "---",                        null,
@@ -290,17 +345,17 @@ function runTest(testNum) {
                           "context-copyvideourl",       true,
                           "---",                        null,
                           "context-savevideo",          true,
                           "context-sendvideo",          true]);
         closeContextMenu();
         openContextMenuFor(video_bad2); // Invoke context menu for next test.
         break;
 
-    case 10:
+    case 12:
         // 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-showcontrols", false,
                           "context-video-fullscreen",   false,
                           "---",                        null,
@@ -308,17 +363,17 @@ function runTest(testNum) {
                           "context-copyvideourl",       false,
                           "---",                        null,
                           "context-savevideo",          false,
                           "context-sendvideo",          false]);
         closeContextMenu();
         openContextMenuFor(iframe); // Invoke context menu for next test.
         break;
 
-    case 11:
+    case 13:
         // Context menu for an iframe
         checkContextMenu(["popupwindow-reject",   true,
                           "---",                  null,
                           "context-back",         false,
                           "context-forward",      false,
                           "context-reload",       true,
                           "context-stop",         false,
                           "---",                  null,
@@ -366,41 +421,44 @@ function runTest(testNum) {
         return;
   }
 
 }
 
 
 var testNum = 1;
 var subwindow, chromeWin, contextMenu;
-var text, link, mailto, input, img, canvas, video, iframe;
+var text, link, mailto, input, img, img_link, img_mailto, canvas, video_ok,
+    video_bad, video_bad2, iframe;
 
 function startTest() {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     chromeWin = subwindow
                     .QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIWebNavigation)
                     .QueryInterface(Ci.nsIDocShellTreeItem)
                     .rootTreeItem
                     .QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIDOMWindow)
                     .QueryInterface(Ci.nsIDOMChromeWindow);
     contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
     ok(contextMenu, "Got context menu XUL");
 
-    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");
-    canvas = subwindow.document.getElementById("test-canvas");
+    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");
+    iframe     = subwindow.document.getElementById("test-iframe");
 
     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
--- a/suite/locales/en-US/chrome/common/contentAreaCommands.dtd
+++ b/suite/locales/en-US/chrome/common/contentAreaCommands.dtd
@@ -39,23 +39,23 @@
 <!ENTITY viewPageInfoCmd.accesskey    "I">
 <!ENTITY viewFrameInfoCmd.label       "View Frame Info">
 <!ENTITY viewFrameInfoCmd.accesskey   "I">
 <!ENTITY fitImageCmd.label            "Fit Image to Window">
 <!ENTITY fitImageCmd.accesskey        "F">
 <!ENTITY reloadImageCmd.label         "Reload Image">
 <!ENTITY reloadImageCmd.accesskey     "R">
 <!ENTITY viewImageCmd.label           "View Image">
-<!ENTITY viewImageCmd.accesskey       "w">
+<!ENTITY viewImageCmd.accesskey       "I">
 <!ENTITY viewVideoCmd.label           "View Video">
 <!ENTITY viewVideoCmd.accesskey       "i">
 <!ENTITY viewBGImageCmd.label         "View Background Image">
 <!ENTITY viewBGImageCmd.accesskey     "w">
 <!ENTITY setWallpaperCmd.label        "Set As Wallpaper">
-<!ENTITY setWallpaperCmd.accesskey    "e">
+<!ENTITY setWallpaperCmd.accesskey    "A">
 <!ENTITY bookmarkPageCmd.label        "Bookmark This Page">
 <!ENTITY bookmarkPageCmd.accesskey    "m">
 <!ENTITY bookmarkLinkCmd.label        "Bookmark This Link">
 <!ENTITY bookmarkLinkCmd.accesskey    "B">
 <!ENTITY bookmarkFrameCmd.label       "Bookmark This Frame">
 <!ENTITY bookmarkFrameCmd.accesskey   "m">
 <!ENTITY savePageAsCmd.label          "Save Page As…">
 <!ENTITY savePageCmd.label            "Save Page">
@@ -76,25 +76,25 @@
 <!ENTITY saveAudioCmd.accesskey       "v">
 <!ENTITY copyCmd.label                "Copy">
 <!ENTITY copyCmd.accesskey            "C">
 <!ENTITY selectAllCmd.label           "Select All">
 <!ENTITY selectAllCmd.accesskey       "A">
 <!ENTITY copyLinkCmd.label            "Copy Link Location">
 <!ENTITY copyLinkCmd.accesskey        "L">
 <!ENTITY copyImageCmd.label           "Copy Image">
-<!ENTITY copyImageCmd.accesskey       "I">
+<!ENTITY copyImageCmd.accesskey       "y">
 <!ENTITY copyVideoURLCmd.label        "Copy Video Location">
 <!ENTITY copyVideoURLCmd.accesskey    "L">
 <!ENTITY copyAudioURLCmd.label        "Copy Audio Location">
 <!ENTITY copyAudioURLCmd.accesskey    "L">
 <!ENTITY metadataCmd.label            "Properties">
 <!ENTITY metadataCmd.accesskey        "P">
 <!ENTITY copyEmailCmd.label           "Copy Email Address">
-<!ENTITY copyEmailCmd.accesskey       "A">
+<!ENTITY copyEmailCmd.accesskey       "s">
 <!ENTITY pasteCmd.label               "Paste">
 <!ENTITY pasteCmd.accesskey           "P">
 <!ENTITY cutCmd.label                 "Cut">
 <!ENTITY cutCmd.accesskey             "t">
 <!ENTITY deleteCmd.label              "Delete">
 <!ENTITY deleteCmd.accesskey          "D">
 <!ENTITY undoCmd.label                "Undo">
 <!ENTITY undoCmd.accesskey            "U">
--- a/suite/locales/en-US/chrome/common/contentAreaCommands.properties
+++ b/suite/locales/en-US/chrome/common/contentAreaCommands.properties
@@ -1,9 +1,9 @@
 # context menu strings
 
 searchText=Search Web for "%S"
 searchText.accesskey=S
 
 blockImage=Block Images from %S
-blockImage.accesskey=k
+blockImage.accesskey=c
 unblockImage=Unblock Images from %S
-unblockImage.accesskey=k
+unblockImage.accesskey=c