зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1300995 - Part 2. Add a browser chrome test for form autofill popup footer. r=MattN
MozReview-Commit-ID: 7IAp0SzPzmm --HG-- extra : rebase_source : 66ed7625a69524757da4769b068e0b221a0dfaa3
This commit is contained in:
Родитель
ea283e4f3d
Коммит
eaa3ec75f7
|
@ -4,6 +4,7 @@ head = head.js
|
|||
support-files =
|
||||
../fixtures/autocomplete_basic.html
|
||||
|
||||
[browser_autocomplete_footer.js]
|
||||
[browser_check_installed.js]
|
||||
[browser_editProfileDialog.js]
|
||||
[browser_first_time_use_doorhanger.js]
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
|
||||
const URL = BASE_URL + "autocomplete_basic.html";
|
||||
const PRIVACY_PREF_URL = "about:preferences#privacy";
|
||||
|
||||
add_task(async function setup_storage() {
|
||||
await saveAddress(TEST_ADDRESS_1);
|
||||
await saveAddress(TEST_ADDRESS_2);
|
||||
await saveAddress(TEST_ADDRESS_3);
|
||||
});
|
||||
|
||||
add_task(async function test_click_on_footer() {
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
|
||||
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
|
||||
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
content.document.getElementById("organization").focus();
|
||||
});
|
||||
await sleep(2000);
|
||||
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
|
||||
await BrowserTestUtils.waitForCondition(() => autoCompletePopup.popupOpen);
|
||||
|
||||
// Click on the footer
|
||||
const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem");
|
||||
const prefTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, PRIVACY_PREF_URL);
|
||||
await EventUtils.synthesizeMouseAtCenter(listItemElems[listItemElems.length - 1], {});
|
||||
await BrowserTestUtils.removeTab(await prefTabPromise);
|
||||
ok(true, "Tab: preferences#privacy was successfully opened by clicking on the footer");
|
||||
|
||||
// Ensure the popup is closed before entering the next test.
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
content.document.getElementById("organization").blur();
|
||||
});
|
||||
await BrowserTestUtils.waitForCondition(() => !autoCompletePopup.popupOpen);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_press_enter_on_footer() {
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: URL}, async function(browser) {
|
||||
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
|
||||
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
const input = content.document.getElementById("organization");
|
||||
input.focus();
|
||||
});
|
||||
await sleep(2000);
|
||||
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
|
||||
await BrowserTestUtils.waitForCondition(() => autoCompletePopup.popupOpen);
|
||||
|
||||
// Navigate to the footer and press enter.
|
||||
const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem");
|
||||
const prefTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, PRIVACY_PREF_URL);
|
||||
for (let i = 0; i < listItemElems.length; i++) {
|
||||
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
|
||||
}
|
||||
await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser);
|
||||
await BrowserTestUtils.removeTab(await prefTabPromise);
|
||||
ok(true, "Tab: preferences#privacy was successfully opened by pressing enter on the footer");
|
||||
});
|
||||
});
|
|
@ -1,12 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
let addresses = await getAddresses();
|
||||
if (addresses.length) {
|
||||
await removeAddresses(addresses.map(address => address.guid));
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_cancelEditProfileDialog() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_PROFILE_DIALOG_URL, null, null, null);
|
||||
|
|
|
@ -4,13 +4,6 @@ const FORM_URL = "http://mochi.test:8888/browser/browser/extensions/formautofill
|
|||
const FTU_PREF = "extensions.formautofill.firstTimeUse";
|
||||
const ENABLED_PREF = "extensions.formautofill.addresses.enabled";
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
let addresses = await getAddresses();
|
||||
if (addresses.length) {
|
||||
await removeAddresses(addresses.map(address => address.guid));
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_first_time_save() {
|
||||
let addresses = await getAddresses();
|
||||
is(addresses.length, 0, "No profile in storage");
|
||||
|
|
|
@ -19,13 +19,6 @@ function waitForAddresses() {
|
|||
});
|
||||
}
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
let addresses = await getAddresses();
|
||||
if (addresses.length) {
|
||||
await removeAddresses(addresses.map(address => address.guid));
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_manageProfilesInitialState() {
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: MANAGE_PROFILES_DIALOG_URL}, async function(browser) {
|
||||
await ContentTask.spawn(browser, TEST_SELECTORS, (args) => {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* exported MANAGE_PROFILES_DIALOG_URL, EDIT_PROFILE_DIALOG_URL,
|
||||
/* exported MANAGE_PROFILES_DIALOG_URL, EDIT_PROFILE_DIALOG_URL, BASE_URL,
|
||||
TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3,
|
||||
getAddresses, saveAddress, removeAddresses */
|
||||
sleep, getAddresses, saveAddress, removeAddresses */
|
||||
|
||||
"use strict";
|
||||
|
||||
const MANAGE_PROFILES_DIALOG_URL = "chrome://formautofill/content/manageProfiles.xhtml";
|
||||
const EDIT_PROFILE_DIALOG_URL = "chrome://formautofill/content/editProfile.xhtml";
|
||||
const BASE_URL = "http://mochi.test:8888/browser/browser/extensions/formautofill/test/browser/";
|
||||
|
||||
const TEST_ADDRESS_1 = {
|
||||
"given-name": "John",
|
||||
|
@ -31,6 +32,10 @@ const TEST_ADDRESS_3 = {
|
|||
"postal-code": "12345",
|
||||
};
|
||||
|
||||
async function sleep(ms = 500) {
|
||||
await new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function getAddresses() {
|
||||
return new Promise(resolve => {
|
||||
Services.cpmm.addMessageListener("FormAutofill:Addresses", function getResult(result) {
|
||||
|
@ -50,3 +55,10 @@ function removeAddresses(guids) {
|
|||
Services.cpmm.sendAsyncMessage("FormAutofill:RemoveAddresses", {guids});
|
||||
return TestUtils.topicObserved("formautofill-storage-changed");
|
||||
}
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
let addresses = await getAddresses();
|
||||
if (addresses.length) {
|
||||
await removeAddresses(addresses.map(address => address.guid));
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче