Bug 1976779 - rsclientcerts: make each backend responsible for rate-limiting calls to find_objects r=jschanck
Before this patch, `rsclientcerts::manager` would rate-limit calls to
`find_objects` to once every 3 seconds because the underlying operation can be
time-consuming (in particular, on macOS and Windows, if there are many
certificates/keys available). On Android, keys aren't available until the user
selects one, which means that if a call to `find_objects` happened before the
selection prompt was shown (which is what happens) and the user chose one in
less than 3 seconds, the backend wouldn't search again, thus making it seem like
no keys were available, which would cause Firefox to not send a client
certificate. This patch makes each backend implementation responsible for this
rate-limiting, because only they know if it's appropriate to do so (in particular,
on Android, `find_objects` doesn't have the same performance concern as
on macOS and Windows because rather than searching for certificates and
keys, it asks `ClientAuthCertificateManager` for the cached list of certificates
and keys that have already been approved for use by the user).
Differential Revision: https://phabricator.services.mozilla.com/D257065
<!DOCTYPE HTML><html><head><scripttype="application/javascript"src="pc.js"></script><scripttype="application/javascript"src="sdpUtils.js"></script></head><body><preid="test"><scripttype="application/javascript">createHTML({bug:"1401592",title:"Test that setParameters compat mode works",visible:true});functioncompareCodecParam(observed,expected){info(`Comparing ${JSON.stringify(observed)} to ${JSON.stringify(expected)}`);is(observed.payloadType,expected.payloadType);is(observed.clockRate,expected.clockRate);is(observed.channels,expected.channels);is(observed.mimeType.toLowerCase(),expected.mimeType.toLowerCase());if(expected.hasOwnProperty('sdpFmtpLine')){is(observed.sdpFmtpLine,expected.sdpFmtpLine);}}functioncompareCodecParams(observed,expected){is(observed.length,expected.length);if(observed.length==expected.length){for(leti=0;i<observed.length;++i){compareCodecParam(observed[i],expected[i]);}}}consttests=[asyncfunctioncheckNoGetParameters(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc=newRTCPeerConnection();const{sender}=pc.addTransceiver('video',{sendEncodings:[{rid:"0"},{rid:"1"},{rid:"2"}]});awaitsender.setParameters({encodings:[{rid:"0"},{rid:"1"},{rid:"2"}]});});},asyncfunctioncheckStaleGetParameters(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc=newRTCPeerConnection();const{sender}=pc.addTransceiver('video',{sendEncodings:[{rid:"0"},{rid:"1"},{rid:"2"}]});constparams=sender.getParameters();awaitnewPromise(r=>setTimeout(r,10));awaitsender.setParameters(params);});},asyncfunctioncheckLengthChanged(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc=newRTCPeerConnection();const{sender}=pc.addTransceiver('video',{sendEncodings:[{rid:"0"},{rid:"1"},{rid:"2"}]});constparams=sender.getParameters();params.encodings.pop();awaitsender.setParameters(params);});},asyncfunctioncheckNoTransactionId(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc=newRTCPeerConnection();const{sender}=pc.addTransceiver('video',{sendEncodings:[{rid:"0"},{rid:"1"},{rid:"2"}]});constparams=sender.getParameters();deleteparams.transactionId;awaitsender.setParameters(params);});},asyncfunctioncheckCodecsUndefined(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc1=newRTCPeerConnection();constpc2=newRTCPeerConnection();const{sender}=pc1.addTransceiver('video');awaitpc1.setLocalDescription();awaitpc2.setRemoteDescription(pc1.localDescription);awaitpc1.setRemoteDescription(awaitpc2.createAnswer());letparams=sender.getParameters();constcodecsCopy=[...params.codecs];deleteparams.codecs;awaitsender.setParameters(params);params=sender.getParameters();compareCodecParams(params.codecs,codecsCopy);});},asyncfunctioncheckCodecsExtended(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc1=newRTCPeerConnection();constpc2=newRTCPeerConnection();const{sender}=pc1.addTransceiver('video');awaitpc1.setLocalDescription();awaitpc2.setRemoteDescription(pc1.localDescription);awaitpc1.setRemoteDescription(awaitpc2.createAnswer());letparams=sender.getParameters();constcodecsCopy=[...params.codecs];params.codecs.push({payloadType:2,mimeType:'video/flarglblurp',clockRate:1000});awaitsender.setParameters(params);params=sender.getParameters();compareCodecParams(params.codecs,codecsCopy);});},asyncfunctioncheckCodecsTruncated(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc1=newRTCPeerConnection();constpc2=newRTCPeerConnection();const{sender}=pc1.addTransceiver('video');awaitpc1.setLocalDescription();awaitpc2.setRemoteDescription(pc1.localDescription);awaitpc1.setRemoteDescription(awaitpc2.createAnswer());letparams=sender.getParameters();constcodecsCopy=[...params.codecs];params.codecs.pop();awaitsender.setParameters(params);params=sender.getParameters();compareCodecParams(params.codecs,codecsCopy);});},asyncfunctioncheckCodecsReordered(){awaitwithPrefs([["media.peerconnection.allow_old_setParameters",true]],async()=>{constpc1=newRTCPeerConnection();constpc2=newRTCPeerConnection();const{sender}=pc1.addTransceiver('video');awaitpc1.setLocalDescription();awaitpc2.setRemoteDescription(pc1.localDescription);awaitpc1.setRemoteDescription(awaitpc2.createAnswer());letparams=sender.getParameters();constcodecsCopy=[...params.codecs];params.codecs.reverse();awaitsender.setParameters(params);params=sender.getParameters();compareCodecParams(params.codecs,codecsCopy);});},];runNetworkTest(async()=>{for(consttestoftests){info(`Running test: ${test.name}`);awaittest();info(`Done running test: ${test.name}`);}});</script></pre></body></html>