mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169159 - Make xpcshells run_test_in_child() and do_await_remote_message() return promises. r=ted,gfritzsche
This commit is contained in:
parent
6ae071f17a
commit
b1961bbde0
@ -1239,11 +1239,19 @@ function do_load_child_test_harness()
|
||||
* @param optionalCallback.
|
||||
* Optional function to be called (in parent) when test on child is
|
||||
* complete. If provided, the function must call do_test_finished();
|
||||
* @return Promise Resolved when the test in the child is complete.
|
||||
*/
|
||||
function run_test_in_child(testFile, optionalCallback)
|
||||
{
|
||||
var callback = (typeof optionalCallback == 'undefined') ?
|
||||
do_test_finished : optionalCallback;
|
||||
return new Promise((resolve) => {
|
||||
var callback = () => {
|
||||
resolve();
|
||||
if (typeof optionalCallback == 'undefined') {
|
||||
do_test_finished();
|
||||
} else {
|
||||
optionalCallback();
|
||||
}
|
||||
};
|
||||
|
||||
do_load_child_test_harness();
|
||||
|
||||
@ -1254,22 +1262,33 @@ function run_test_in_child(testFile, optionalCallback)
|
||||
+ "_execute_test(); "
|
||||
+ "_testLogger.info('CHILD-TEST-COMPLETED');",
|
||||
callback);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given function as soon as a particular cross-process message is received.
|
||||
* Must be paired with do_send_remote_message or equivalent ProcessMessageManager calls.
|
||||
*
|
||||
* @param optionalCallback
|
||||
* Optional callback that is invoked when the message is received. If provided,
|
||||
* the function must call do_test_finished().
|
||||
* @return Promise Promise that is resolved when the message is received.
|
||||
*/
|
||||
function do_await_remote_message(name, callback)
|
||||
function do_await_remote_message(name, optionalCallback)
|
||||
{
|
||||
return new Promise((resolve) => {
|
||||
var listener = {
|
||||
receiveMessage: function(message) {
|
||||
if (message.name == name) {
|
||||
mm.removeMessageListener(name, listener);
|
||||
callback();
|
||||
resolve();
|
||||
if (optionalCallback) {
|
||||
optionalCallback();
|
||||
} else {
|
||||
do_test_finished();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var mm;
|
||||
@ -1280,6 +1299,7 @@ function do_await_remote_message(name, callback)
|
||||
}
|
||||
do_test_pending();
|
||||
mm.addMessageListener(name, listener);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user