1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_canonizeURL.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +function test() { 1.5 + waitForExplicitFinish(); 1.6 + testNext(); 1.7 +} 1.8 + 1.9 +var pairs = [ 1.10 + ["example", "http://www.example.net/"], 1.11 + ["ex-ample", "http://www.ex-ample.net/"], 1.12 + [" example ", "http://www.example.net/"], 1.13 + [" example/foo ", "http://www.example.net/foo"], 1.14 + [" example/foo bar ", "http://www.example.net/foo%20bar"], 1.15 + ["example.net", "http://example.net/"], 1.16 + ["http://example", "http://example/"], 1.17 + ["example:8080", "http://example:8080/"], 1.18 + ["ex-ample.foo", "http://ex-ample.foo/"], 1.19 + ["example.foo/bar ", "http://example.foo/bar"], 1.20 + ["1.1.1.1", "http://1.1.1.1/"], 1.21 + ["ftp://example", "ftp://example/"], 1.22 + ["ftp.example.bar", "ftp://ftp.example.bar/"], 1.23 + ["ex ample", Services.search.defaultEngine.getSubmission("ex ample", null, "keyword").uri.spec], 1.24 +]; 1.25 + 1.26 +function testNext() { 1.27 + if (!pairs.length) { 1.28 + finish(); 1.29 + return; 1.30 + } 1.31 + 1.32 + let [inputValue, expectedURL] = pairs.shift(); 1.33 + 1.34 + gBrowser.addProgressListener({ 1.35 + onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { 1.36 + if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && 1.37 + aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { 1.38 + is(aRequest.originalURI.spec, expectedURL, 1.39 + "entering '" + inputValue + "' loads expected URL"); 1.40 + 1.41 + gBrowser.removeProgressListener(this); 1.42 + gBrowser.stop(); 1.43 + 1.44 + executeSoon(testNext); 1.45 + } 1.46 + } 1.47 + }); 1.48 + 1.49 + gURLBar.addEventListener("focus", function onFocus() { 1.50 + gURLBar.removeEventListener("focus", onFocus); 1.51 + EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); 1.52 + }); 1.53 + 1.54 + gBrowser.selectedBrowser.focus(); 1.55 + gURLBar.inputField.value = inputValue; 1.56 + gURLBar.focus(); 1.57 +}