Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | MARIONETTE_TIMEOUT = 60000; |
michael@0 | 5 | MARIONETTE_HEAD_JS = 'head.js'; |
michael@0 | 6 | |
michael@0 | 7 | function handleConferenceRemoveError(callToRemove) { |
michael@0 | 8 | log('Handle conference remove error.'); |
michael@0 | 9 | |
michael@0 | 10 | let deferred = Promise.defer(); |
michael@0 | 11 | |
michael@0 | 12 | conference.onerror = function(evt) { |
michael@0 | 13 | log('Receiving a conference error event.'); |
michael@0 | 14 | conference.onerror = null; |
michael@0 | 15 | |
michael@0 | 16 | is(evt.name, 'removeError', 'conference removeError'); |
michael@0 | 17 | |
michael@0 | 18 | deferred.resolve(); |
michael@0 | 19 | } |
michael@0 | 20 | conference.remove(callToRemove); |
michael@0 | 21 | |
michael@0 | 22 | return deferred.promise; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function testConferenceRemoveError() { |
michael@0 | 26 | log('= testConferenceRemoveError ='); |
michael@0 | 27 | |
michael@0 | 28 | let outCall; |
michael@0 | 29 | let inCall; |
michael@0 | 30 | let inCall2; |
michael@0 | 31 | let outNumber = "5555550101"; |
michael@0 | 32 | let inNumber = "5555550201"; |
michael@0 | 33 | let inNumber2 = "5555550202"; |
michael@0 | 34 | let outInfo = gOutCallStrPool(outNumber); |
michael@0 | 35 | let inInfo = gInCallStrPool(inNumber); |
michael@0 | 36 | let inInfo2 = gInCallStrPool(inNumber2); |
michael@0 | 37 | |
michael@0 | 38 | return Promise.resolve() |
michael@0 | 39 | .then(() => gSetupConferenceTwoCalls(outNumber, inNumber)) |
michael@0 | 40 | .then(calls => { |
michael@0 | 41 | [outCall, inCall] = calls; |
michael@0 | 42 | }) |
michael@0 | 43 | .then(() => gRemoteDial(inNumber2)) |
michael@0 | 44 | .then(call => {inCall2 = call;}) |
michael@0 | 45 | .then(() => gCheckAll(conference, [inCall2], 'connected', [outCall, inCall], |
michael@0 | 46 | [outInfo.active, inInfo.active, inInfo2.incoming])) |
michael@0 | 47 | .then(() => gAnswer(inCall2, function() { |
michael@0 | 48 | gCheckState(inCall2, [inCall2], 'held', [outCall, inCall]); |
michael@0 | 49 | })) |
michael@0 | 50 | .then(() => gCheckAll(inCall2, [inCall2], 'held', [outCall, inCall], |
michael@0 | 51 | [outInfo.held, inInfo.held, inInfo2.active])) |
michael@0 | 52 | .then(() => gResumeConference([outCall, inCall], function() { |
michael@0 | 53 | gCheckState(conference, [inCall2], 'connected', [outCall, inCall]); |
michael@0 | 54 | })) |
michael@0 | 55 | // Not allowed to remove a call when there are one connected and one held |
michael@0 | 56 | // calls. |
michael@0 | 57 | .then(() => handleConferenceRemoveError(outCall)) |
michael@0 | 58 | .then(() => gRemoteHangUpCalls([outCall, inCall, inCall2])); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Start the test |
michael@0 | 62 | startTest(function() { |
michael@0 | 63 | testConferenceRemoveError() |
michael@0 | 64 | .then(null, error => { |
michael@0 | 65 | ok(false, 'promise rejects during test.'); |
michael@0 | 66 | }) |
michael@0 | 67 | .then(finish); |
michael@0 | 68 | }); |