Bug 1533166 - Move getSubmitMessage function into pwmgr_common.js to avoid duplication, r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D30086

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Yuan Cheng 2019-05-06 17:37:21 +00:00
Родитель 8efbd9be96
Коммит 5e6b519d3b
7 изменённых файлов: 20 добавлений и 80 удалений

Просмотреть файл

@ -142,6 +142,26 @@ function checkUnmodifiedForm(formNum) {
}
}
/**
* @param {Function} [aFilterFn = undefined] Function to filter out irrelevant submissions.
* @return {Promise} resolving when a relevant form submission was processed.
*/
function getSubmitMessage(aFilterFn = undefined) {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
PWMGR_COMMON_PARENT.addMessageListener("formSubmissionProcessed", function processed(...args) {
if (aFilterFn && !aFilterFn(...args)) {
// This submission isn't the one we're waiting for.
return;
}
info("got formSubmissionProcessed");
PWMGR_COMMON_PARENT.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
function registerRunTests() {
return new Promise(resolve => {
function onDOMContentLoaded() {

Просмотреть файл

@ -129,17 +129,6 @@ const TESTCASES = [
},
];
function getSubmitMessage() {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
PWMGR_COMMON_PARENT.addMessageListener("formSubmissionProcessed", function processed(...args) {
info("got formSubmissionProcessed");
PWMGR_COMMON_PARENT.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
add_task(async function test() {
let count = 0;
let loginFrame = document.getElementById("loginFrame");

Просмотреть файл

@ -138,26 +138,6 @@ const TESTCASES = [
},
];
/**
* @param {Function} [aFilterFn = undefined] Function to filter out irrelevant submissions.
* @return {Promise} resolving when a relevant form submission was processed.
*/
function getSubmitMessage(aFilterFn = undefined) {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
PWMGR_COMMON_PARENT.addMessageListener("formSubmissionProcessed", function processed(...args) {
if (aFilterFn && !aFilterFn(...args)) {
// This submission isn't the one we're waiting for.
return;
}
info("got formSubmissionProcessed");
PWMGR_COMMON_PARENT.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
function filterFormSubmissions(data) {
return data.newPasswordField.value != "ignore-form-submission";
}

Просмотреть файл

@ -129,20 +129,6 @@ const TESTCASES = [
},
];
/**
* @return {Promise} resolving when form submission was processed.
*/
function getSubmitMessage() {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
PWMGR_COMMON_PARENT.addMessageListener("formSubmissionProcessed", function processed(...args) {
info("got formSubmissionProcessed");
PWMGR_COMMON_PARENT.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
add_task(async function test_new_logins() {
for (let tc of TESTCASES) {
info("Starting testcase: " + JSON.stringify(tc));

Просмотреть файл

@ -12,17 +12,6 @@
<script>
let chromeScript = runChecksAfterCommonInit();
function getSubmitMessage() {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
chromeScript.addMessageListener("formSubmissionProcessed", function processed(...args) {
info("got formSubmissionProcessed");
chromeScript.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
SimpleTest.requestFlakyTimeout("Giving a chance for the unexpected popupshown to occur");
</script>
<p id="display"></p>

Просмотреть файл

@ -12,17 +12,6 @@ Login Manager test: input value change right after onsubmit event
<script>
let chromeScript = runChecksAfterCommonInit();
function getSubmitMessage() {
info("getSubmitMessage");
return new Promise((resolve, reject) => {
chromeScript.addMessageListener("formSubmissionProcessed", function processed(...args) {
info("got formSubmissionProcessed");
chromeScript.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
</script>
<p id="display"></p>

Просмотреть файл

@ -77,19 +77,6 @@ const TESTCASES = [
},
];
/**
* @return {Promise} resolving when form submission was processed.
*/
function getSubmitMessage() {
return new Promise((resolve, reject) => {
PWMGR_COMMON_PARENT.addMessageListener("formSubmissionProcessed", function processed(...args) {
info("got formSubmissionProcessed");
PWMGR_COMMON_PARENT.removeMessageListener("formSubmissionProcessed", processed);
resolve(...args);
});
});
}
add_task(async function test_password_lengths() {
for (let tc of TESTCASES) {
info("Starting testcase: " + tc.testName + ", " + JSON.stringify([tc.pword1, tc.pword2]));