Bug 1335778 - Synchronize navigate() for trigger methods using generators.
In the case when the trigger callback inside navigate() uses a generator,
the code has to be synchronized and needs to wait until the contained
command has been completed.
MozReview-Commit-ID: 8qKUMvH7HpS
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -268,29 +268,33 @@ var loadListener = {
}
}
if (loadEventExpected) {
let startTime = new Date().getTime();
this.start(command_id, timeout, startTime, true);
}
- try {
- trigger();
- } catch (e) {
+ return Task.spawn(function* () {
+ yield trigger();
+
+ }).then(val => {
+ if (!loadEventExpected) {
+ sendOk(command_id);
+ }
+
+ }).catch(err => {
if (loadEventExpected) {
this.stop();
}
- sendError(new UnknownCommandError(e.message), command_id);
+
+ // Check why we do not raise an error if err is of type Event
+ sendError(err, command_id);
return;
- }
-
- if (!loadEventExpected) {
- sendOk(command_id);
- }
+ });
},
}
/**
* Called when listener is first started up.
* The listener sends its unique window ID and its current URI to the actor.
* If the actor returns an ID, we start the listeners. Otherwise, nothing happens.
*/