<html><head><metacharset="utf-8"/><scripttype="application/javascript">varscriptRelativePath="../";</script><scripttype="application/javascript"src="../pc.js"></script></head><body><scriptclass="testbody"type="application/javascript">createHTML({title:"Test multiple identity fingerprints",bug:"1005152"});// here we call the identity provider directlyasyncfunctiongetIdentityAssertion(fingerprint){const{IdpSandbox}=SpecialPowers.ChromeUtils.importESModule('resource://gre/modules/media/IdpSandbox.sys.mjs');constsandbox=newIdpSandbox('example.com','idp.js',window);constidp=SpecialPowers.wrap(awaitsandbox.start());constassertion=SpecialPowers.wrap(awaitidp.generateAssertion(JSON.stringify({fingerprint}),'https://example.com',{}));constassertionString=btoa(JSON.stringify(assertion));sandbox.stop();returnassertionString;}// This takes a real fingerprint and makes some extra bad ones.functionmakeFingerprints(algorithm,digest){constfingerprints=[];fingerprints.push({algorithm,digest});for(vari=0;i<3;++i){fingerprints.push({algorithm,digest:digest.replace(/:./g,':'+i.toString(16))});}returnfingerprints;}constfingerprintRegex=/^a=fingerprint:(\S+) (\S+)/m;constidentityRegex=/^a=identity:(\S+)/m;functionfingerprintSdp(fingerprints){returnfingerprints.map(fp=>'a=fInGeRpRiNt:'+fp.algorithm+' '+fp.digest+'\n').join('');}// Firefox only uses a single fingerprint.// That doesn't mean we have it create SDP that describes two.// This function synthesizes that SDP and tries to set it.runNetworkTest(async()=>{// this one fails setRemoteDescription if the identity is not goodconstpcStrict=newRTCPeerConnection({peerIdentity:'someone@example.com'});// this one will be manually tweaked to have two fingerprintsconstpcDouble=newRTCPeerConnection({});conststream=awaitgetUserMedia({video:true});ok(stream,'Got test stream');const[track]=stream.getTracks();pcDouble.addTrack(track,stream);try{constoffer=awaitpcDouble.createOffer();ok(offer,'Got offer');constmatch=offer.sdp.match(fingerprintRegex);if(!match){thrownewError('No fingerprint in offer SDP');}constfingerprints=makeFingerprints(match[1],match[2]);constassertion=awaitgetIdentityAssertion(fingerprints);ok(assertion,'Should have assertion');constsdp=offer.sdp.slice(0,match.index)+'a=identity:'+assertion+'\n'+fingerprintSdp(fingerprints.slice(1))+offer.sdp.slice(match.index);awaitpcStrict.setRemoteDescription({type:'offer',sdp});ok(true,'Modified fingerprints were accepted');}catch(error){conste=SpecialPowers.wrap(error);ok(false,'error in test: '+(e.message?(e.message+'\n'+e.stack):e));}pcStrict.close();pcDouble.close();track.stop();});</script></body></html>