mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 461304 - Test; r=gavin
This commit is contained in:
parent
4ac41f5d14
commit
3b990fb208
@ -206,6 +206,7 @@ _BROWSER_FILES = \
|
||||
browser_tabs_isActive.js \
|
||||
browser_tabs_owner.js \
|
||||
browser_urlbarCopying.js \
|
||||
browser_urlbarEnter.js \
|
||||
browser_urlbarTrimURLs.js \
|
||||
browser_urlHighlight.js \
|
||||
browser_visibleFindSelection.js \
|
||||
|
69
browser/base/content/test/browser_urlbarEnter.js
Normal file
69
browser/base/content/test/browser_urlbarEnter.js
Normal file
@ -0,0 +1,69 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
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);
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let gTests = [
|
||||
{ desc: "Simple return keypress",
|
||||
event: {},
|
||||
check: checkCurrent
|
||||
},
|
||||
|
||||
{ desc: "Alt+Return keypress",
|
||||
event: { altKey: true },
|
||||
check: checkNewTab,
|
||||
},
|
||||
]
|
||||
|
||||
function checkCurrent(aTab) {
|
||||
is(gURLBar.value, TEST_VALUE, "Urlbar should preserve the value on return keypress");
|
||||
is(gBrowser.selectedTab, aTab, "New URL was loaded in the current tab");
|
||||
}
|
||||
|
||||
function checkNewTab(aTab) {
|
||||
is(gURLBar.value, 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();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user