зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1778179 - Remove duplicate definitions of waitForNextPopup. r=sgalich
Differential Revision: https://phabricator.services.mozilla.com/D155251
This commit is contained in:
Родитель
7082d438e6
Коммит
11967f6b54
|
@ -22,13 +22,6 @@ Test for Form History Autocomplete Untrusted Events: Bug 511615
|
|||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var resolvePopupShownListener;
|
||||
registerPopupShownListener(() => resolvePopupShownListener());
|
||||
|
||||
function waitForNextPopup() {
|
||||
return new Promise(resolve => { resolvePopupShownListener = resolve; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the time to wait before checking that the state of the autocomplete
|
||||
* popup, including whether it is open, has not changed in response to events.
|
||||
|
@ -53,7 +46,7 @@ SimpleTest.requestFlakyTimeout("Must ensure that an event does not happen.");
|
|||
* @returns {Promise}
|
||||
*/
|
||||
function expectPopupDoesNotOpen(triggerFn) {
|
||||
let popupShown = waitForNextPopup();
|
||||
const popupShown = promiseACShown();
|
||||
triggerFn();
|
||||
return Promise.race([
|
||||
popupShown.then(() => Promise.reject("Popup opened unexpectedly.")),
|
||||
|
@ -172,9 +165,9 @@ add_task(async function test_untrusted_events_ignored() {
|
|||
}
|
||||
|
||||
// A privileged key press will actually open the popup.
|
||||
let popupShown = waitForNextPopup();
|
||||
const promisePopupShown = promiseACShown();
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
await popupShown;
|
||||
await promisePopupShown;
|
||||
|
||||
// The selected autocomplete item should not change from untrusted events.
|
||||
for (let triggerFn of [
|
||||
|
@ -186,7 +179,7 @@ add_task(async function test_untrusted_events_ignored() {
|
|||
}
|
||||
|
||||
// A privileged key press will actually change the selected index.
|
||||
let indexChanged = new Promise(resolve => notifySelectedIndex(0, resolve));
|
||||
const indexChanged = new Promise(resolve => notifySelectedIndex(0, resolve));
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
await indexChanged;
|
||||
|
||||
|
@ -205,9 +198,8 @@ add_task(async function test_untrusted_events_ignored() {
|
|||
await checkSelectedIndexAfterResponseTime(0);
|
||||
is(input.value, "", "The selected item should not have been used.");
|
||||
}
|
||||
input.blur(); // Close popup
|
||||
|
||||
// Close the popup.
|
||||
input.blur();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -50,15 +50,6 @@ Form History Layout test: form field autocomplete: Bug 787624
|
|||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Form History autocomplete Layout: Bug 787624 **/
|
||||
|
||||
var resolvePopupShownListener;
|
||||
registerPopupShownListener(() => resolvePopupShownListener());
|
||||
|
||||
function waitForNextPopup() {
|
||||
return new Promise(resolve => { resolvePopupShownListener = resolve; });
|
||||
}
|
||||
|
||||
add_setup(async () => {
|
||||
await updateFormHistory([
|
||||
{ op: "remove" },
|
||||
|
@ -68,15 +59,15 @@ add_setup(async () => {
|
|||
});
|
||||
|
||||
add_task(async function test_popup_not_move_input() {
|
||||
let input = getFormElementByName(1, "field1");
|
||||
let rect = input.getBoundingClientRect();
|
||||
const input = getFormElementByName(1, "field1");
|
||||
const rect = input.getBoundingClientRect();
|
||||
|
||||
let popupShown = waitForNextPopup();
|
||||
input.focus();
|
||||
synthesizeKey("KEY_ArrowDown", {});
|
||||
await popupShown;
|
||||
const promisePopupShown = promiseACShown();
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
await promisePopupShown;
|
||||
|
||||
let newRect = input.getBoundingClientRect();
|
||||
const newRect = input.getBoundingClientRect();
|
||||
is(newRect.left, rect.left,
|
||||
"autocomplete popup does not disturb the input position");
|
||||
is(newRect.top, rect.top,
|
||||
|
|
|
@ -27,13 +27,6 @@
|
|||
<script class="testbody" type="text/javascript">
|
||||
const input = document.getElementById("field1");
|
||||
|
||||
let resolvePopupShownListener;
|
||||
registerPopupShownListener(() => resolvePopupShownListener());
|
||||
|
||||
function waitForNextPopup() {
|
||||
return new Promise(resolve => { resolvePopupShownListener = resolve; });
|
||||
}
|
||||
|
||||
add_setup(async () => {
|
||||
await new Promise(resolve => updateFormHistory([
|
||||
{ op: "add", fieldname: "field1", value: "Mozilla" },
|
||||
|
@ -61,10 +54,12 @@ add_task(async function test_non_duplicate_entries_are_shown_once() {
|
|||
async function triggerAutofillAndCheckEntriesValue(inputValue, expectedValues) {
|
||||
SpecialPowers.wrap(input).setUserInput(inputValue);
|
||||
input.focus();
|
||||
synthesizeKey("KEY_ArrowDown"); // trigger autocomplete dropdown
|
||||
await waitForNextPopup();
|
||||
const promisePopupShown = promiseACShown();
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
await promisePopupShown;
|
||||
isDeeply(getMenuEntries(), expectedValues, "Matching deduplicated autocomplete list entries with expected values.");
|
||||
input.blur();
|
||||
input.blur(); // Close popup
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -34,13 +34,6 @@
|
|||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var resolvePopupShownListener;
|
||||
registerPopupShownListener(() => resolvePopupShownListener());
|
||||
|
||||
function waitForNextPopup() {
|
||||
return new Promise(resolve => { resolvePopupShownListener = resolve; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the time to wait before checking that the state of the autocomplete
|
||||
* popup, including whether it is open, has not changed in response to events.
|
||||
|
@ -65,7 +58,7 @@ SimpleTest.requestFlakyTimeout("Must ensure that an event does not happen.");
|
|||
* @returns {Promise}
|
||||
*/
|
||||
function expectPopupDoesNotOpen(triggerFn) {
|
||||
let popupShown = waitForNextPopup();
|
||||
const popupShown = promiseACShown();
|
||||
triggerFn();
|
||||
return Promise.race([
|
||||
popupShown.then(() => Promise.reject("Popup opened unexpectedly.")),
|
||||
|
@ -97,7 +90,7 @@ add_setup(async () => {
|
|||
});
|
||||
|
||||
add_task(async function test_secure_noFormHistoryOrWarning() {
|
||||
let input = getFormElementByName(1, "field1");
|
||||
const input = getFormElementByName(1, "field1");
|
||||
|
||||
// The autocomplete popup should not open under any circumstances on
|
||||
// type=password with password manager disabled.
|
||||
|
@ -116,22 +109,22 @@ add_task(async function test_secure_noFormHistoryOrWarning() {
|
|||
await expectPopupDoesNotOpen(triggerFn);
|
||||
}
|
||||
|
||||
// Close the popup.
|
||||
input.blur();
|
||||
});
|
||||
|
||||
add_task(async function test_insecure_focusWarning() {
|
||||
// Form 2 has an insecure action so should show the warning even if password manager is disabled.
|
||||
let input = getFormElementByName(2, "field1");
|
||||
let shownPromise = waitForNextPopup();
|
||||
const input = getFormElementByName(2, "field1");
|
||||
|
||||
input.focus();
|
||||
await shownPromise;
|
||||
const promisePopupShown = promiseACShown();
|
||||
synthesizeKey("KEY_ArrowDown");
|
||||
await promisePopupShown;
|
||||
|
||||
ok(getMenuEntries()[0].includes("Logins entered here could be compromised"),
|
||||
"Check warning is first");
|
||||
|
||||
// Close the popup
|
||||
input.blur();
|
||||
input.blur(); // Close popup.
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
Загрузка…
Ссылка в новой задаче