From 2a85a061ba52c0407467ab2b3075c6ac065ab6d1 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Fri, 7 Apr 2017 21:44:32 +0200 Subject: [PATCH] Bug 1335778 - Synchronize navigate() for trigger methods using generators. r=ato 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 --HG-- extra : rebase_source : 19a87058d62088701914ab2a468ddffaecec1fe2 --- testing/marionette/listener.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index 5cc7855def94..f85604944e48 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -273,19 +273,23 @@ var loadListener = { 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); - return; - } - if (!loadEventExpected) { - sendOk(command_id); - } + // Check why we do not raise an error if err is of type Event + sendError(err, command_id); + return; + }); }, }