author | Dão Gottwald <dao@mozilla.com> |
Fri, 19 Aug 2011 11:17:39 +0200 | |
changeset 75618 | 6dc468c41136e1c859678ac431d6e31d76fd8503 |
parent 75617 | 6009974c1e1c42edaf2e39f298d499f759e1eea9 |
child 75619 | 482742e6fff759fb007cb4414208862a72308b77 |
push id | 1371 |
push user | bmo@edmorley.co.uk |
push date | Sun, 21 Aug 2011 18:18:23 +0000 |
treeherder | mozilla-inbound@482742e6fff7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gavin, faaborg |
bugs | 673528 |
milestone | 9.0a1 |
first release with | nightly linux32
6dc468c41136
/
9.0a1
/
20110821030758
/
files
nightly linux64
6dc468c41136
/
9.0a1
/
20110821030758
/
files
nightly mac
6dc468c41136
/
9.0a1
/
20110821030758
/
files
nightly win32
6dc468c41136
/
9.0a1
/
20110821030758
/
files
nightly win64
6dc468c41136
/
9.0a1
/
20110821030758
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
9.0a1
/
20110821030758
/
pushlog to previous
nightly linux64
9.0a1
/
20110821030758
/
pushlog to previous
nightly mac
9.0a1
/
20110821030758
/
pushlog to previous
nightly win32
9.0a1
/
20110821030758
/
pushlog to previous
nightly win64
9.0a1
/
20110821030758
/
pushlog to previous
|
--- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -172,16 +172,17 @@ endif browser_bug599325.js \ browser_bug609700.js \ browser_bug616836.js \ browser_bug623893.js \ browser_bug624734.js \ browser_bug647886.js \ browser_bug655584.js \ browser_bug664672.js \ + browser_canonizeURL.js \ browser_findbarClose.js \ browser_keywordBookmarklets.js \ browser_contextSearchTabPosition.js \ browser_ctrlTab.js \ browser_customize_popupNotification.js \ browser_disablechrome.js \ browser_discovery.js \ browser_duplicateIDs.js \
new file mode 100644 --- /dev/null +++ b/browser/base/content/test/browser_canonizeURL.js @@ -0,0 +1,54 @@ +function test() { + waitForExplicitFinish(); + testNext(); +} + +var pairs = [ + ["example", "http://www.example.net/"], + ["ex-ample", "http://www.ex-ample.net/"], + [" example ", "http://www.example.net/"], + [" example/foo ", "http://www.example.net/foo"], + [" example/foo bar ", "http://www.example.net/foo%20bar"], + ["example.net", "http://example.net/"], + ["http://example", "http://example/"], + ["example:8080", "http://example:8080/"], + ["ex-ample.foo", "http://ex-ample.foo/"], + ["example.foo/bar ", "http://example.foo/bar"], + ["1.1.1.1", "http://1.1.1.1/"], + ["ftp://example", "ftp://example/"], + ["ftp.example.bar", "ftp://ftp.example.bar/"], + ["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample").uri.spec], +]; + +function testNext() { + if (!pairs.length) { + finish(); + return; + } + + let [inputValue, expectedURL] = pairs.shift(); + + gBrowser.addProgressListener({ + onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && + aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { + is(aRequest.originalURI.spec, expectedURL, + "entering '" + inputValue + "' loads expected URL"); + + gBrowser.removeProgressListener(this); + gBrowser.stop(); + + executeSoon(testNext); + } + } + }); + + gURLBar.addEventListener("focus", function onFocus() { + gURLBar.removeEventListener("focus", onFocus); + EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); + }); + + gBrowser.selectedBrowser.focus(); + gURLBar.inputField.value = inputValue; + gURLBar.focus(); +}
--- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -362,17 +362,17 @@ <parameter name="aTriggeringEvent"/> <body><![CDATA[ var url = this.value; if (!url) return ["", null, false]; // Only add the suffix when the URL bar value isn't already "URL-like", // and only if we get a keyboard event, to match user expectations. - if (!/^\s*(www|https?)\b|\/\s*$/i.test(url) && + if (/^\s*[^.:\/\s]+(?:\/.*|\s*)$/i.test(url) && (aTriggeringEvent instanceof KeyEvent)) { #ifdef XP_MACOSX let accel = aTriggeringEvent.metaKey; #else let accel = aTriggeringEvent.ctrlKey; #endif let shift = aTriggeringEvent.shiftKey; @@ -397,34 +397,25 @@ } if (suffix) { // trim leading/trailing spaces (bug 233205) url = url.trim(); // Tack www. and suffix on. If user has appended directories, insert // suffix before them (bug 279035). Be careful not to get two slashes. - // Also, don't add the suffix if it's in the original url (bug 233853). let firstSlash = url.indexOf("/"); - let existingSuffix = url.indexOf(suffix.substring(0, suffix.length - 1)); - - // * Logic for slash and existing suffix (example) - // No slash, no suffix: Add suffix (mozilla) - // No slash, yes suffix: Add slash (mozilla.com) - // Yes slash, no suffix: Insert suffix (mozilla/stuff) - // Yes slash, suffix before slash: Do nothing (mozilla.com/stuff) - // Yes slash, suffix after slash: Insert suffix (mozilla/?stuff=.com) if (firstSlash >= 0) { - if (existingSuffix == -1 || existingSuffix > firstSlash) - url = url.substring(0, firstSlash) + suffix + - url.substring(firstSlash + 1); - } else - url = url + (existingSuffix == -1 ? suffix : "/"); + url = url.substring(0, firstSlash) + suffix + + url.substring(firstSlash + 1); + } else { + url = url + suffix; + } url = "http://www." + url; } } var postData = {}; var mayInheritPrincipal = { value: false }; url = getShortcutOrURI(url, postData, mayInheritPrincipal);