Bug 1678484: Test-case for bug. Also, re-enable some tests that are working fine. r=mjf

Differential Revision: https://phabricator.services.mozilla.com/D98395
This commit is contained in:
Byron Campen [:bwc] 2020-12-01 22:51:10 +00:00
Родитель b5bdc07bea
Коммит 870dc9cda3
7 изменённых файлов: 58 добавлений и 8 удалений

Просмотреть файл

@ -370,6 +370,8 @@ static Maybe<NrIceCtx::NatSimulatorConfig> GetNatConfig() {
"media.peerconnection.nat_simulator.block_tcp", false);
bool block_udp = Preferences::GetBool(
"media.peerconnection.nat_simulator.block_udp", false);
int error_code_for_drop = Preferences::GetInt(
"media.peerconnection.nat_simulator.error_code_for_drop", 0);
nsAutoCString mapping_type;
(void)Preferences::GetCString(
"media.peerconnection.nat_simulator.mapping_type", mapping_type);
@ -384,6 +386,7 @@ static Maybe<NrIceCtx::NatSimulatorConfig> GetNatConfig() {
NrIceCtx::NatSimulatorConfig natConfig;
natConfig.mBlockUdp = block_udp;
natConfig.mBlockTcp = block_tcp;
natConfig.mErrorCodeForDrop = error_code_for_drop;
natConfig.mFilteringType = filtering_type;
natConfig.mMappingType = mapping_type;
return Some(natConfig);

Просмотреть файл

@ -123,16 +123,19 @@ skip-if = toolkit == 'android' # no screenshare or windowshare on android
[test_peerConnection_audioContributingSources.html]
[test_peerConnection_checkPacketDumpHook.html]
[test_peerConnection_basicAudioNATSrflx.html]
skip-if = toolkit == 'android' || (verify && (os == 'linux')) || socketprocess_e10s # websockets don't work on android (bug 1266217, IPV6 is busted in try which causes timeouts in socket process case (bug 1521117))
skip-if = toolkit == 'android' # websockets don't work on android (bug 1266217)
scheme=http
[test_peerConnection_basicAudioNATRelay.html]
skip-if = toolkit == 'android' || (verify && debug && (os == 'linux')) || socketprocess_e10s # websockets don't work on android (bug 1266217, IPV6 is busted in try which causes timeouts in socket process case (bug 1521117))
skip-if = toolkit == 'android' # websockets don't work on android (bug 1266217)
scheme=http
[test_peerConnection_basicAudioNATRelayTCP.html]
skip-if = toolkit == 'android' || socketprocess_e10s # websockets don't work on android (bug 1266217, IPV6 is busted in try which causes timeouts in socket process case (bug 1521117))
skip-if = toolkit == 'android' # websockets don't work on android (bug 1266217)
scheme=http
[test_peerConnection_basicAudioNoisyUDPBlock.html]
skip-if = toolkit == 'android' # websockets don't work on android (bug 1266217)
scheme=http
[test_peerConnection_basicAudioNATRelayTLS.html]
skip-if = true # need pyopenssl on builders, see bug 1323439 # toolkit == 'android' || socketprocess_e10s # websockets don't work on android (bug 1266217), IPV6 is busted in try which causes timeouts in socket process case (bug 1521117)
skip-if = true # need pyopenssl on builders, see bug 1323439 # toolkit == 'android' # websockets don't work on android (bug 1266217)
scheme=http
[test_peerConnection_basicAudioRequireEOC.html]
[test_peerConnection_basicAudioPcmaPcmuOnly.html]

Просмотреть файл

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection where UDP sockets return errors on send"
});
// This test uses the NAT simulator, which doesn't work in https, so we turn
// on getUserMedia in http, which requires a reload.
if (!("mediaDevices" in navigator)) {
SpecialPowers.pushPrefEnv({set: [['media.devices.insecure.enabled', true]]},
() => location.reload());
} else {
runNetworkTest(async (options = {}) => {
await pushPrefs(
['media.peerconnection.ice.obfuscate_host_addresses', false],
['media.peerconnection.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.block_udp', true],
['media.peerconnection.nat_simulator.error_code_for_drop', 3 /*R_INTERNAL*/],
['media.getusermedia.insecure.enabled', true]);
options.expectedLocalCandidateType = "relay-tcp";
options.expectedRemoteCandidateType = "relay-tcp";
// No reason to wait for gathering to complete like the other NAT tests,
// since relayed-tcp is the only thing that can work.
const test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
}, { useIceServer: true });
}
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -608,6 +608,8 @@ bool NrIceCtx::Initialize() {
TestNat::ToNatBehavior(config_.mNatSimulatorConfig->mMappingType.get());
test_nat->block_udp_ = config_.mNatSimulatorConfig->mBlockUdp;
test_nat->block_tcp_ = config_.mNatSimulatorConfig->mBlockTcp;
test_nat->error_code_for_drop_ =
config_.mNatSimulatorConfig->mErrorCodeForDrop;
test_nat->enabled_ = true;
SetNat(test_nat);
}

Просмотреть файл

@ -205,6 +205,7 @@ class NrIceCtx {
struct NatSimulatorConfig {
bool mBlockTcp = false;
bool mBlockUdp = false;
int mErrorCodeForDrop = 0;
nsCString mMappingType = "ENDPOINT_INDEPENDENT"_ns;
nsCString mFilteringType = "ENDPOINT_INDEPENDENT"_ns;
};

Просмотреть файл

@ -299,12 +299,12 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags,
if (nat_->nat_delegate_ &&
nat_->nat_delegate_->on_sendto(nat_, msg, len, flags, to)) {
return 0;
return nat_->error_code_for_drop_;
}
UCHAR* buf = static_cast<UCHAR*>(const_cast<void*>(msg));
if (nat_->block_stun_ && nr_is_stun_message(buf, len)) {
return 0;
return nat_->error_code_for_drop_;
}
/* TODO: improve the functionality of this in bug 1253657 */
@ -322,8 +322,7 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags,
destroy_stale_port_mappings();
if (to->protocol == IPPROTO_UDP && nat_->block_udp_) {
// Silently eat the packet
return 0;
return nat_->error_code_for_drop_;
}
// Choose our port mapping based on our most selective criteria

Просмотреть файл

@ -156,6 +156,7 @@ class TestNat {
block_udp_(false),
block_stun_(false),
block_tcp_(false),
error_code_for_drop_(0),
delay_stun_resp_ms_(0),
nat_delegate_(nullptr),
sockets_() {}
@ -185,6 +186,7 @@ class TestNat {
bool block_udp_;
bool block_stun_;
bool block_tcp_;
bool error_code_for_drop_;
/* Note: this can only delay a single response so far (bug 1253657) */
uint32_t delay_stun_resp_ms_;