diff --git a/dom/telephony/test/marionette/head.js b/dom/telephony/test/marionette/head.js index 7ea0b87b485..93e8fd95a3e 100644 --- a/dom/telephony/test/marionette/head.js +++ b/dom/telephony/test/marionette/head.js @@ -55,6 +55,23 @@ let emulator = (function() { * Telephony related helper functions. */ (function() { + /** + * @return Promise + */ + function delay(ms) { + let deferred = Promise.defer(); + + let startTime = Date.now(); + waitFor(function() { + deferred.resolve(); + },function() { + let duration = Date.now() - startTime; + return (duration >= ms); + }); + + return deferred.promise; + } + /** * @return Promise */ @@ -1016,6 +1033,7 @@ let emulator = (function() { * Public members. */ + this.gDelay = delay; this.gCheckInitialState = checkInitialState; this.gClearCalls = clearCalls; this.gOutCallStrPool = outCallStrPool; diff --git a/dom/telephony/test/marionette/test_outgoing_emergency_in_airplane_mode.js b/dom/telephony/test/marionette/test_outgoing_emergency_in_airplane_mode.js index 67f9d7de514..d38654caed2 100644 --- a/dom/telephony/test/marionette/test_outgoing_emergency_in_airplane_mode.js +++ b/dom/telephony/test/marionette/test_outgoing_emergency_in_airplane_mode.js @@ -34,6 +34,7 @@ startTestWithPermissions(['mobileconnection'], function() { .then(() => gDial("112")) .then(call => { outCall = call; }) .then(() => gRemoteAnswer(outCall)) + .then(() => gDelay(1000)) // See Bug 1018051 for the purpose of the delay. .then(() => gRemoteHangUp(outCall)) .then(null, () => { ok(false, "promise rejects during test.");