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
This commit is contained in:
Henrik Skupin 2017-04-07 21:44:32 +02:00
Родитель e1a0e9491a
Коммит 2a85a061ba
1 изменённых файлов: 13 добавлений и 9 удалений

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

@ -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;
});
},
}