зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1662066 - Use a single waitFor test helper implementation. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D88834
This commit is contained in:
Родитель
27c9bcc6c5
Коммит
5d89a18f3b
|
@ -38,35 +38,6 @@ function logThreadEvents(dbg, event) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a predicate to return a result.
|
||||
*
|
||||
* @param function condition
|
||||
* Invoked once in a while until it returns a truthy value. This should be an
|
||||
* idempotent function, since we have to run it a second time after it returns
|
||||
* true in order to return the value.
|
||||
* @param string message [optional]
|
||||
* A message to output if the condition fails.
|
||||
* @param number interval [optional]
|
||||
* How often the predicate is invoked, in milliseconds.
|
||||
* @return object
|
||||
* A promise that is resolved with the result of the condition.
|
||||
*/
|
||||
async function waitFor(
|
||||
condition,
|
||||
message = "waitFor",
|
||||
interval = 10,
|
||||
maxTries = 500
|
||||
) {
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
condition,
|
||||
message,
|
||||
interval,
|
||||
maxTries
|
||||
);
|
||||
return condition();
|
||||
}
|
||||
|
||||
// Wait until an action of `type` is dispatched. This is different
|
||||
// then `waitForDispatch` because it doesn't wait for async actions
|
||||
// to be done/errored. Use this if you want to listen for the "start"
|
||||
|
|
|
@ -766,35 +766,6 @@ var waitForTab = async function() {
|
|||
return tab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wait for a predicate to return a result.
|
||||
*
|
||||
* @param {Function} condition
|
||||
* Invoked once in a while until it returns a truthy value. This should be an
|
||||
* idempotent function, since we have to run it a second time after it returns
|
||||
* true in order to return the value.
|
||||
* @param {String} message [optional]
|
||||
* A message to output if the condition fails.
|
||||
* @param {Number} interval [optional]
|
||||
* How often the predicate is invoked, in milliseconds.
|
||||
* @return {Object}
|
||||
* A promise that is resolved with the result of the condition.
|
||||
*/
|
||||
async function waitFor(
|
||||
condition,
|
||||
message = "waitFor",
|
||||
interval = 10,
|
||||
maxTries = 500
|
||||
) {
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
condition,
|
||||
message,
|
||||
interval,
|
||||
maxTries
|
||||
);
|
||||
return condition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate the key input for the given input in the window.
|
||||
*
|
||||
|
|
|
@ -248,8 +248,6 @@ registerCleanupFunction(() => {
|
|||
Services.obs.removeObserver(ConsoleObserver, "console-api-log-event");
|
||||
});
|
||||
|
||||
var waitForTime = DevToolsUtils.waitForTime;
|
||||
|
||||
function loadFrameScriptUtils(browser = gBrowser.selectedBrowser) {
|
||||
let mm = browser.messageManager;
|
||||
const frameURL =
|
||||
|
@ -598,6 +596,60 @@ function synthesizeKeyShortcut(key, target) {
|
|||
EventUtils.synthesizeKey(shortcut.key || "", keyEvent, target);
|
||||
}
|
||||
|
||||
var waitForTime = DevToolsUtils.waitForTime;
|
||||
|
||||
/**
|
||||
* Wait for a tick.
|
||||
* @return {Promise}
|
||||
*/
|
||||
function waitForTick() {
|
||||
return new Promise(resolve => DevToolsUtils.executeSoon(resolve));
|
||||
}
|
||||
|
||||
/**
|
||||
* This shouldn't be used in the tests, but is useful when writing new tests or
|
||||
* debugging existing tests in order to introduce delays in the test steps
|
||||
*
|
||||
* @param {Number} ms
|
||||
* The time to wait
|
||||
* @return A promise that resolves when the time is passed
|
||||
*/
|
||||
function wait(ms) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, ms);
|
||||
info("Waiting " + ms / 1000 + " seconds.");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a predicate to return a result.
|
||||
*
|
||||
* @param function condition
|
||||
* Invoked once in a while until it returns a truthy value. This should be an
|
||||
* idempotent function, since we have to run it a second time after it returns
|
||||
* true in order to return the value.
|
||||
* @param string message [optional]
|
||||
* A message to output if the condition fails.
|
||||
* @param number interval [optional]
|
||||
* How often the predicate is invoked, in milliseconds.
|
||||
* @return object
|
||||
* A promise that is resolved with the result of the condition.
|
||||
*/
|
||||
async function waitFor(
|
||||
condition,
|
||||
message = "waitFor",
|
||||
interval = 10,
|
||||
maxTries = 500
|
||||
) {
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
condition,
|
||||
message,
|
||||
interval,
|
||||
maxTries
|
||||
);
|
||||
return condition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for eventName on target to be delivered a number of times.
|
||||
*
|
||||
|
@ -709,29 +761,6 @@ function loadHelperScript(filePath) {
|
|||
Services.scriptloader.loadSubScript(testDir + "/" + filePath, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a tick.
|
||||
* @return {Promise}
|
||||
*/
|
||||
function waitForTick() {
|
||||
return new Promise(resolve => DevToolsUtils.executeSoon(resolve));
|
||||
}
|
||||
|
||||
/**
|
||||
* This shouldn't be used in the tests, but is useful when writing new tests or
|
||||
* debugging existing tests in order to introduce delays in the test steps
|
||||
*
|
||||
* @param {Number} ms
|
||||
* The time to wait
|
||||
* @return A promise that resolves when the time is passed
|
||||
*/
|
||||
function wait(ms) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, ms);
|
||||
info("Waiting " + ms / 1000 + " seconds.");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the toolbox in a given tab.
|
||||
* @param {XULNode} tab The tab the toolbox should be opened in.
|
||||
|
|
|
@ -335,35 +335,6 @@ function keyboardExecuteAndWaitForMessage(
|
|||
return onMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a predicate to return a result.
|
||||
*
|
||||
* @param function condition
|
||||
* Invoked once in a while until it returns a truthy value. This should be an
|
||||
* idempotent function, since we have to run it a second time after it returns
|
||||
* true in order to return the value.
|
||||
* @param string message [optional]
|
||||
* A message to output if the condition fails.
|
||||
* @param number interval [optional]
|
||||
* How often the predicate is invoked, in milliseconds.
|
||||
* @return object
|
||||
* A promise that is resolved with the result of the condition.
|
||||
*/
|
||||
async function waitFor(
|
||||
condition,
|
||||
message = "waitFor",
|
||||
interval = 10,
|
||||
maxTries = 500
|
||||
) {
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
condition,
|
||||
message,
|
||||
interval,
|
||||
maxTries
|
||||
);
|
||||
return condition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a message in the output.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче