Port more reliable branch test from bug 304198 to trunk to fix intermittent oranges, a=beltzner/shaver

This commit is contained in:
Gavin Sharp 2009-05-28 18:43:58 -04:00
parent 371ff5a1bd
commit 20d1c5bca1

View File

@ -38,16 +38,14 @@
function test() {
waitForExplicitFinish();
let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
let deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
charsToDelete = 5;
deletedURLTab = gBrowser.addTab();
fullURLTab = gBrowser.addTab();
partialURLTab = gBrowser.addTab();
testPartialURL = "http://example.org/brow";
testURL = "http://example.org/browser/browser/base/content/test/dummy_page.html";
testPartialURL = testURL.substr(0, (testURL.length - charsToDelete));
function cleanUp() {
gBrowser.removeTab(fullURLTab);
@ -55,7 +53,36 @@ function test() {
gBrowser.removeTab(deletedURLTab);
}
function cycleTabs() {
// function borrowed from browser_bug386835.js
function load(tab, url, cb) {
tab.linkedBrowser.addEventListener("load", function (event) {
event.currentTarget.removeEventListener("load", arguments.callee, true);
cb();
}, true);
tab.linkedBrowser.loadURI(url);
}
function runTests() {
gBrowser.selectedTab = fullURLTab;
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
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
gBrowser.userTypedValue = testPartialURL;
URLBarSetURI();
is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL (just set)');
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
gBrowser.userTypedValue = '';
URLBarSetURI();
is(gURLBar.value, '', 'gURLBar.value should be "" (just set)');
// now cycle the tabs and make sure everything looks good
gBrowser.selectedTab = fullURLTab;
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
@ -69,60 +96,6 @@ function test() {
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
}
// function borrowed from browser_bug386835.js
function load(tab, url, cb) {
tab.linkedBrowser.addEventListener("load", function (event) {
event.currentTarget.removeEventListener("load", arguments.callee, true);
cb();
}, true);
tab.linkedBrowser.loadURI(url);
}
function prepareDeletedURLTab() {
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");
}
function prepareFullURLTab() {
gBrowser.selectedTab = fullURLTab;
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
}
function preparePartialURLTab() {
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");
}
function runTests() {
// prepare the three tabs required by this test
prepareFullURLTab();
preparePartialURLTab();
prepareDeletedURLTab();
// now cycle the tabs and make sure everything looks good
cycleTabs();
}
load(deletedURLTab, testURL, function() {
load(fullURLTab, testURL, function() {
load(partialURLTab, testURL, function() {