Bug 1257804 - avoid copy-pasting about:reader and copy-paste the URL instead, r=dolske, a=ritu
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 21 Mar 2016 11:25:17 +0000
changeset 323803 3e3bdbc7ac120e442fe099adcab8ffc6b4eb1d02
parent 323802 59db0f178e71825daab8621d2cc2a036ac0eaa3b
child 323804 5e58ca6ae7033872ae13d95fc8ee92f7f0eedd8a
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, ritu
bugs1257804
milestone47.0a2
Bug 1257804 - avoid copy-pasting about:reader and copy-paste the URL instead, r=dolske, a=ritu MozReview-Commit-ID: IzBVSG4ZUte
browser/base/content/test/general/browser_readerMode.js
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/test/general/browser_readerMode.js
+++ b/browser/base/content/test/general/browser_readerMode.js
@@ -55,16 +55,25 @@ add_task(function* test_reader_button() 
 
   let readerUrl = gBrowser.selectedBrowser.currentURI.spec;
   ok(readerUrl.startsWith("about:reader"), "about:reader loaded after clicking reader mode button");
   is_element_visible(readerButton, "Reader mode button is present on about:reader");
 
   is(gURLBar.value, readerUrl, "gURLBar value is about:reader URL");
   is(gURLBar.textValue, url.substring("http://".length), "gURLBar is displaying original article URL");
 
+  // Check selected value for URL bar
+  yield new Promise((resolve, reject) => {
+    waitForClipboard(url, function () {
+      gURLBar.focus();
+      gURLBar.select();
+      goDoCommand("cmd_copy");
+    }, resolve, reject);
+  });
+
   // Switch page back out of reader mode.
   readerButton.click();
   yield promiseTabLoadEvent(tab);
   is(gBrowser.selectedBrowser.currentURI.spec, url,
     "Original page loaded after clicking active reader mode button");
 
   // Load a new tab that is NOT reader-able.
   let newTab = gBrowser.selectedTab = gBrowser.addTab();
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -607,16 +607,22 @@ file, You can obtain one at http://mozil
             // We're dealing with an autocompleted value, create a new URI from that.
             try {
               uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
             } catch (e) {}
             if (!uri)
               return selectedVal;
           }
 
+          // Avoid copying 'about:reader?url=', and always provide the original URI:
+          let readerOriginalURL = ReaderMode.getOriginalUrl(uri.spec);
+          if (readerOriginalURL) {
+            uri = uriFixup.createFixupURI(readerOriginalURL, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
+          }
+
           // Only copy exposable URIs
           try {
             uri = uriFixup.createExposableURI(uri);
           } catch (ex) {}
 
           // If the entire URL is selected, just use the actual loaded URI.
           if (inputVal == selectedVal) {
             // ... but only if  isn't a javascript: or data: URI, since those