michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 60000; michael@0: MARIONETTE_HEAD_JS = 'head.js'; michael@0: michael@0: function handleConferenceRemoveError(callToRemove) { michael@0: log('Handle conference remove error.'); michael@0: michael@0: let deferred = Promise.defer(); michael@0: michael@0: conference.onerror = function(evt) { michael@0: log('Receiving a conference error event.'); michael@0: conference.onerror = null; michael@0: michael@0: is(evt.name, 'removeError', 'conference removeError'); michael@0: michael@0: deferred.resolve(); michael@0: } michael@0: conference.remove(callToRemove); michael@0: michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testConferenceRemoveError() { michael@0: log('= testConferenceRemoveError ='); michael@0: michael@0: let outCall; michael@0: let inCall; michael@0: let inCall2; michael@0: let outNumber = "5555550101"; michael@0: let inNumber = "5555550201"; michael@0: let inNumber2 = "5555550202"; michael@0: let outInfo = gOutCallStrPool(outNumber); michael@0: let inInfo = gInCallStrPool(inNumber); michael@0: let inInfo2 = gInCallStrPool(inNumber2); michael@0: michael@0: return Promise.resolve() michael@0: .then(() => gSetupConferenceTwoCalls(outNumber, inNumber)) michael@0: .then(calls => { michael@0: [outCall, inCall] = calls; michael@0: }) michael@0: .then(() => gRemoteDial(inNumber2)) michael@0: .then(call => {inCall2 = call;}) michael@0: .then(() => gCheckAll(conference, [inCall2], 'connected', [outCall, inCall], michael@0: [outInfo.active, inInfo.active, inInfo2.incoming])) michael@0: .then(() => gAnswer(inCall2, function() { michael@0: gCheckState(inCall2, [inCall2], 'held', [outCall, inCall]); michael@0: })) michael@0: .then(() => gCheckAll(inCall2, [inCall2], 'held', [outCall, inCall], michael@0: [outInfo.held, inInfo.held, inInfo2.active])) michael@0: .then(() => gResumeConference([outCall, inCall], function() { michael@0: gCheckState(conference, [inCall2], 'connected', [outCall, inCall]); michael@0: })) michael@0: // Not allowed to remove a call when there are one connected and one held michael@0: // calls. michael@0: .then(() => handleConferenceRemoveError(outCall)) michael@0: .then(() => gRemoteHangUpCalls([outCall, inCall, inCall2])); michael@0: } michael@0: michael@0: // Start the test michael@0: startTest(function() { michael@0: testConferenceRemoveError() michael@0: .then(null, error => { michael@0: ok(false, 'promise rejects during test.'); michael@0: }) michael@0: .then(finish); michael@0: });