зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1067903 - Part 3: Update tests to deal with autoselect and textValue. r=mak
--HG-- extra : transplant_source : %27%23%DC/%3E%866%CB%AC%FD%87%8C%16hP%28%B8%04%F4O
This commit is contained in:
Родитель
33080ce19a
Коммит
6a76308101
|
@ -122,6 +122,8 @@ skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test un
|
|||
[browser_alltabslistener.js]
|
||||
[browser_autocomplete_a11y_label.js]
|
||||
skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir (works on its own)
|
||||
[browser_autocomplete_autoselect.js]
|
||||
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
|
||||
[browser_backButtonFitts.js]
|
||||
skip-if = os != "win" || e10s # The Fitts Law back button is only supported on Windows (bug 571454) / e10s - Bug 1099154: test touches content (attempts to add an event listener directly to the contentWindow)
|
||||
[browser_blob-channelname.js]
|
||||
|
@ -289,7 +291,7 @@ skip-if = e10s # Bug 1093155 - tries to use context menu from browser-chrome and
|
|||
skip-if = os == 'win' || e10s # Bug 1056146 - zoom tests use FullZoomHelper and break in e10s
|
||||
[browser_bug1064280_changeUrlInPinnedTab.js]
|
||||
[browser_bug1070778.js]
|
||||
skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux
|
||||
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
|
||||
[browser_canonizeURL.js]
|
||||
skip-if = e10s # Bug 1094510 - test hits the network in e10s mode only
|
||||
[browser_contentAreaClick.js]
|
||||
|
|
|
@ -31,7 +31,7 @@ let tests = [
|
|||
function revert(next) {
|
||||
loadTabInWindow(window, function (tab) {
|
||||
gURLBar.handleRevert();
|
||||
is(gURLBar.value, "example.com", "URL bar had user/pass stripped after reverting");
|
||||
is(gURLBar.textValue, "example.com", "URL bar had user/pass stripped after reverting");
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ let tests = [
|
|||
loadTabInWindow(win, function () {
|
||||
openToolbarCustomizationUI(function () {
|
||||
closeToolbarCustomizationUI(function () {
|
||||
is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped after customize");
|
||||
is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped after customize");
|
||||
win.close();
|
||||
next();
|
||||
}, win);
|
||||
|
@ -59,7 +59,7 @@ let tests = [
|
|||
// error.
|
||||
tab.linkedBrowser.loadURI("http://test1.example.com");
|
||||
tab.linkedBrowser.stop();
|
||||
is(gURLBar.value, "example.com", "URL bar had user/pass stripped after load error");
|
||||
is(gURLBar.textValue, "example.com", "URL bar had user/pass stripped after load error");
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
});
|
||||
|
@ -76,7 +76,7 @@ function loadTabInWindow(win, callback) {
|
|||
return;
|
||||
tab.linkedBrowser.removeEventListener("load", listener, true);
|
||||
|
||||
is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped initially");
|
||||
is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped initially");
|
||||
callback(tab);
|
||||
}, true);
|
||||
}
|
||||
|
|
|
@ -43,11 +43,14 @@ add_task(function* () {
|
|||
|
||||
let result = yield promise_first_result("open a search");
|
||||
isnot(result, null, "Should have a result");
|
||||
is(result.getAttribute("url"),
|
||||
`moz-action:searchengine,{"engineName":"MozSearch","input":"open a search","searchQuery":"open a search"}`,
|
||||
"Result should be a moz-action: for the correct search engine");
|
||||
is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
|
||||
|
||||
let tabPromise = promiseTabLoaded(gBrowser.selectedTab);
|
||||
EventUtils.synthesizeMouseAtCenter(result, {});
|
||||
yield tabPromise;
|
||||
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search");
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search", "Correct URL should be loaded");
|
||||
});
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
function repeat(limit, func) {
|
||||
for (let i = 0; i < limit; i++) {
|
||||
func(i);
|
||||
}
|
||||
}
|
||||
|
||||
function* promiseAutoComplete(inputText) {
|
||||
gURLBar.focus();
|
||||
gURLBar.value = inputText.slice(0, -1);
|
||||
EventUtils.synthesizeKey(inputText.slice(-1), {});
|
||||
yield promiseSearchComplete();
|
||||
}
|
||||
|
||||
function is_selected(index) {
|
||||
is(gURLBar.popup.richlistbox.selectedIndex, index, `Item ${index + 1} should be selected`);
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
registerCleanupFunction(promiseClearHistory);
|
||||
|
||||
let visits = [];
|
||||
repeat(10, i => {
|
||||
visits.push({
|
||||
uri: makeURI("http://example.com/autocomplete/?" + i),
|
||||
});
|
||||
});
|
||||
yield PlacesTestUtils.addVisits(visits);
|
||||
|
||||
yield promiseAutoComplete("example.com/autocomplete");
|
||||
|
||||
let popup = gURLBar.popup;
|
||||
let results = popup.richlistbox.children;
|
||||
// 1 extra for the current search engine match
|
||||
is(results.length, 11, "Should get 11 results");
|
||||
is_selected(0);
|
||||
|
||||
info("Key Down to select the next item");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
is_selected(1);
|
||||
|
||||
info("Key Down 11 times should wrap around all the way around");
|
||||
repeat(11, () => EventUtils.synthesizeKey("VK_DOWN", {}));
|
||||
is_selected(1);
|
||||
|
||||
info("Key Up 11 times should wrap around the other way");
|
||||
repeat(11, () => EventUtils.synthesizeKey("VK_UP", {}));
|
||||
is_selected(1);
|
||||
|
||||
info("Page Up will go up the list, but not wrap");
|
||||
EventUtils.synthesizeKey("VK_PAGE_UP", {})
|
||||
is_selected(0);
|
||||
|
||||
info("Page Up again will wrap around to the end of the list");
|
||||
EventUtils.synthesizeKey("VK_PAGE_UP", {})
|
||||
is_selected(10);
|
||||
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
yield promisePopupHidden(gURLBar.popup);
|
||||
});
|
|
@ -35,7 +35,7 @@ add_task(function* test_switchtab_override() {
|
|||
onSearchComplete.apply(gURLBar);
|
||||
deferred.resolve();
|
||||
}
|
||||
|
||||
|
||||
gURLBar.focus();
|
||||
gURLBar.value = "dummy_pag";
|
||||
EventUtils.synthesizeKey("e" , {});
|
||||
|
@ -43,7 +43,6 @@ add_task(function* test_switchtab_override() {
|
|||
|
||||
info("Select second autocomplete popup entry");
|
||||
EventUtils.synthesizeKey("VK_DOWN" , {});
|
||||
EventUtils.synthesizeKey("VK_DOWN" , {});
|
||||
ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found");
|
||||
|
||||
info("Override switch-to-tab");
|
||||
|
@ -61,6 +60,7 @@ add_task(function* test_switchtab_override() {
|
|||
|
||||
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" });
|
||||
EventUtils.synthesizeKey("VK_RETURN" , { });
|
||||
info(`gURLBar.value = ${gURLBar.value}`);
|
||||
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" });
|
||||
yield deferred.promise;
|
||||
|
||||
|
|
|
@ -21,26 +21,13 @@ add_task(function* test_switchtab_override_keynav() {
|
|||
return promiseClearHistory();
|
||||
});
|
||||
|
||||
info("Wait for autocomplete")
|
||||
let searchDeferred = Promise.defer();
|
||||
let onSearchComplete = gURLBar.onSearchComplete;
|
||||
registerCleanupFunction(() => {
|
||||
gURLBar.onSearchComplete = onSearchComplete;
|
||||
});
|
||||
gURLBar.onSearchComplete = function () {
|
||||
ok(gURLBar.popupOpen, "The autocomplete popup is correctly open");
|
||||
onSearchComplete.apply(gURLBar);
|
||||
searchDeferred.resolve();
|
||||
}
|
||||
|
||||
gURLBar.focus();
|
||||
gURLBar.value = "dummy_pag";
|
||||
EventUtils.synthesizeKey("e" , {});
|
||||
yield searchDeferred.promise;
|
||||
yield promiseSearchComplete();
|
||||
|
||||
info("Select second autocomplete popup entry");
|
||||
EventUtils.synthesizeKey("VK_DOWN" , {});
|
||||
EventUtils.synthesizeKey("VK_DOWN" , {});
|
||||
ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found");
|
||||
|
||||
info("Shift+left on switch-to-tab entry");
|
||||
|
|
|
@ -17,9 +17,8 @@ add_task(function*() {
|
|||
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete"))
|
||||
return;
|
||||
|
||||
let itemIds = [];
|
||||
registerCleanupFunction(() => {
|
||||
itemIds.forEach(PlacesUtils.bookmarks.removeItem);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
|
||||
});
|
||||
|
||||
let itemId =
|
||||
|
@ -28,7 +27,6 @@ add_task(function*() {
|
|||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"test");
|
||||
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
|
||||
itemIds.push(itemId);
|
||||
|
||||
// This item only needed so we can select the keyword item, select something
|
||||
// else, then select the keyword item again.
|
||||
|
@ -37,12 +35,10 @@ add_task(function*() {
|
|||
NetUtil.newURI("http://example.com/keyword"),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"keyword abc");
|
||||
itemIds.push(itemId);
|
||||
|
||||
yield promiseAutoComplete("keyword a");
|
||||
|
||||
// Select keyword item
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
// First item should already be selected
|
||||
is_selected(0);
|
||||
// Select next one (important!)
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
|
|
|
@ -21,16 +21,15 @@ function test() {
|
|||
|
||||
function cycleTabs() {
|
||||
gBrowser.selectedTab = fullURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
|
||||
is(gURLBar.textValue, testURL, 'gURLBar.textValue should be testURL after switching back to fullURLTab');
|
||||
|
||||
gBrowser.selectedTab = partialURLTab;
|
||||
is(gURLBar.value, testPartialURL, 'gURLBar.value should be testPartialURL after switching back to partialURLTab');
|
||||
|
||||
is(gURLBar.textValue, testPartialURL, 'gURLBar.textValue should be testPartialURL after switching back to partialURLTab');
|
||||
gBrowser.selectedTab = deletedURLTab;
|
||||
is(gURLBar.value, '', 'gURLBar.value should be "" after switching back to deletedURLTab');
|
||||
is(gURLBar.textValue, '', 'gURLBar.textValue should be "" after switching back to deletedURLTab');
|
||||
|
||||
gBrowser.selectedTab = fullURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after switching back to fullURLTab');
|
||||
is(gURLBar.textValue, testURL, 'gURLBar.textValue should be testURL after switching back to fullURLTab');
|
||||
}
|
||||
|
||||
// function borrowed from browser_bug386835.js
|
||||
|
@ -59,13 +58,13 @@ function test() {
|
|||
|
||||
function prepareDeletedURLTab(cb) {
|
||||
gBrowser.selectedTab = deletedURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to deletedURLTab');
|
||||
is(gURLBar.textValue, testURL, 'gURLBar.textValue 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);
|
||||
|
||||
urlbarBackspace(function () {
|
||||
is(gURLBar.value, "", 'gURLBar.value should be "" (just set)');
|
||||
is(gURLBar.textValue, "", 'gURLBar.textValue should be "" (just set)');
|
||||
if (gPrefService.prefHasUserValue("browser.urlbar.clickSelectsAll"))
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
cb();
|
||||
|
@ -74,13 +73,13 @@ function test() {
|
|||
|
||||
function prepareFullURLTab(cb) {
|
||||
gBrowser.selectedTab = fullURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to fullURLTab');
|
||||
is(gURLBar.textValue, testURL, 'gURLBar.textValue should be testURL after initial switch to fullURLTab');
|
||||
cb();
|
||||
}
|
||||
|
||||
function preparePartialURLTab(cb) {
|
||||
gBrowser.selectedTab = partialURLTab;
|
||||
is(gURLBar.value, testURL, 'gURLBar.value should be testURL after initial switch to partialURLTab');
|
||||
is(gURLBar.textValue, testURL, 'gURLBar.textValue 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);
|
||||
|
@ -91,7 +90,7 @@ function test() {
|
|||
if (deleted < charsToDelete) {
|
||||
urlbarBackspace(arguments.callee);
|
||||
} else {
|
||||
is(gURLBar.value, testPartialURL, "gURLBar.value should be testPartialURL (just set)");
|
||||
is(gURLBar.textValue, testPartialURL, "gURLBar.textValue should be testPartialURL (just set)");
|
||||
if (gPrefService.prefHasUserValue("browser.urlbar.clickSelectsAll"))
|
||||
gPrefService.clearUserPref("browser.urlbar.clickSelectsAll");
|
||||
cb();
|
||||
|
|
|
@ -31,8 +31,8 @@ let tests = [
|
|||
setup: function() {
|
||||
gURLBar.value = testActionURL;
|
||||
gURLBar.valueIsTyped = true;
|
||||
is(gURLBar._value, testActionURL, "gURLBar starts with the correct real value");
|
||||
is(gURLBar.value, testURL, "gURLBar starts with the correct display value");
|
||||
is(gURLBar.value, testActionURL, "gURLBar starts with the correct real value");
|
||||
is(gURLBar.textValue, testURL, "gURLBar starts with the correct display value");
|
||||
|
||||
// Focus the urlbar so we can select it all & copy
|
||||
gURLBar.focus();
|
||||
|
@ -40,7 +40,7 @@ let tests = [
|
|||
goDoCommand("cmd_copy");
|
||||
},
|
||||
success: function() {
|
||||
is(gURLBar._value, testActionURL, "gURLBar.value didn't change when copying");
|
||||
is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying");
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ let tests = [
|
|||
goDoCommand("cmd_copy");
|
||||
},
|
||||
success: function() {
|
||||
is(gURLBar._value, testActionURL, "gURLBar.value didn't change when copying");
|
||||
is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying");
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -74,8 +74,8 @@ let tests = [
|
|||
gURLBar.value = testActionURL;
|
||||
gURLBar.valueIsTyped = true;
|
||||
// Sanity check that we have the right value
|
||||
is(gURLBar._value, testActionURL, "gURLBar starts with the correct real value");
|
||||
is(gURLBar.value, testURL, "gURLBar starts with the correct display value");
|
||||
is(gURLBar.value, testActionURL, "gURLBar starts with the correct real value");
|
||||
is(gURLBar.textValue, testURL, "gURLBar starts with the correct display value");
|
||||
|
||||
// Now just select part of the value & cut that.
|
||||
gURLBar.selectionStart = testURL.length - 10;
|
||||
|
|
|
@ -45,10 +45,12 @@ function testNext() {
|
|||
|
||||
gURLBar.addEventListener("focus", function onFocus() {
|
||||
gURLBar.removeEventListener("focus", onFocus);
|
||||
gURLBar.inputField.value = inputValue.slice(0, -1);
|
||||
EventUtils.synthesizeKey(inputValue.slice(-1) , {});
|
||||
EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true });
|
||||
});
|
||||
|
||||
gBrowser.selectedBrowser.focus();
|
||||
gURLBar.inputField.value = inputValue;
|
||||
gURLBar.focus();
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ function runShiftLeftClickTest() {
|
|||
addPageShowListener(aWindow.gBrowser.selectedBrowser, function() {
|
||||
executeSoon(function () {
|
||||
info("URL should be loaded in a new window");
|
||||
is(gURLBar.value, "", "Urlbar reverted to original value");
|
||||
is(gURLBar.value, "", "Urlbar reverted to original value");
|
||||
is(gFocusManager.focusedElement, null, "There should be no focused element");
|
||||
is(gFocusManager.focusedWindow, aWindow.gBrowser.contentWindow, "Content window should be focused");
|
||||
is(aWindow.gURLBar.value, TEST_VALUE, "New URL is loaded in new window");
|
||||
is(aWindow.gURLBar.textValue, TEST_VALUE, "New URL is loaded in new window");
|
||||
|
||||
aWindow.close();
|
||||
|
||||
|
@ -61,7 +61,7 @@ function runNextTest() {
|
|||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
info("Running test: " + test.desc);
|
||||
// Tab will be blank if test.startValue is null
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(test.startValue);
|
||||
|
@ -106,7 +106,7 @@ let gTests = [
|
|||
is(gURLBar.value, "", "Urlbar reverted to original value");
|
||||
ok(!gURLBar.focused, "Urlbar is no longer focused after urlbar command");
|
||||
is(gBrowser.selectedTab, aTab, "Focus did not change to the new tab");
|
||||
|
||||
|
||||
// Select the new background tab
|
||||
gBrowser.selectedTab = gBrowser.selectedTab.nextSibling;
|
||||
is(gURLBar.value, TEST_VALUE, "New URL is loaded in new tab");
|
||||
|
@ -143,7 +143,7 @@ function triggerCommand(aClick, aEvent) {
|
|||
if (aClick) {
|
||||
is(gURLBar.getAttribute("pageproxystate"), "invalid",
|
||||
"page proxy state must be invalid for go button to be visible");
|
||||
EventUtils.synthesizeMouseAtCenter(gGoButton, aEvent);
|
||||
EventUtils.synthesizeMouseAtCenter(gGoButton, aEvent);
|
||||
}
|
||||
else
|
||||
EventUtils.synthesizeKey("VK_RETURN", aEvent);
|
||||
|
|
|
@ -41,7 +41,7 @@ function testNext() {
|
|||
|
||||
gURLBar.focus();
|
||||
paste(inputValue, function() {
|
||||
is(gURLBar.value, expectedURL, "entering '" + inputValue + "' strips relevant bits.");
|
||||
is(gURLBar.textValue, expectedURL, "entering '" + inputValue + "' strips relevant bits.");
|
||||
|
||||
setTimeout(testNext, 0);
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ function test() {
|
|||
};
|
||||
let history = Cc["@mozilla.org/browser/history;1"]
|
||||
.getService(Ci.mozIAsyncHistory);
|
||||
history.updatePlaces({ uri: NetUtil.newURI("http://www.autofilltrimurl.com/")
|
||||
history.updatePlaces({ uri: NetUtil.newURI("http://www.autofilltrimurl.com/whatever")
|
||||
, visits: [ { transitionType: Ci.nsINavHistoryService.TRANSITION_TYPED
|
||||
, visitDate: Date.now() * 1000
|
||||
} ]
|
||||
|
@ -44,7 +44,8 @@ function continue_test() {
|
|||
|
||||
EventUtils.synthesizeKey(aTyped.substr(-1), {});
|
||||
waitForSearchComplete(function () {
|
||||
is(gURLBar.value, aExpected, "trim was applied correctly");
|
||||
info(`Got value: ${gURLBar.value}`);
|
||||
is(gURLBar.value, aExpected, "Autofilled value is as expected");
|
||||
aCallback();
|
||||
});
|
||||
}
|
||||
|
@ -53,9 +54,9 @@ function continue_test() {
|
|||
test_autoFill("http://au", "http://autofilltrimurl.com/", function () {
|
||||
test_autoFill("http://www.autofilltrimurl.com", "http://www.autofilltrimurl.com/", function () {
|
||||
// Now ensure selecting from the popup correctly trims.
|
||||
is(gURLBar.controller.matchCount, 1, "Found the expected number of matches");
|
||||
is(gURLBar.controller.matchCount, 2, "Found the expected number of matches");
|
||||
EventUtils.synthesizeKey("VK_DOWN", {});
|
||||
is(gURLBar.value, "www.autofilltrimurl.com", "trim was applied correctly");
|
||||
is(gURLBar.textValue, "www.autofilltrimurl.com/whatever", "trim was applied correctly");
|
||||
gURLBar.closePopup();
|
||||
waitForClearHistory(finish);
|
||||
});
|
||||
|
|
|
@ -156,7 +156,7 @@ function runTest(test, cb) {
|
|||
function doCheck() {
|
||||
if (test.setURL || test.loadURL) {
|
||||
gURLBar.valueIsTyped = !!test.setURL;
|
||||
is(gURLBar.value, test.expectedURL, "url bar value set");
|
||||
is(gURLBar.textValue, test.expectedURL, "url bar value set");
|
||||
}
|
||||
|
||||
testCopy(test.copyVal, test.copyExpected, cb);
|
||||
|
@ -180,7 +180,7 @@ function testCopy(copyVal, targetValue, cb) {
|
|||
let endBracket = copyVal.indexOf(">");
|
||||
if (startBracket == -1 || endBracket == -1 ||
|
||||
startBracket > endBracket ||
|
||||
copyVal.replace("<", "").replace(">", "") != gURLBar.value) {
|
||||
copyVal.replace("<", "").replace(">", "") != gURLBar.textValue) {
|
||||
ok(false, "invalid copyVal: " + copyVal);
|
||||
}
|
||||
gURLBar.selectionStart = startBracket;
|
||||
|
|
|
@ -51,12 +51,12 @@ let gTests = [
|
|||
]
|
||||
|
||||
function checkCurrent(aTab) {
|
||||
is(gURLBar.value, TEST_VALUE, "Urlbar should preserve the value on return keypress");
|
||||
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");
|
||||
}
|
||||
|
||||
function checkNewTab(aTab) {
|
||||
is(gURLBar.value, TEST_VALUE, "Urlbar should preserve the value on return keypress");
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -11,23 +11,23 @@ function test() {
|
|||
function onload() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
|
||||
|
||||
is(gURLBar.value, gURLBar.trimValue(goodURL), "location bar reflects loaded page");
|
||||
is(gURLBar.textValue, gURLBar.trimValue(goodURL), "location bar reflects loaded page");
|
||||
|
||||
typeAndSubmit(badURL);
|
||||
is(gURLBar.value, gURLBar.trimValue(badURL), "location bar reflects loading page");
|
||||
is(gURLBar.textValue, gURLBar.trimValue(badURL), "location bar reflects loading page");
|
||||
|
||||
gBrowser.contentWindow.stop();
|
||||
is(gURLBar.value, gURLBar.trimValue(goodURL), "location bar reflects loaded page after stop()");
|
||||
is(gURLBar.textValue, gURLBar.trimValue(goodURL), "location bar reflects loaded page after stop()");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab("about:blank");
|
||||
is(gURLBar.value, "", "location bar is empty");
|
||||
is(gURLBar.textValue, "", "location bar is empty");
|
||||
|
||||
typeAndSubmit(badURL);
|
||||
is(gURLBar.value, gURLBar.trimValue(badURL), "location bar reflects loading page");
|
||||
is(gURLBar.textValue, gURLBar.trimValue(badURL), "location bar reflects loading page");
|
||||
|
||||
gBrowser.contentWindow.stop();
|
||||
is(gURLBar.value, gURLBar.trimValue(badURL), "location bar reflects stopped page in an empty tab");
|
||||
is(gURLBar.textValue, gURLBar.trimValue(badURL), "location bar reflects stopped page in an empty tab");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
finish();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
function testVal(originalValue, targetValue) {
|
||||
gURLBar.value = originalValue;
|
||||
gURLBar.valueIsTyped = false;
|
||||
is(gURLBar.value, targetValue || originalValue, "url bar value set");
|
||||
is(gURLBar.textValue, targetValue || originalValue, "url bar value set");
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
@ -96,7 +96,7 @@ function test() {
|
|||
|
||||
function testCopy(originalValue, targetValue, cb) {
|
||||
waitForClipboard(targetValue, function () {
|
||||
is(gURLBar.value, originalValue, "url bar copy value set");
|
||||
is(gURLBar.textValue, originalValue, "url bar copy value set");
|
||||
|
||||
gURLBar.focus();
|
||||
gURLBar.select();
|
||||
|
|
|
@ -6,6 +6,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
|||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
|
||||
"resource://testing-common/PlacesTestUtils.jsm");
|
||||
|
||||
function closeAllNotifications () {
|
||||
let notificationBox = document.getElementById("global-notificationbox");
|
||||
|
|
|
@ -193,16 +193,16 @@ function test() {
|
|||
is(browser.userTypedValue, null, "userTypedValue is empty to start");
|
||||
is(browser.userTypedClear, 0, "userTypedClear is 0 to start");
|
||||
|
||||
gURLBar.value = "example.org";
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("input", true, false);
|
||||
gURLBar.dispatchEvent(event);
|
||||
let inputText = "example.org";
|
||||
gURLBar.focus();
|
||||
gURLBar.value = inputText.slice(0, -1);
|
||||
EventUtils.synthesizeKey(inputText.slice(-1) , {});
|
||||
|
||||
executeSoon(function () {
|
||||
is(browser.userTypedValue, "example.org",
|
||||
"userTypedValue was set when changing gURLBar.value");
|
||||
"userTypedValue was set when changing URLBar value");
|
||||
is(browser.userTypedClear, 0,
|
||||
"userTypedClear was not changed when changing gURLBar.value");
|
||||
"userTypedClear was not changed when changing URLBar value");
|
||||
|
||||
// Now make sure ss gets these values too
|
||||
let newState = JSON.parse(ss.getBrowserState());
|
||||
|
@ -235,7 +235,7 @@ function test() {
|
|||
"userTypedValue was null after loading a URI");
|
||||
is(browser.userTypedClear, 0,
|
||||
"userTypeClear reset to 0");
|
||||
is(gURLBar.value, gURLBar.trimValue("http://example.com/"),
|
||||
is(gURLBar.textValue, gURLBar.trimValue("http://example.com/"),
|
||||
"Address bar's value set after loading URI");
|
||||
runNextTest();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"PlacesTestUtils",
|
||||
];
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
|
||||
this.PlacesTestUtils = Object.freeze({
|
||||
/**
|
||||
* Asynchronously adds visits to a page.
|
||||
*
|
||||
* @param aPlaceInfo
|
||||
* Can be an nsIURI, in such a case a single LINK visit will be added.
|
||||
* Otherwise can be an object describing the visit to add, or an array
|
||||
* of these objects:
|
||||
* { uri: nsIURI of the page,
|
||||
* [optional] transition: one of the TRANSITION_* from nsINavHistoryService,
|
||||
* [optional] title: title of the page,
|
||||
* [optional] visitDate: visit date in microseconds from the epoch
|
||||
* [optional] referrer: nsIURI of the referrer for this visit
|
||||
* }
|
||||
*
|
||||
* @return {Promise}
|
||||
* @resolves When all visits have been added successfully.
|
||||
* @rejects JavaScript exception.
|
||||
*/
|
||||
addVisits(placeInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let places = [];
|
||||
if (placeInfo instanceof Ci.nsIURI) {
|
||||
places.push({ uri: placeInfo });
|
||||
}
|
||||
else if (Array.isArray(placeInfo)) {
|
||||
places = places.concat(placeInfo);
|
||||
} else {
|
||||
places.push(placeInfo)
|
||||
}
|
||||
|
||||
// Create mozIVisitInfo for each entry.
|
||||
let now = Date.now();
|
||||
for (let place of places) {
|
||||
if (typeof place.title != "string") {
|
||||
place.title = "test visit for " + place.uri.spec;
|
||||
}
|
||||
place.visits = [{
|
||||
transitionType: place.transition === undefined ? Ci.nsINavHistoryService.TRANSITION_LINK
|
||||
: place.transition,
|
||||
visitDate: place.visitDate || (now++) * 1000,
|
||||
referrerURI: place.referrer
|
||||
}];
|
||||
}
|
||||
|
||||
PlacesUtils.asyncHistory.updatePlaces(
|
||||
places,
|
||||
{
|
||||
handleError: function AAV_handleError(resultCode, placeInfo) {
|
||||
let ex = new Components.Exception("Unexpected error in adding visits.",
|
||||
resultCode);
|
||||
reject(ex);
|
||||
},
|
||||
handleResult: function () {},
|
||||
handleCompletion: function UP_handleCompletion() {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
TEST_DIRS += ['cpp']
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
'PlacesTestUtils.jsm',
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += [
|
||||
'autocomplete/xpcshell.ini',
|
||||
'bookmarks/xpcshell.ini',
|
||||
|
|
|
@ -1129,7 +1129,7 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
|||
// Process maxRows per chunk to improve performance and user experience
|
||||
for (let i = 0; i < this.maxRows; i++) {
|
||||
if (this._currentIndex >= matchCount)
|
||||
return;
|
||||
break;
|
||||
|
||||
var item;
|
||||
|
||||
|
@ -1185,8 +1185,14 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
|||
this._currentIndex++;
|
||||
}
|
||||
|
||||
// yield after each batch of items so that typing the url bar is responsive
|
||||
setTimeout(function (self) { self._appendCurrentResult(); }, 0, this);
|
||||
if (typeof this.onResultsAdded == "function")
|
||||
this.onResultsAdded();
|
||||
|
||||
if (this._currentIndex < matchCount) {
|
||||
// yield after each batch of items so that typing the url bar is
|
||||
// responsive
|
||||
setTimeout(function (self) { self._appendCurrentResult(); }, 0, this);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
Загрузка…
Ссылка в новой задаче