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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const TEST_VALUE = "example.com/\xF7?\xF7"; |
michael@0 | 5 | const START_VALUE = "example.com/%C3%B7?%C3%B7"; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | runNextTest(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | function locationBarEnter(aEvent, aClosure) { |
michael@0 | 13 | executeSoon(function() { |
michael@0 | 14 | gURLBar.focus(); |
michael@0 | 15 | EventUtils.synthesizeKey("VK_RETURN", aEvent); |
michael@0 | 16 | addPageShowListener(aClosure); |
michael@0 | 17 | }); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | function runNextTest() { |
michael@0 | 21 | let test = gTests.shift(); |
michael@0 | 22 | if (!test) { |
michael@0 | 23 | finish(); |
michael@0 | 24 | return; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | info("Running test: " + test.desc); |
michael@0 | 28 | let tab = gBrowser.selectedTab = gBrowser.addTab(START_VALUE); |
michael@0 | 29 | addPageShowListener(function() { |
michael@0 | 30 | locationBarEnter(test.event, function() { |
michael@0 | 31 | test.check(tab); |
michael@0 | 32 | |
michael@0 | 33 | // Clean up |
michael@0 | 34 | while (gBrowser.tabs.length > 1) |
michael@0 | 35 | gBrowser.removeTab(gBrowser.selectedTab) |
michael@0 | 36 | runNextTest(); |
michael@0 | 37 | }); |
michael@0 | 38 | }); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | let gTests = [ |
michael@0 | 42 | { desc: "Simple return keypress", |
michael@0 | 43 | event: {}, |
michael@0 | 44 | check: checkCurrent |
michael@0 | 45 | }, |
michael@0 | 46 | |
michael@0 | 47 | { desc: "Alt+Return keypress", |
michael@0 | 48 | event: { altKey: true }, |
michael@0 | 49 | check: checkNewTab, |
michael@0 | 50 | }, |
michael@0 | 51 | ] |
michael@0 | 52 | |
michael@0 | 53 | function checkCurrent(aTab) { |
michael@0 | 54 | is(gURLBar.value, TEST_VALUE, "Urlbar should preserve the value on return keypress"); |
michael@0 | 55 | is(gBrowser.selectedTab, aTab, "New URL was loaded in the current tab"); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function checkNewTab(aTab) { |
michael@0 | 59 | is(gURLBar.value, TEST_VALUE, "Urlbar should preserve the value on return keypress"); |
michael@0 | 60 | isnot(gBrowser.selectedTab, aTab, "New URL was loaded in a new tab"); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function addPageShowListener(aFunc) { |
michael@0 | 64 | gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() { |
michael@0 | 65 | gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false); |
michael@0 | 66 | aFunc(); |
michael@0 | 67 | }); |
michael@0 | 68 | } |
michael@0 | 69 |