From 8e3266a3c8673497a4c8c31be17f91a2a6cfcf40 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Fri, 30 May 2014 03:33:00 +0800 Subject: [PATCH] Bug 1018051 - Delay 1s in test_outgoing_emergency_in_airplane_mode.js. r=echen --- dom/telephony/test/marionette/head.js | 18 ++++++++++++++++++ ...test_outgoing_emergency_in_airplane_mode.js | 1 + 2 files changed, 19 insertions(+) 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.");