mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 1100291 - Fix browser/base/content/test/general/browser_urlbarEnter.js to work with an async getShortcutOrURIAndPostData() r=dao
This commit is contained in:
parent
d04ed886cd
commit
25f7753fcc
@ -1,69 +1,40 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_VALUE = "example.com/\xF7?\xF7";
|
||||
const START_VALUE = "example.com/%C3%B7?%C3%B7";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
function locationBarEnter(aEvent, aClosure) {
|
||||
executeSoon(function() {
|
||||
gURLBar.focus();
|
||||
EventUtils.synthesizeKey("VK_RETURN", aEvent);
|
||||
addPageShowListener(aClosure);
|
||||
});
|
||||
}
|
||||
|
||||
function runNextTest() {
|
||||
let test = gTests.shift();
|
||||
if (!test) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
info("Running test: " + test.desc);
|
||||
add_task(function* () {
|
||||
info("Simple return keypress");
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(START_VALUE);
|
||||
addPageShowListener(function() {
|
||||
locationBarEnter(test.event, function() {
|
||||
test.check(tab);
|
||||
|
||||
// Clean up
|
||||
while (gBrowser.tabs.length > 1)
|
||||
gBrowser.removeTab(gBrowser.selectedTab)
|
||||
runNextTest();
|
||||
});
|
||||
});
|
||||
}
|
||||
gURLBar.focus();
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let gTests = [
|
||||
{ desc: "Simple return keypress",
|
||||
event: {},
|
||||
check: checkCurrent
|
||||
},
|
||||
|
||||
{ desc: "Alt+Return keypress",
|
||||
event: { altKey: true },
|
||||
check: checkNewTab,
|
||||
},
|
||||
]
|
||||
|
||||
function checkCurrent(aTab) {
|
||||
// Check url bar and selected tab.
|
||||
is(gURLBar.textValue, TEST_VALUE, "Urlbar should preserve the value on return keypress");
|
||||
is(gBrowser.selectedTab, aTab, "New URL was loaded in the current tab");
|
||||
}
|
||||
is(gBrowser.selectedTab, tab, "New URL was loaded in the current tab");
|
||||
|
||||
function checkNewTab(aTab) {
|
||||
// Cleanup.
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
info("Alt+Return keypress");
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(START_VALUE);
|
||||
|
||||
gURLBar.focus();
|
||||
EventUtils.synthesizeKey("VK_RETURN", {altKey: true});
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
// Check url bar and selected tab.
|
||||
is(gURLBar.textValue, TEST_VALUE, "Urlbar should preserve the value on return keypress");
|
||||
isnot(gBrowser.selectedTab, aTab, "New URL was loaded in a new tab");
|
||||
}
|
||||
|
||||
function addPageShowListener(aFunc) {
|
||||
gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
|
||||
gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
|
||||
aFunc();
|
||||
});
|
||||
}
|
||||
isnot(gBrowser.selectedTab, tab, "New URL was loaded in a new tab");
|
||||
|
||||
// Cleanup.
|
||||
gBrowser.removeTab(tab);
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user