Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | function test() { |
michael@0 | 2 | waitForExplicitFinish(); |
michael@0 | 3 | testNext(); |
michael@0 | 4 | } |
michael@0 | 5 | |
michael@0 | 6 | var pairs = [ |
michael@0 | 7 | ["example", "http://www.example.net/"], |
michael@0 | 8 | ["ex-ample", "http://www.ex-ample.net/"], |
michael@0 | 9 | [" example ", "http://www.example.net/"], |
michael@0 | 10 | [" example/foo ", "http://www.example.net/foo"], |
michael@0 | 11 | [" example/foo bar ", "http://www.example.net/foo%20bar"], |
michael@0 | 12 | ["example.net", "http://example.net/"], |
michael@0 | 13 | ["http://example", "http://example/"], |
michael@0 | 14 | ["example:8080", "http://example:8080/"], |
michael@0 | 15 | ["ex-ample.foo", "http://ex-ample.foo/"], |
michael@0 | 16 | ["example.foo/bar ", "http://example.foo/bar"], |
michael@0 | 17 | ["1.1.1.1", "http://1.1.1.1/"], |
michael@0 | 18 | ["ftp://example", "ftp://example/"], |
michael@0 | 19 | ["ftp.example.bar", "ftp://ftp.example.bar/"], |
michael@0 | 20 | ["ex ample", Services.search.defaultEngine.getSubmission("ex ample", null, "keyword").uri.spec], |
michael@0 | 21 | ]; |
michael@0 | 22 | |
michael@0 | 23 | function testNext() { |
michael@0 | 24 | if (!pairs.length) { |
michael@0 | 25 | finish(); |
michael@0 | 26 | return; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | let [inputValue, expectedURL] = pairs.shift(); |
michael@0 | 30 | |
michael@0 | 31 | gBrowser.addProgressListener({ |
michael@0 | 32 | onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { |
michael@0 | 33 | if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && |
michael@0 | 34 | aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { |
michael@0 | 35 | is(aRequest.originalURI.spec, expectedURL, |
michael@0 | 36 | "entering '" + inputValue + "' loads expected URL"); |
michael@0 | 37 | |
michael@0 | 38 | gBrowser.removeProgressListener(this); |
michael@0 | 39 | gBrowser.stop(); |
michael@0 | 40 | |
michael@0 | 41 | executeSoon(testNext); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | }); |
michael@0 | 45 | |
michael@0 | 46 | gURLBar.addEventListener("focus", function onFocus() { |
michael@0 | 47 | gURLBar.removeEventListener("focus", onFocus); |
michael@0 | 48 | EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); |
michael@0 | 49 | }); |
michael@0 | 50 | |
michael@0 | 51 | gBrowser.selectedBrowser.focus(); |
michael@0 | 52 | gURLBar.inputField.value = inputValue; |
michael@0 | 53 | gURLBar.focus(); |
michael@0 | 54 | } |