Bug 1528031 - Update tests to work with [SecureContext] navigator.mediaDevices. r=pehrsons,smaug

Differential Revision: https://phabricator.services.mozilla.com/D35970

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan-Ivar Bruaroey 2019-06-26 18:15:50 +00:00
Родитель 4abced2ba4
Коммит 8fd4637236
7 изменённых файлов: 78 добавлений и 56 удалений

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

@ -86,9 +86,9 @@ runTest(async () => {
src = `data:text/html;base64,${btoa(source)}`;
is(await iframeGum({ src, sandbox: "allow-scripts" }),
"NotAllowedError", "gUM fails in sandboxed data iframe");
"TypeError", "navigator.mediaDevices undefined in sandboxed data iframe");
is(await iframeGum({ src, sandbox: "allow-scripts allow-same-origin"}),
"NotAllowedError", "gUM fails in regular data iframe");
"TypeError", "navigator.mediaDevices undefined in regular data iframe");
});
</script>
</pre>

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

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="nonTrickleIce.js"></script>
@ -7,18 +7,21 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT"
});
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT"
});
// This test uses the NAT simulator, which doesn't work in https, so we turn
// on getUserMedia in http.
// 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.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT'],
['media.devices.insecure.enabled', true],
['media.getusermedia.insecure.enabled', true]);
options.expectedLocalCandidateType = "srflx";
options.expectedRemoteCandidateType = "relay";
@ -35,6 +38,7 @@
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
}, { useIceServer: true });
}
</script>
</pre>
</body>

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

@ -6,19 +6,22 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT that blocks UDP"
});
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT that blocks UDP"
});
// This test uses the NAT simulator, which doesn't work in https, so we turn
// on getUserMedia in http.
// 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.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.block_udp', true],
['media.devices.insecure.enabled', true],
['media.getusermedia.insecure.enabled', true]);
options.expectedLocalCandidateType = "relay-tcp";
options.expectedRemoteCandidateType = "relay-tcp";
@ -28,6 +31,7 @@
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
}, { useIceServer: true });
}
</script>
</pre>
</body>

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

@ -6,20 +6,23 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT that blocks STUN"
});
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT that blocks STUN"
});
// This test uses the NAT simulator, which doesn't work in https, so we turn
// on getUserMedia in http.
// 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.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.block_tcp', true],
['media.devices.insecure.enabled', true],
['media.getusermedia.insecure.enabled', true]);
options.expectedLocalCandidateType = "relay-tcp";
options.expectedRemoteCandidateType = "relay-tcp";
@ -29,6 +32,7 @@
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
}, { useIceServer: true });
}
</script>
</pre>
</body>

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

@ -7,18 +7,21 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with endpoint independent NAT"
});
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with endpoint independent NAT"
});
// This test uses the NAT simulator in order to get srflx candidates.
// It doesn't work in https, so we turn on getUserMedia in http.
// 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.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT'],
['media.devices.insecure.enabled', true],
['media.getusermedia.insecure.enabled', true]);
options.expectedLocalCandidateType = "srflx";
options.expectedRemoteCandidateType = "srflx";
@ -32,6 +35,7 @@
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
}, { useIceServer: true });
}
</script>
</pre>
</body>

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

@ -7,10 +7,35 @@
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1435789",
title: "WebRTC local-candidate relayProtocol stats attribute"
});
createHTML({
bug: "1435789",
title: "WebRTC local-candidate relayProtocol stats attribute"
});
// This test uses the NAT simulator in order to get srflx candidates.
// It 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.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT'],
['media.getusermedia.insecure.enabled', true]);
const test = new PeerConnectionTest(options);
makeOffererNonTrickle(test.chain);
makeAnswererNonTrickle(test.chain);
test.chain.removeAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW");
test.chain.append([PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE]);
test.setMediaConstraints([{ audio: true }], [{ audio: true }]);
test.run();
}, { useIceServer: true });
}
var PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE = test => {
return test.pcLocal.getStats().then(stats => {
let haveRelayProtocol = {};
@ -29,25 +54,6 @@ var PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE = test => {
is(Object.keys(haveRelayProtocol).length, 4, "All candidate types are accounted for");
});
}
// This test uses the NAT simulator in order to get srflx candidates.
// It doesn't work in https, so we turn on getUserMedia in http.
runNetworkTest(async (options = {}) => {
await pushPrefs(
['media.peerconnection.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT'],
['media.devices.insecure.enabled', true],
['media.getusermedia.insecure.enabled', true]);
const test = new PeerConnectionTest(options);
makeOffererNonTrickle(test.chain);
makeAnswererNonTrickle(test.chain);
test.chain.removeAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW");
test.chain.append([PC_LOCAL_TEST_LOCAL_STATS_RELAYCANDIDATE]);
test.setMediaConstraints([{ audio: true }], [{ audio: true }]);
test.run();
}, { useIceServer: true });
</script>
</pre>
</body>

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

@ -620,9 +620,9 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaCapabilitiesInfo", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaDeviceInfo", insecureContext: true},
{name: "MediaDeviceInfo", insecureContext: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaDevices", insecureContext: true},
{name: "MediaDevices", insecureContext: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaElementAudioSourceNode", insecureContext: true},
// IMPORTANT: Do not change this list without review from a DOM peer!