mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 04:35:33 +00:00
Bug 509295 - fix browser_bug304198.js focus issues
This commit is contained in:
parent
25ddc3dde3
commit
15ab0505b0
@ -38,6 +38,16 @@
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
if (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow !=
|
||||
window) {
|
||||
window.addEventListener("focus", function () {
|
||||
window.removeEventListener("focus", arguments.callee, false);
|
||||
test();
|
||||
}, false);
|
||||
window.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
|
||||
|
||||
charsToDelete = 5;
|
||||
@ -49,7 +59,6 @@ function test() {
|
||||
testPartialURL = testURL.substr(0, (testURL.length - charsToDelete));
|
||||
|
||||
function cleanUp() {
|
||||
|
||||
gBrowser.removeTab(fullURLTab);
|
||||
gBrowser.removeTab(partialURLTab);
|
||||
gBrowser.removeTab(deletedURLTab);
|
||||
@ -78,58 +87,78 @@ function test() {
|
||||
tab.linkedBrowser.loadURI(url);
|
||||
}
|
||||
|
||||
function prepareDeletedURLTab() {
|
||||
function urlbarBackspace(cb) {
|
||||
gBrowser.selectedBrowser.focus();
|
||||
gURLBar.addEventListener("focus", function () {
|
||||
gURLBar.removeEventListener("focus", arguments.callee, false);
|
||||
gURLBar.addEventListener("input", function () {
|
||||
gURLBar.removeEventListener("input", arguments.callee, false);
|
||||
cb();
|
||||
}, false);
|
||||
executeSoon(function () {
|
||||
EventUtils.synthesizeKey("VK_BACK_SPACE", {});
|
||||
});
|
||||
}, false);
|
||||
gURLBar.focus();
|
||||
}
|
||||
|
||||
function prepareDeletedURLTab(cb) {
|
||||
gBrowser.selectedTab = deletedURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to deletedURLTab');
|
||||
|
||||
// simulate the user removing the whole url from the location bar
|
||||
gPrefService.setBoolPref("browser.urlbar.clickSelectsAll", true);
|
||||
gURLBar.focus();
|
||||
|
||||
EventUtils.synthesizeKey("VK_BACK_SPACE", {});
|
||||
|
||||
is(gURLBar.value, '', 'gURLBar.value should be "" (just set)');
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
urlbarBackspace(function () {
|
||||
is(gURLBar.value, "", 'gURLBar.value should be "" (just set)');
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function prepareFullURLTab() {
|
||||
function prepareFullURLTab(cb) {
|
||||
gBrowser.selectedTab = fullURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
|
||||
cb();
|
||||
}
|
||||
|
||||
function preparePartialURLTab() {
|
||||
function preparePartialURLTab(cb) {
|
||||
gBrowser.selectedTab = partialURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to partialURLTab');
|
||||
|
||||
// simulate the user removing part of the url from the location bar
|
||||
gPrefService.setBoolPref("browser.urlbar.clickSelectsAll", false);
|
||||
gURLBar.focus();
|
||||
|
||||
for(let i = 0; i < charsToDelete; ++i) {
|
||||
EventUtils.synthesizeKey("VK_BACK_SPACE", {});
|
||||
}
|
||||
|
||||
is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL (just set)');
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
var deleted = 0;
|
||||
urlbarBackspace(function () {
|
||||
deleted++;
|
||||
if (deleted < charsToDelete) {
|
||||
urlbarBackspace(arguments.callee);
|
||||
} else {
|
||||
is(gURLBar.value, testPartialURL, "gURLBar.value should be testPartialURL (just set)");
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
cb();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
// prepare the three tabs required by this test
|
||||
prepareFullURLTab();
|
||||
preparePartialURLTab();
|
||||
prepareDeletedURLTab();
|
||||
|
||||
// now cycle the tabs and make sure everything looks good
|
||||
cycleTabs();
|
||||
prepareFullURLTab(function () {
|
||||
preparePartialURLTab(function () {
|
||||
prepareDeletedURLTab(function () {
|
||||
// now cycle the tabs and make sure everything looks good
|
||||
cycleTabs();
|
||||
cleanUp();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
load(deletedURLTab, testURL, function() {
|
||||
load(fullURLTab, testURL, function() {
|
||||
load(partialURLTab, testURL, function() {
|
||||
runTests();
|
||||
cleanUp();
|
||||
finish();
|
||||
});
|
||||
load(partialURLTab, testURL, runTests);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user