diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index c6fdf8fb0051..c72d6627ddfa 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -1062,11 +1062,9 @@ class RTCPeerConnection { }); } - setIdentityProvider(provider, - {protocol, usernameHint, peerIdentity} = {}) { + setIdentityProvider(provider, protocol, username) { this._checkClosed(); - this._localIdp.setIdentityProvider(provider, - protocol, usernameHint, peerIdentity); + this._localIdp.setIdentityProvider(provider, protocol, username); } async _getIdentityAssertion(origin) { diff --git a/dom/media/PeerConnectionIdp.jsm b/dom/media/PeerConnectionIdp.jsm index 41c8494d2d1c..c4dff798d7f0 100644 --- a/dom/media/PeerConnectionIdp.jsm +++ b/dom/media/PeerConnectionIdp.jsm @@ -43,12 +43,11 @@ PeerConnectionIdp.prototype = { this.idpLoginUrl = null; }, - setIdentityProvider(provider, protocol, usernameHint, peerIdentity) { + setIdentityProvider(provider, protocol, username) { this._resetAssertion(); this.provider = provider; - this.protocol = protocol; - this.username = usernameHint; - this.peeridentity = peerIdentity; + this.protocol = protocol || "default"; + this.username = username; if (this._idp) { if (this._idp.isSame(provider, protocol)) { return; // noop @@ -70,8 +69,6 @@ PeerConnectionIdp.prototype = { this._resetAssertion(); this.provider = null; this.protocol = null; - this.username = null; - this.peeridentity = null; if (this._idp) { this._idp.stop(); this._idp = null; @@ -285,15 +282,9 @@ PeerConnectionIdp.prototype = { this._resetAssertion(); let p = this.start() - .then(idp => { - let options = { protocol: this.protocol, - usernameHint: this.username, - peerIdentity: this.peeridentity }; - return this._wrapCrossCompartmentPromise( - idp.generateAssertion(JSON.stringify(content), - origin, - options)); - }) + .then(idp => this._wrapCrossCompartmentPromise( + idp.generateAssertion(JSON.stringify(content), + origin, this.username))) .then(assertion => { if (!this._isValidAssertion(assertion)) { throw new this._win.DOMException("IdP generated invalid assertion", diff --git a/dom/media/tests/mochitest/identity/identityPcTest.js b/dom/media/tests/mochitest/identity/identityPcTest.js index 88556a8271bb..e5fcbc5db87f 100644 --- a/dom/media/tests/mochitest/identity/identityPcTest.js +++ b/dom/media/tests/mochitest/identity/identityPcTest.js @@ -22,8 +22,8 @@ function identityPcTest(remoteOptions) { video: true, peerIdentity: id1 }]); - test.pcLocal.setIdentityProvider('test1.example.com', { protocol: 'idp.js' }); - test.pcRemote.setIdentityProvider('test2.example.com', { protocol: 'idp.js' }); + test.pcLocal.setIdentityProvider('test1.example.com', 'idp.js'); + test.pcRemote.setIdentityProvider('test2.example.com', 'idp.js'); test.chain.append([ function PEER_IDENTITY_IS_SET_CORRECTLY(test) { // no need to wait to check identity in this case, diff --git a/dom/media/tests/mochitest/identity/idp.js b/dom/media/tests/mochitest/identity/idp.js index 9eb131198d6e..6cc3a17063d5 100644 --- a/dom/media/tests/mochitest/identity/idp.js +++ b/dom/media/tests/mochitest/identity/idp.js @@ -56,7 +56,6 @@ }, _selectUsername: function(usernameHint) { - dump('_selectUsername: usernameHint(' + usernameHint + ')\n'); var username = 'someone@' + this.domain; if (usernameHint) { var at = usernameHint.indexOf('@'); @@ -69,9 +68,8 @@ return username; }, - generateAssertion: function(payload, origin, options) { - dump('idp: generateAssertion(' + payload + ', ' + origin + ', ' - + JSON.stringify(options) + ')\n'); + generateAssertion: function(payload, origin, usernameHint) { + dump('idp: generateAssertion(' + payload + ')\n'); var idpDetails = { domain: this.domain, protocol: this.protocol @@ -82,7 +80,7 @@ return this.borkResult({ idp: idpDetails, assertion: JSON.stringify({ - username: this._selectUsername(options.usernameHint), + username: this._selectUsername(usernameHint), contents: payload }) }); diff --git a/dom/media/tests/mochitest/identity/test_fingerprints.html b/dom/media/tests/mochitest/identity/test_fingerprints.html index 949bb32e10fd..0bb233945685 100644 --- a/dom/media/tests/mochitest/identity/test_fingerprints.html +++ b/dom/media/tests/mochitest/identity/test_fingerprints.html @@ -16,8 +16,7 @@ function getIdentityAssertion(fpArray) { return sandbox.start() .then(idp => SpecialPowers.wrap(idp) .generateAssertion(JSON.stringify({ fingerprint: fpArray }), - 'https://example.com', - {})) + 'https://example.com')) .then(assertion => { assertion = SpecialPowers.wrap(assertion); var assertionString = btoa(JSON.stringify(assertion)); diff --git a/dom/media/tests/mochitest/identity/test_getIdentityAssertion.html b/dom/media/tests/mochitest/identity/test_getIdentityAssertion.html index 0c16604b67fe..6629816134c9 100644 --- a/dom/media/tests/mochitest/identity/test_getIdentityAssertion.html +++ b/dom/media/tests/mochitest/identity/test_getIdentityAssertion.html @@ -21,11 +21,8 @@ function checkIdentity(assertion, identity) { } function getAssertion(t, instructions, userHint) { - dump('instructions: ' + instructions + '\n'); - dump('userHint: ' + userHint + '\n'); - t.pcLocal.setIdentityProvider('example.com', - { protocol: 'idp.js' + instructions, - usernameHint: userHint }); + t.pcLocal.setIdentityProvider('example.com', 'idp.js' + instructions, + userHint); return t.pcLocal._pc.getIdentityAssertion(); } @@ -42,9 +39,7 @@ function theTest() { }, function PC_LOCAL_IDENTITY_ASSERTION_FAILS_WITH_BAD_PROVIDER(t) { - t.pcLocal._pc.setIdentityProvider('example.com', - { protocol: 'idp-bad.js', - usernameHint: '' }); + t.pcLocal._pc.setIdentityProvider('example.com', 'idp-bad.js', ''); return t.pcLocal._pc.getIdentityAssertion() .then(a => ok(false, 'should fail with bad provider'), e => { diff --git a/dom/media/tests/mochitest/identity/test_idpproxy.html b/dom/media/tests/mochitest/identity/test_idpproxy.html index e24bbf6521cc..c8860d1f4e38 100644 --- a/dom/media/tests/mochitest/identity/test_idpproxy.html +++ b/dom/media/tests/mochitest/identity/test_idpproxy.html @@ -63,8 +63,7 @@ function makeSandbox(js) { function test_generate_assertion() { return makeSandbox() .then(idp => idp.generateAssertion(dummyPayload, - 'https://example.net', - {})) + 'https://example.net')) .then(response => { response = SpecialPowers.wrap(response); is(response.idp.domain, 'example.com', 'domain is correct'); @@ -80,8 +79,7 @@ function test_generate_assertion() { function test_validate_assertion() { return makeSandbox() .then(idp => idp.generateAssertion(dummyPayload, - 'https://example.net', - { usernameHint: 'user' })) + 'https://example.net', 'user')) .then(assertion => { var wrapped = SpecialPowers.wrap(assertion); return makeSandbox() @@ -99,7 +97,7 @@ function test_validate_assertion() { function test_assertion_failure(reason) { return () => { return makeSandbox(idpName(reason)) - .then(idp => idp.generateAssertion('hello', 'example.net', {})) + .then(idp => idp.generateAssertion('hello', 'example.net')) .then(r => ok(false, 'should not succeed on ' + reason), e => ok(true, 'failed correctly on ' + reason)); }; diff --git a/dom/media/tests/mochitest/identity/test_loginNeeded.html b/dom/media/tests/mochitest/identity/test_loginNeeded.html index c1dba507c696..3628cb3b230e 100644 --- a/dom/media/tests/mochitest/identity/test_loginNeeded.html +++ b/dom/media/tests/mochitest/identity/test_loginNeeded.html @@ -24,8 +24,7 @@ function waitForLoginDone() { } function checkLogin(t, name, onLoginNeeded) { - t.pcLocal.setIdentityProvider('example.com', - { protocol: 'idp.js#login:' + name }); + t.pcLocal.setIdentityProvider('example.com', 'idp.js#login:' + name); return t.pcLocal._pc.getIdentityAssertion() .then(a => ok(false, 'should request login'), e => { diff --git a/dom/media/tests/mochitest/identity/test_setIdentityProvider.html b/dom/media/tests/mochitest/identity/test_setIdentityProvider.html index 4cb8bfee20ac..ee65d5af5907 100644 --- a/dom/media/tests/mochitest/identity/test_setIdentityProvider.html +++ b/dom/media/tests/mochitest/identity/test_setIdentityProvider.html @@ -24,12 +24,8 @@ function checkIdentity(peer, prefix, idp, name) { function theTest() { var test = new PeerConnectionTest(); test.setMediaConstraints([{audio: true}], [{audio: true}]); - test.pcLocal.setIdentityProvider("test1.example.com", - { protocol: "idp.js", - usernameHint: "someone" }); - test.pcRemote.setIdentityProvider("test2.example.com", - { protocol: "idp.js", - usernameHinte: "someone"}); + test.pcLocal.setIdentityProvider("test1.example.com", "idp.js", "someone"); + test.pcRemote.setIdentityProvider("test2.example.com", "idp.js", "someone"); test.chain.append([ function PC_LOCAL_PEER_IDENTITY_IS_SET_CORRECTLY(test) { diff --git a/dom/media/tests/mochitest/identity/test_setIdentityProviderWithErrors.html b/dom/media/tests/mochitest/identity/test_setIdentityProviderWithErrors.html index 86469d9e738c..ce6276a2b66e 100644 --- a/dom/media/tests/mochitest/identity/test_setIdentityProviderWithErrors.html +++ b/dom/media/tests/mochitest/identity/test_setIdentityProviderWithErrors.html @@ -18,9 +18,7 @@ runNetworkTest(function () { test.setMediaConstraints([{audio: true}], [{audio: true}]); // No IdP for local. // Remote generates a bad assertion, but that only fails to validate - test.pcRemote.setIdentityProvider('example.com', - { protocol: 'idp.js#bad-validate', - usernameHint: 'nobody' }); + test.pcRemote.setIdentityProvider('example.com', 'idp.js#bad-validate', 'nobody'); // Save the peerIdentity promises now, since when they reject they are // replaced and we expect them to be rejected this time diff --git a/dom/media/tests/mochitest/pc.js b/dom/media/tests/mochitest/pc.js index 3c931ce23bed..af135985ab9f 100644 --- a/dom/media/tests/mochitest/pc.js +++ b/dom/media/tests/mochitest/pc.js @@ -873,8 +873,8 @@ PeerConnectionWrapper.prototype = { return this._pc.iceConnectionState; }, - setIdentityProvider: function(provider, options) { - this._pc.setIdentityProvider(provider, options); + setIdentityProvider: function(provider, protocol, identity) { + this._pc.setIdentityProvider(provider, protocol, identity); }, elementPrefix : direction => diff --git a/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp b/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp index 9ea0f0c5a836..76ed3e5adbdf 100644 --- a/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp +++ b/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp @@ -63,13 +63,13 @@ RTCIdentityProviderRegistrar::HasIdp() const already_AddRefed RTCIdentityProviderRegistrar::GenerateAssertion( const nsAString& aContents, const nsAString& aOrigin, - const RTCIdentityProviderOptions& aOptions, ErrorResult& aRv) + const Optional& aUsernameHint, ErrorResult& aRv) { if (!mGenerateAssertionCallback) { aRv.Throw(NS_ERROR_NOT_INITIALIZED); return nullptr; } - return mGenerateAssertionCallback->Call(aContents, aOrigin, aOptions, aRv); + return mGenerateAssertionCallback->Call(aContents, aOrigin, aUsernameHint, aRv); } already_AddRefed RTCIdentityProviderRegistrar::ValidateAssertion( diff --git a/dom/media/webrtc/RTCIdentityProviderRegistrar.h b/dom/media/webrtc/RTCIdentityProviderRegistrar.h index 7b1a64b967e6..49537503b35b 100644 --- a/dom/media/webrtc/RTCIdentityProviderRegistrar.h +++ b/dom/media/webrtc/RTCIdentityProviderRegistrar.h @@ -40,8 +40,7 @@ public: already_AddRefed GenerateAssertion(const nsAString& aContents, const nsAString& aOrigin, - const RTCIdentityProviderOptions& aOptions, - ErrorResult& aRv); + const Optional& aUsernameHint, ErrorResult& aRv); already_AddRefed ValidateAssertion(const nsAString& assertion, const nsAString& origin, ErrorResult& aRv); diff --git a/dom/webidl/RTCIdentityProvider.webidl b/dom/webidl/RTCIdentityProvider.webidl index 8717ea2588fd..fd1b44b09291 100644 --- a/dom/webidl/RTCIdentityProvider.webidl +++ b/dom/webidl/RTCIdentityProvider.webidl @@ -23,7 +23,7 @@ interface RTCIdentityProviderRegistrar { [ChromeOnly, Throws] Promise generateAssertion(DOMString contents, DOMString origin, - optional RTCIdentityProviderOptions options); + optional DOMString usernameHint); /* Forward to idp.validateAssertion() */ [ChromeOnly, Throws] Promise @@ -37,8 +37,7 @@ dictionary RTCIdentityProvider { callback GenerateAssertionCallback = Promise - (DOMString contents, DOMString origin, - RTCIdentityProviderOptions options); + (DOMString contents, DOMString origin, optional DOMString usernameHint); callback ValidateAssertionCallback = Promise (DOMString assertion, DOMString origin); @@ -56,10 +55,3 @@ dictionary RTCIdentityValidationResult { required DOMString identity; required DOMString contents; }; - -dictionary RTCIdentityProviderOptions { - DOMString protocol = "default"; - DOMString usernameHint; - DOMString peerIdentity; -}; - diff --git a/dom/webidl/RTCPeerConnection.webidl b/dom/webidl/RTCPeerConnection.webidl index ab935f1a31c2..8b2e787feec3 100644 --- a/dom/webidl/RTCPeerConnection.webidl +++ b/dom/webidl/RTCPeerConnection.webidl @@ -83,7 +83,8 @@ interface RTCPeerConnection : EventTarget { [Pref="media.peerconnection.identity.enabled"] void setIdentityProvider (DOMString provider, - optional RTCIdentityProviderOptions options); + optional DOMString protocol, + optional DOMString username); [Pref="media.peerconnection.identity.enabled"] Promise getIdentityAssertion(); Promise createOffer (optional RTCOfferOptions options);