Bug 1210381 - Remove view-source: when copying links. r=mconley a=sylvestre
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 01 Oct 2015 17:19:20 -0500
changeset 296298 878f69bf290856fe32f4e92c237833cb3070b0ae
parent 296297 dd2e90cfe88ade3cd2863ab2a0b2d03621a25001
child 296299 314a38a414915421b81ee613a3cbc7aeea639aa9
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, sylvestre
bugs1210381
milestone43.0a2
Bug 1210381 - Remove view-source: when copying links. r=mconley a=sylvestre
browser/base/content/nsContextMenu.js
toolkit/components/viewsource/test/browser/browser_contextmenu.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1466,19 +1466,21 @@ nsContextMenu.prototype = {
     }
 
     var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
                     getService(Ci.nsIClipboardHelper);
     clipboard.copyString(addresses);
   },
 
   copyLink: function() {
+    // If we're in a view source tab, remove the view-source: prefix
+    let linkURL = this.linkURL.replace(/^view-source:/, "");
     var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
                     getService(Ci.nsIClipboardHelper);
-    clipboard.copyString(this.linkURL);
+    clipboard.copyString(linkURL);
   },
 
   ///////////////
   // Utilities //
   ///////////////
 
   // Show/hide one item (specified via name or the item element itself).
   showItem: function(aItemOrId, aShow) {
--- a/toolkit/components/viewsource/test/browser/browser_contextmenu.js
+++ b/toolkit/components/viewsource/test/browser/browser_contextmenu.js
@@ -26,18 +26,16 @@ add_task(function *() {
 
   // Selection source in view source tab
   expectedData = [];
   let newTab = yield openDocumentSelect(source, "body");
   yield* onViewSourceWindowOpen(window, true);
 
   contextMenu = document.getElementById("contentAreaContextMenu");
 
-  // Prepend view-source to this one as it opens in a tab.
-  expectedData[0][3] = "view-source:" + expectedData[0][3];
   for (let test of expectedData) {
     yield* checkMenuItems(contextMenu, true, test[0], test[1], test[2], test[3]);
   }
 
   gBrowser.removeTab(newTab);
 
   // Selection source in view source window
   yield pushPrefs(["view_source.tab", false]);