зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1320061 - Add pref that allows users to copy unescaped URL from the URL bar r=mak
MozReview-Commit-ID: CDnMnkqj8gW * * * Bug 1320061 - Add test for copying non-ascii URL from the urlbar MozReview-Commit-ID: 72jymxn6DJv --HG-- extra : rebase_source : 06b33dc4a22745076ad5fbd61ccd573efb84ce4a
This commit is contained in:
Родитель
91e6ea18e7
Коммит
1fbe2eb916
|
@ -318,6 +318,10 @@ pref("browser.urlbar.oneOffSearches", true);
|
|||
pref("browser.urlbar.oneOffSearches", false);
|
||||
#endif
|
||||
|
||||
// If changed to true, copying the entire URL from the location bar will put the
|
||||
// human readable (percent-decoded) URL on the clipboard.
|
||||
pref("browser.urlbar.decodeURLsOnCopy", false);
|
||||
|
||||
pref("browser.altClickSave", false);
|
||||
|
||||
// Enable logging downloads operations to the Console.
|
||||
|
|
|
@ -3,6 +3,15 @@
|
|||
|
||||
const trimPref = "browser.urlbar.trimURLs";
|
||||
const phishyUserPassPref = "network.http.phishy-userpass-length";
|
||||
const decodeURLpref = "browser.urlbar.decodeURLsOnCopy";
|
||||
|
||||
function toUnicode(input) {
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||
.createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
converter.charset = "UTF-8";
|
||||
|
||||
return converter.ConvertToUnicode(input);
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
||||
|
@ -12,6 +21,7 @@ function test() {
|
|||
gBrowser.removeTab(tab);
|
||||
Services.prefs.clearUserPref(trimPref);
|
||||
Services.prefs.clearUserPref(phishyUserPassPref);
|
||||
Services.prefs.clearUserPref(decodeURLpref);
|
||||
URLBarSetURI();
|
||||
});
|
||||
|
||||
|
@ -141,7 +151,17 @@ var tests = [
|
|||
{
|
||||
copyVal: "<data:text/html,(%C3%A9 %25P>)",
|
||||
copyExpected: "data:text/html,(%C3%A9 %25P",
|
||||
}
|
||||
},
|
||||
{
|
||||
setup: function() { Services.prefs.setBoolPref(decodeURLpref, true); },
|
||||
loadURL: "http://example.com/%D0%B1%D0%B8%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F",
|
||||
expectedURL: toUnicode("example.com/биография"),
|
||||
copyExpected: toUnicode("http://example.com/биография")
|
||||
},
|
||||
{
|
||||
copyVal: toUnicode("<example.com/би>ография"),
|
||||
copyExpected: toUnicode("http://example.com/би")
|
||||
},
|
||||
];
|
||||
|
||||
function nextTest() {
|
||||
|
@ -162,6 +182,10 @@ function runTest(testCase, cb) {
|
|||
testCopy(testCase.copyVal, testCase.copyExpected, cb);
|
||||
}
|
||||
|
||||
if (testCase.setup) {
|
||||
testCase.setup();
|
||||
}
|
||||
|
||||
if (testCase.loadURL) {
|
||||
loadURL(testCase.loadURL, doCheck);
|
||||
} else {
|
||||
|
|
|
@ -797,19 +797,17 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|||
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
|
||||
// are hard to read when encoded
|
||||
if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) {
|
||||
selectedVal = uri.spec;
|
||||
}
|
||||
|
||||
return selectedVal;
|
||||
// If the entire URL is selected, just use the actual loaded URI,
|
||||
// unless we want a decoded URI, or it's a data: or javascript: URI,
|
||||
// since those are hard to read when encoded.
|
||||
if (inputVal == selectedVal &&
|
||||
!uri.schemeIs("javascript") && !uri.schemeIs("data") &&
|
||||
!Services.prefs.getBoolPref("browser.urlbar.decodeURLsOnCopy")) {
|
||||
return uri.spec;
|
||||
}
|
||||
|
||||
// Just the beginning of the URL is selected, check for a trimmed
|
||||
// value
|
||||
// Just the beginning of the URL is selected, or we want a decoded
|
||||
// url. First check for a trimmed value.
|
||||
let spec = uri.spec;
|
||||
let trimmedSpec = this.trimValue(spec);
|
||||
if (spec != trimmedSpec) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче