41 let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL,
testURL;
44 deletedURLTab = gBrowser.addTab();
45 fullURLTab = gBrowser.addTab();
46 partialURLTab = gBrowser.addTab();
47 testURL =
"http://example.org/browser/browser/base/content/test/dummy_page.html";
49 testPartialURL = testURL.substr(0, (testURL.length - charsToDelete));
52 gBrowser.removeTab(fullURLTab);
53 gBrowser.removeTab(partialURLTab);
54 gBrowser.removeTab(deletedURLTab);
57 function cycleTabs() {
58 gBrowser.selectedTab = fullURLTab;
59 is(gURLBar.value, testURL,
'gURLBar.value should be testURL after switching back to fullURLTab');
61 gBrowser.selectedTab = partialURLTab;
62 is(gURLBar.value, testPartialURL,
'gURLBar.value should be testPartialURL after switching back to partialURLTab');
64 gBrowser.selectedTab = deletedURLTab;
65 is(gURLBar.value,
'',
'gURLBar.value should be "" after switching back to deletedURLTab');
67 gBrowser.selectedTab = fullURLTab;
68 is(gURLBar.value, testURL,
'gURLBar.value should be testURL after switching back to fullURLTab');
73 tab.linkedBrowser.addEventListener(
"load",
function (
event) {
74 event.currentTarget.removeEventListener(
"load",
arguments.callee,
true);
77 tab.linkedBrowser.loadURI(
url);
80 function urlbarBackspace(cb) {
81 gBrowser.selectedBrowser.focus();
82 gURLBar.addEventListener(
"focus",
function () {
83 gURLBar.removeEventListener(
"focus",
arguments.callee,
false);
84 gURLBar.addEventListener(
"input",
function () {
85 gURLBar.removeEventListener(
"input",
arguments.callee,
false);
88 executeSoon(
function () {
89 EventUtils.synthesizeKey(
"VK_BACK_SPACE", {});
95 function prepareDeletedURLTab(cb) {
96 gBrowser.selectedTab = deletedURLTab;
97 is(gURLBar.value, testURL,
'gURLBar.value should be testURL after initial switch to deletedURLTab');
100 gPrefService.setBoolPref(
"browser.urlbar.clickSelectsAll",
true);
102 urlbarBackspace(
function () {
103 is(gURLBar.value,
"",
'gURLBar.value should be "" (just set)');
104 if (
gPrefService.prefHasUserValue(
"browser.urlbar.clickSelectsAll"))
105 gPrefService.clearUserPref(
"browser.urlbar.clickSelectsAll");
110 function prepareFullURLTab(cb) {
111 gBrowser.selectedTab = fullURLTab;
112 is(gURLBar.value, testURL,
'gURLBar.value should be testURL after initial switch to fullURLTab');
116 function preparePartialURLTab(cb) {
117 gBrowser.selectedTab = partialURLTab;
118 is(gURLBar.value, testURL,
'gURLBar.value should be testURL after initial switch to partialURLTab');
121 gPrefService.setBoolPref(
"browser.urlbar.clickSelectsAll",
false);
124 urlbarBackspace(
function () {
126 if (deleted < charsToDelete) {
129 is(gURLBar.value, testPartialURL,
"gURLBar.value should be testPartialURL (just set)");
130 if (
gPrefService.prefHasUserValue(
"browser.urlbar.clickSelectsAll"))
131 gPrefService.clearUserPref(
"browser.urlbar.clickSelectsAll");
137 function runTests() {
139 prepareFullURLTab(
function () {
140 preparePartialURLTab(
function () {
141 prepareDeletedURLTab(
function () {
151 load(deletedURLTab, testURL,
function() {
152 load(fullURLTab, testURL,
function() {
153 load(partialURLTab, testURL, runTests);
return!aWindow arguments!aWindow arguments[0]