зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1405083 - Fix failure paths across head.js, mediaStreamPlayback.js and pc.js. r=padenot
Prior to this patch various failure paths, e.g., runTest() from mediaStreamPlayback.js would call SimpleTest.finish() twice. This patch fixes this so no path will call finish only on failure (and not on success) to make responsibilities clear. This applies to PeerConnectionTest.run and runTestWhenReady. runTestWhenReady will be in charge of calling finish for all paths through the test framework. Its callers runTest and runNetworkTest will stop calling finish. The responsibility for calling networkTestFinished is moved from PeerConnectionTest.run to runNetworkTest since the latter calls startNetworkAndTest which is the analogous start function. At the same time, networkTestFinished stops calling through to finish since that is now the responsibility of runTestWhenReady. All users of the relevant APIs are updated to comply. In many cases related code is modernized and cleaned up to support the new pattern and to improve readability. Differential Revision: https://phabricator.services.mozilla.com/D110405
This commit is contained in:
Родитель
ee9dab6aa9
Коммит
b412b5715d
|
@ -175,8 +175,6 @@ runTestWhenReady(async () => {
|
|||
|
||||
await videoReady;
|
||||
info("Video content ok");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -2,86 +2,79 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
||||
<script>
|
||||
createHTML({
|
||||
title: "Parallel MTG by setting AudioContextParam sample rate",
|
||||
bug: "1387454",
|
||||
visible: true
|
||||
});
|
||||
createHTML({
|
||||
title: "Parallel MTG by setting AudioContextParam sample rate",
|
||||
bug: "1387454",
|
||||
visible: true
|
||||
});
|
||||
|
||||
scriptsReady
|
||||
.then(() => FAKE_ENABLED = false)
|
||||
.then(() => runTestWhenReady( async () => {
|
||||
// Test an AudioContext of specific sample rate.
|
||||
// Verify that the oscillator produces a tone.
|
||||
let rate1 = 500;
|
||||
let ac1 = new AudioContext({sampleRate: 44100});
|
||||
let dest_ac1 = ac1.createMediaStreamDestination();
|
||||
let osc_ac1 = ac1.createOscillator();
|
||||
osc_ac1.frequency.value = rate1;
|
||||
osc_ac1.connect(dest_ac1);
|
||||
osc_ac1.start(0);
|
||||
runTest(async () => {
|
||||
// Test an AudioContext of specific sample rate.
|
||||
// Verify that the oscillator produces a tone.
|
||||
const rate1 = 500;
|
||||
const ac1 = new AudioContext({sampleRate: 44100});
|
||||
const dest_ac1 = ac1.createMediaStreamDestination();
|
||||
const osc_ac1 = ac1.createOscillator();
|
||||
osc_ac1.frequency.value = rate1;
|
||||
osc_ac1.connect(dest_ac1);
|
||||
osc_ac1.start(0);
|
||||
|
||||
let analyser = new AudioStreamAnalyser(ac1, dest_ac1.stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq_rate1 = array[analyser.binIndexForFrequency(rate1)];
|
||||
const freq_4000Hz = array[analyser.binIndexForFrequency(4000)];
|
||||
const analyser = new AudioStreamAnalyser(ac1, dest_ac1.stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq_rate1 = array[analyser.binIndexForFrequency(rate1)];
|
||||
const freq_4000Hz = array[analyser.binIndexForFrequency(4000)];
|
||||
|
||||
info("Analysing audio frequency - low:target1:high = "
|
||||
+ freg_50Hz + ':' + freq_rate1 + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq_rate1 > 200 && freq_4000Hz < 50;
|
||||
})
|
||||
osc_ac1.stop();
|
||||
info("Analysing audio frequency - low:target1:high = "
|
||||
+ freg_50Hz + ':' + freq_rate1 + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq_rate1 > 200 && freq_4000Hz < 50;
|
||||
})
|
||||
osc_ac1.stop();
|
||||
|
||||
// Same test using a new AudioContext of different sample rate.
|
||||
let rate2 = 1500;
|
||||
let ac2 = new AudioContext({sampleRate: 48000});
|
||||
let dest_ac2 = ac2.createMediaStreamDestination();
|
||||
let osc_ac2 = ac2.createOscillator();
|
||||
osc_ac2.frequency.value = rate2;
|
||||
osc_ac2.connect(dest_ac2);
|
||||
osc_ac2.start(0);
|
||||
// Same test using a new AudioContext of different sample rate.
|
||||
const rate2 = 1500;
|
||||
const ac2 = new AudioContext({sampleRate: 48000});
|
||||
const dest_ac2 = ac2.createMediaStreamDestination();
|
||||
const osc_ac2 = ac2.createOscillator();
|
||||
osc_ac2.frequency.value = rate2;
|
||||
osc_ac2.connect(dest_ac2);
|
||||
osc_ac2.start(0);
|
||||
|
||||
let analyser2 = new AudioStreamAnalyser(ac2, dest_ac2.stream);
|
||||
analyser2.enableDebugCanvas();
|
||||
await analyser2.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser2.binIndexForFrequency(50)];
|
||||
const freq_rate2 = array[analyser2.binIndexForFrequency(rate2)];
|
||||
const freq_4000Hz = array[analyser2.binIndexForFrequency(4000)];
|
||||
const analyser2 = new AudioStreamAnalyser(ac2, dest_ac2.stream);
|
||||
analyser2.enableDebugCanvas();
|
||||
await analyser2.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser2.binIndexForFrequency(50)];
|
||||
const freq_rate2 = array[analyser2.binIndexForFrequency(rate2)];
|
||||
const freq_4000Hz = array[analyser2.binIndexForFrequency(4000)];
|
||||
|
||||
info("Analysing audio frequency - low:target2:high = "
|
||||
+ freg_50Hz + ':' + freq_rate2 + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq_rate2 > 200 && freq_4000Hz < 50;
|
||||
})
|
||||
osc_ac2.stop();
|
||||
info("Analysing audio frequency - low:target2:high = "
|
||||
+ freg_50Hz + ':' + freq_rate2 + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq_rate2 > 200 && freq_4000Hz < 50;
|
||||
})
|
||||
osc_ac2.stop();
|
||||
|
||||
// Two AudioContexts with different sample rate cannot communicate.
|
||||
mustThrowWith("Connect nodes with different sample rate", "NotSupportedError",
|
||||
() => {let source_ac2 = ac2.createMediaStreamSource(dest_ac1.stream)});
|
||||
// Two AudioContexts with different sample rate cannot communicate.
|
||||
mustThrowWith("Connect nodes with different sample rate", "NotSupportedError",
|
||||
() => ac2.createMediaStreamSource(dest_ac1.stream));
|
||||
|
||||
// Two AudioContext with the same sample rate can communicate.
|
||||
let ac3 = new AudioContext({sampleRate: 48000});
|
||||
let dest_ac3 = ac3.createMediaStreamDestination();
|
||||
let source_ac2 = ac2.createMediaStreamSource(dest_ac3.stream);
|
||||
ok(true, "Connect nodes with the same sample rate is ok");
|
||||
// Two AudioContext with the same sample rate can communicate.
|
||||
const ac3 = new AudioContext({sampleRate: 48000});
|
||||
const dest_ac3 = ac3.createMediaStreamDestination();
|
||||
const source_ac2 = ac2.createMediaStreamSource(dest_ac3.stream);
|
||||
ok(true, "Connect nodes with the same sample rate is ok");
|
||||
|
||||
expectException(function() {
|
||||
new AudioContext({sampleRate: 0});
|
||||
}, DOMException.NOT_SUPPORTED_ERR);
|
||||
mustThrowWith("Invalid zero samplerate", "NotSupportedError",
|
||||
() => new AudioContext({sampleRate: 0}));
|
||||
|
||||
expectException(function() {
|
||||
new AudioContext({sampleRate: -1});
|
||||
}, DOMException.NOT_SUPPORTED_ERR);
|
||||
|
||||
}))
|
||||
.then(() => finish())
|
||||
mustThrowWith("Invalid negative samplerate", "NotSupportedError",
|
||||
() => new AudioContext({sampleRate: -1}));
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -7,48 +7,45 @@
|
|||
<pre id="test">
|
||||
|
||||
<script>
|
||||
(async function() {
|
||||
createHTML({
|
||||
title: "Check tab muting when the tab plays audio via the Web Audio API",
|
||||
bug: "1346880",
|
||||
visible: false
|
||||
});
|
||||
|
||||
await createHTML({
|
||||
title: "Check tab muting when the tab plays audio via the Web Audio API",
|
||||
bug: "1346880",
|
||||
visible: false
|
||||
});
|
||||
/**
|
||||
* Check that muting a tab results in no audible audio: mute a tab, in which
|
||||
* an OscillatorNode is playing. The default audio output device is a
|
||||
* pulseaudio null-sink. Simulateously, record the other side of the null
|
||||
* sink, and check that no audio has been written to the sink, because the tab
|
||||
* was muted. Then, umute the tab and check that audio is being sent to the
|
||||
* null-sink. */
|
||||
await runTestWhenReady(async () => {
|
||||
let audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev", "");
|
||||
if (!audioDevice) {
|
||||
todo(false, "No loopback device set by framework. Try --use-test-media-devices");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Check that muting a tab results in no audible audio: mute a tab, in which
|
||||
* an OscillatorNode is playing. The default audio output device is a
|
||||
* pulseaudio null-sink. Simulateously, record the other side of the null
|
||||
* sink, and check that no audio has been written to the sink, because the tab
|
||||
* was muted. Then, umute the tab and check that audio is being sent to the
|
||||
* null-sink. */
|
||||
runTest(async () => {
|
||||
if (!SpecialPowers.getCharPref("media.audio_loopback_dev", "")) {
|
||||
todo(false, "No loopback device set by framework. Try --use-test-media-devices");
|
||||
return;
|
||||
}
|
||||
|
||||
// Mute the tab
|
||||
await SpecialPowers.toggleMuteState(true, window.top);
|
||||
// Don't use a loopback tone, the loopback device is here to check that
|
||||
// nothing is output because the tab is muted.
|
||||
DISABLE_LOOPBACK_TONE = true;
|
||||
// Mute the tab
|
||||
await SpecialPowers.toggleMuteState(true, window.top);
|
||||
// Don't use a loopback tone, the loopback device is here to check that
|
||||
// nothing is output because the tab is muted.
|
||||
DISABLE_LOOPBACK_TONE = true;
|
||||
|
||||
let stream = await getUserMedia({audio: true});
|
||||
|
||||
let ac = new AudioContext();
|
||||
|
||||
let osc = new OscillatorNode(ac);
|
||||
const stream = await getUserMedia({audio: true});
|
||||
try {
|
||||
const ac = new AudioContext();
|
||||
const osc = new OscillatorNode(ac);
|
||||
osc.connect(ac.destination);
|
||||
osc.start();
|
||||
|
||||
let analyser = new AudioStreamAnalyser(ac, stream);
|
||||
const analyser = new AudioStreamAnalyser(ac, stream);
|
||||
// Wait for some time, checking there is only ever silent audio in the
|
||||
// loopback stream. `waitForAnalysisSuccess` runs off requestAnimationFrame
|
||||
let silenceFor = 3 / (1 / 60);
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
// `array` has values between 0 and 255, 0 being silence.
|
||||
let sum = array.reduce((acc, v) => { return acc + v; });
|
||||
const sum = array.reduce((acc, v) => { return acc + v; });
|
||||
if (sum == 0) {
|
||||
silenceFor--;
|
||||
} else {
|
||||
|
@ -67,7 +64,7 @@
|
|||
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
// `array` has values between 0 and 255, 0 being silence.
|
||||
let sum = array.reduce((acc, v) => { return acc + v; });
|
||||
const sum = array.reduce((acc, v) => { return acc + v; });
|
||||
if (sum != 0) {
|
||||
info(`Sum after unmuting ${sum}`);
|
||||
ok(true, "Unmuting the tab was effective");
|
||||
|
@ -82,10 +79,12 @@
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
finish()
|
||||
})();
|
||||
} finally {
|
||||
for (let t of stream.getTracks()) {
|
||||
t.stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -467,21 +467,23 @@ function setupEnvironment() {
|
|||
SpecialPowers.exactGC();
|
||||
}
|
||||
|
||||
function runTestWhenReady(testFunc) {
|
||||
async function runTestWhenReady(testFunc) {
|
||||
setupEnvironment();
|
||||
return testConfigured
|
||||
.then(options => testFunc(options))
|
||||
.catch(e => {
|
||||
ok(
|
||||
false,
|
||||
"Error executing test: " +
|
||||
e +
|
||||
(typeof e.stack === "string"
|
||||
? " " + e.stack.split("\n").join(" ... ")
|
||||
: "")
|
||||
);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
const options = await testConfigured;
|
||||
try {
|
||||
await testFunc(options);
|
||||
} catch (e) {
|
||||
ok(
|
||||
false,
|
||||
"Error executing test: " +
|
||||
e +
|
||||
(typeof e.stack === "string"
|
||||
? " " + e.stack.split("\n").join(" ... ")
|
||||
: "")
|
||||
);
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,5 +75,5 @@ function identityPcTest(remoteOptions) {
|
|||
]);
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ runNetworkTest(async () => {
|
|||
pcStrict.close();
|
||||
pcDouble.close();
|
||||
track.stop();
|
||||
networkTestFinished();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -91,7 +91,7 @@ function theTest() {
|
|||
.then(a => checkIdentity(a, 'user@example.com'));
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
}
|
||||
runNetworkTest(theTest);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ function theTest() {
|
|||
});
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
}
|
||||
runNetworkTest(theTest);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ function theTest() {
|
|||
// Override the remote media capture options to remove isolation for the
|
||||
// remote party; the test verifies that the media it receives on the local
|
||||
// side is isolated anyway.
|
||||
identityPcTest({
|
||||
return identityPcTest({
|
||||
audio: true,
|
||||
video: true
|
||||
});
|
||||
|
|
|
@ -57,7 +57,7 @@ function theTest() {
|
|||
"a=identity is in the remote copy of the answer");
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
}
|
||||
runNetworkTest(theTest);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ runNetworkTest(function () {
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -186,6 +186,14 @@ function createHTML(options) {
|
|||
return scriptsReady.then(() => realCreateHTML(options));
|
||||
}
|
||||
|
||||
async function runTest(testFunction) {
|
||||
await scriptsReady;
|
||||
await runTestWhenReady(async (...args) => {
|
||||
await testFunction(...args);
|
||||
await noGum();
|
||||
});
|
||||
}
|
||||
|
||||
// noGum - Helper to detect whether active guM tracks still exist.
|
||||
//
|
||||
// It relies on the fact that, by spec, device labels from enumerateDevices are
|
||||
|
@ -193,22 +201,17 @@ function createHTML(options) {
|
|||
// permissions are granted, so turn off media.navigator.permission.disabled
|
||||
// (which is normally on otherwise in our tests). Lastly, we must turn on
|
||||
// media.navigator.permission.fake otherwise fake devices don't count as active.
|
||||
|
||||
var noGum = () =>
|
||||
pushPrefs(
|
||||
async function noGum() {
|
||||
await pushPrefs(
|
||||
["media.navigator.permission.disabled", false],
|
||||
["media.navigator.permission.fake", true],
|
||||
["media.devices.insecure.enabled", true]
|
||||
)
|
||||
.then(() => navigator.mediaDevices.enumerateDevices())
|
||||
.then(
|
||||
([device]) =>
|
||||
device &&
|
||||
is(device.label, "", "Test must leave no active gUM streams behind.")
|
||||
);
|
||||
|
||||
var runTest = testFunction =>
|
||||
scriptsReady
|
||||
.then(() => runTestWhenReady(testFunction))
|
||||
.then(() => noGum())
|
||||
.then(() => finish());
|
||||
["media.navigator.permission.fake", true]
|
||||
);
|
||||
if (!navigator.mediaDevices) {
|
||||
// No mediaDevices, then gUM cannot have been called either.
|
||||
return;
|
||||
}
|
||||
const [device] = await navigator.mediaDevices.enumerateDevices();
|
||||
if (device) {
|
||||
is(device.label, "", "Test must leave no active gUM streams behind.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
* A stub function for preparing the network if needed
|
||||
*
|
||||
*/
|
||||
function startNetworkAndTest() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
async function startNetworkAndTest() {}
|
||||
|
||||
/**
|
||||
* A stub function to shutdown the network if needed
|
||||
*/
|
||||
function networkTestFinished() {
|
||||
return Promise.resolve().then(() => finish());
|
||||
}
|
||||
async function networkTestFinished() {}
|
||||
|
|
|
@ -548,32 +548,20 @@ PeerConnectionTest.prototype.updateChainSteps = function() {
|
|||
/**
|
||||
* Start running the tests as assigned to the command chain.
|
||||
*/
|
||||
PeerConnectionTest.prototype.run = function() {
|
||||
PeerConnectionTest.prototype.run = async function() {
|
||||
/* We have to modify the chain here to allow tests which modify the default
|
||||
* test chain instantiating a PeerConnectionTest() */
|
||||
this.updateChainSteps();
|
||||
var finished = () => {
|
||||
if (window.SimpleTest) {
|
||||
networkTestFinished();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
return this.chain
|
||||
.execute()
|
||||
.then(() => this.close())
|
||||
.catch(e =>
|
||||
ok(
|
||||
false,
|
||||
"Error in test execution: " +
|
||||
e +
|
||||
(typeof e.stack === "string"
|
||||
? " " + e.stack.split("\n").join(" ... ")
|
||||
: "")
|
||||
)
|
||||
)
|
||||
.then(() => finished())
|
||||
.catch(e => ok(false, "Error in finished()"));
|
||||
try {
|
||||
await this.chain.execute();
|
||||
await this.close();
|
||||
} catch (e) {
|
||||
const stack =
|
||||
typeof e.stack === "string"
|
||||
? ` ${e.stack.split("\n").join(" ... ")}`
|
||||
: "";
|
||||
ok(false, `Error in test execution: ${e} (${stack})`);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2415,7 +2403,6 @@ function loadScript(...scripts) {
|
|||
// Ensure SimpleTest.js is loaded before other scripts.
|
||||
var scriptsReady = loadScript("/tests/SimpleTest/SimpleTest.js").then(() => {
|
||||
return loadScript(
|
||||
"../../../test/manifest.js",
|
||||
"head.js",
|
||||
"templates.js",
|
||||
"turnConfig.js",
|
||||
|
@ -2535,5 +2522,6 @@ async function runNetworkTest(testFunction, fixtureOptions = {}) {
|
|||
});
|
||||
}
|
||||
await testFunction(options);
|
||||
await networkTestFinished();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,40 +4,29 @@
|
|||
// It is in a separate file because we have an MTG per document, and we want to
|
||||
// test multiple sample-rates, so we include it in multiple HTML mochitest
|
||||
// files.
|
||||
function test_peerconnection_audio_forced_sample_rate(forcedSampleRate) {
|
||||
scriptsReady.then(function() {
|
||||
pushPrefs(["media.cubeb.force_sample_rate", forcedSampleRate]).then(
|
||||
function() {
|
||||
runNetworkTest(function(options) {
|
||||
let test = new PeerConnectionTest(options);
|
||||
let ac = new AudioContext();
|
||||
test.setMediaConstraints(
|
||||
[
|
||||
{
|
||||
audio: true,
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
test.chain.replace("PC_LOCAL_GUM", [
|
||||
function PC_LOCAL_WEBAUDIO_SOURCE(test) {
|
||||
let oscillator = ac.createOscillator();
|
||||
oscillator.type = "sine";
|
||||
oscillator.frequency.value = 700;
|
||||
oscillator.start();
|
||||
let dest = ac.createMediaStreamDestination();
|
||||
oscillator.connect(dest);
|
||||
test.pcLocal.attachLocalStream(dest.stream);
|
||||
},
|
||||
]);
|
||||
test.chain.append([
|
||||
function CHECK_REMOTE_AUDIO_FLOW(test) {
|
||||
return test.pcRemote.checkReceivingToneFrom(ac, test.pcLocal);
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
});
|
||||
}
|
||||
);
|
||||
async function test_peerconnection_audio_forced_sample_rate(forcedSampleRate) {
|
||||
await scriptsReady;
|
||||
await pushPrefs(["media.cubeb.force_sample_rate", forcedSampleRate]);
|
||||
await runNetworkTest(function(options) {
|
||||
const test = new PeerConnectionTest(options);
|
||||
const ac = new AudioContext();
|
||||
test.setMediaConstraints([{ audio: true }], []);
|
||||
test.chain.replace("PC_LOCAL_GUM", [
|
||||
function PC_LOCAL_WEBAUDIO_SOURCE(test) {
|
||||
const oscillator = ac.createOscillator();
|
||||
oscillator.type = "sine";
|
||||
oscillator.frequency.value = 700;
|
||||
oscillator.start();
|
||||
const dest = ac.createMediaStreamDestination();
|
||||
oscillator.connect(dest);
|
||||
test.pcLocal.attachLocalStream(dest.stream);
|
||||
},
|
||||
]);
|
||||
test.chain.append([
|
||||
function CHECK_REMOTE_AUDIO_FLOW(test) {
|
||||
return test.pcRemote.checkReceivingToneFrom(ac, test.pcLocal);
|
||||
},
|
||||
]);
|
||||
return test.run();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{audio: true, video: true}],
|
||||
[{audio: true, video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ runNetworkTest(function (options) {
|
|||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
addInitialDataChannel(test.chain);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
var sld = test.chain.remove("PC_REMOTE_SET_LOCAL_DESCRIPTION");
|
||||
test.chain.insertAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION", sld);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
addInitialDataChannel(test.chain);
|
||||
test.chain.insertAfter('PC_REMOTE_CHECK_ICE_CONNECTIONS', commandsCheckLargeXfer);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -23,10 +23,7 @@
|
|||
addInitialDataChannel(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
|
||||
// This inlines test.run(), to allow for multiple tests to run.
|
||||
test.updateChainSteps();
|
||||
await test.chain.execute();
|
||||
await test.close();
|
||||
await test.run();
|
||||
}
|
||||
|
||||
runNetworkTest(async (options) => {
|
||||
|
@ -34,7 +31,6 @@
|
|||
for (var version = 770; version <= 772; version++) {
|
||||
await testDtlsVersion(options, version);
|
||||
}
|
||||
networkTestFinished();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -38,10 +38,7 @@
|
|||
});
|
||||
}]);
|
||||
|
||||
// This inlines test.run(), to allow for multiple tests to run.
|
||||
test.updateChainSteps();
|
||||
await test.chain.execute();
|
||||
await test.close();
|
||||
await test.run();
|
||||
}
|
||||
|
||||
runNetworkTest(async (options) => {
|
||||
|
@ -54,8 +51,6 @@
|
|||
await testBlocklist(options, "mochi.test", false);
|
||||
await testBlocklist(options, "example.com,mochi.test", false);
|
||||
await testBlocklist(options, "*.test", false);
|
||||
|
||||
networkTestFinished();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -11,19 +11,20 @@
|
|||
title: "Don't offer m=application unless createDataChannel is called first"
|
||||
});
|
||||
|
||||
runNetworkTest(function () {
|
||||
var pc = new RTCPeerConnection();
|
||||
runNetworkTest(async function () {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
// necessary to circumvent bug 864109
|
||||
var options = { offerToReceiveAudio: true };
|
||||
const options = { offerToReceiveAudio: true };
|
||||
|
||||
pc.createOffer(options).then(offer => {
|
||||
const errorCallback = generateErrorCallback();
|
||||
try {
|
||||
const offer = await pc.createOffer(options);
|
||||
ok(!offer.sdp.includes("m=application"),
|
||||
"m=application is not contained in the SDP");
|
||||
|
||||
networkTestFinished();
|
||||
})
|
||||
.catch(generateErrorCallback());
|
||||
} catch(e) {
|
||||
errorCallback(e);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
'DataChannel has correct messagesReceived');
|
||||
is(stats.messagesSent, 0, 'DataChannel has correct messagesSent');
|
||||
});
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -8,32 +8,31 @@
|
|||
<pre id="test">
|
||||
<script>
|
||||
|
||||
createHTML({
|
||||
bug: "1156472",
|
||||
title: "Test AudioCapture with regular HTMLMediaElement, AudioContext, and HTMLMediaElement playing a MediaStream",
|
||||
visible: true
|
||||
});
|
||||
(async () => {
|
||||
// Get an opus file containing a sine wave at maximum amplitude, of duration
|
||||
// `lengthSeconds`, and of frequency `frequency`.
|
||||
async function getSineWaveFile(frequency, lengthSeconds) {
|
||||
const off = new OfflineAudioContext(1, lengthSeconds * 48000, 48000);
|
||||
const osc = off.createOscillator();
|
||||
const rec = new MediaRecorder(off.destination,
|
||||
{mimeType: "audio/ogg; codecs=opus"});
|
||||
osc.frequency.value = frequency;
|
||||
osc.connect(off.destination);
|
||||
osc.start();
|
||||
rec.start();
|
||||
off.startRendering();
|
||||
const {data} = await new Promise(r => rec.ondataavailable = r);
|
||||
return data;
|
||||
}
|
||||
|
||||
// Get an opus file containing a sine wave at maximum amplitude, of duration
|
||||
// `lengthSeconds`, and of frequency `frequency`.
|
||||
async function getSineWaveFile(frequency, lengthSeconds) {
|
||||
const off = new OfflineAudioContext(1, lengthSeconds * 48000, 48000);
|
||||
const osc = off.createOscillator();
|
||||
const rec = new MediaRecorder(off.destination,
|
||||
{mimeType: "audio/ogg; codecs=opus"});
|
||||
osc.frequency.value = frequency;
|
||||
osc.connect(off.destination);
|
||||
osc.start();
|
||||
rec.start();
|
||||
off.startRendering();
|
||||
const {data} = await new Promise(r => rec.ondataavailable = r);
|
||||
return data;
|
||||
}
|
||||
await createHTML({
|
||||
bug: "1156472",
|
||||
title: "Test AudioCapture with regular HTMLMediaElement, AudioContext, " +
|
||||
"and HTMLMediaElement playing a MediaStream",
|
||||
visible: true
|
||||
});
|
||||
|
||||
(async function() {
|
||||
await scriptsReady;
|
||||
FAKE_ENABLED = false;
|
||||
await runTestWhenReady(async function() {
|
||||
await runTestWhenReady(async () => {
|
||||
/**
|
||||
* Get two HTMLMediaElements:
|
||||
* - One playing a sine tone from a blob (of an opus file created on the fly)
|
||||
|
@ -77,26 +76,28 @@ async function getSineWaveFile(frequency, lengthSeconds) {
|
|||
const constraints = {audio: {mediaSource: "audioCapture"}};
|
||||
|
||||
const stream = await getUserMedia(constraints);
|
||||
window.grip = stream;
|
||||
const analyser = new AudioStreamAnalyser(ac, stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
// We want to find three frequency components here, around 1000, 5000
|
||||
// and 10000Hz. Frequency are logarithmic. Also make sure we have low
|
||||
// energy in between, not just a flat white noise.
|
||||
return (array[analyser.binIndexForFrequency(50)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(1000)] > 200 &&
|
||||
array[analyser.binIndexForFrequency(2500)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(5000)] > 200 &&
|
||||
array[analyser.binIndexForFrequency(7500)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(10000)] > 200);
|
||||
});
|
||||
finish();
|
||||
try {
|
||||
const analyser = new AudioStreamAnalyser(ac, stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
// We want to find three frequency components here, around 1000, 5000
|
||||
// and 10000Hz. Frequency are logarithmic. Also make sure we have low
|
||||
// energy in between, not just a flat white noise.
|
||||
return (array[analyser.binIndexForFrequency(50)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(1000)] > 200 &&
|
||||
array[analyser.binIndexForFrequency(2500)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(5000)] > 200 &&
|
||||
array[analyser.binIndexForFrequency(7500)] < 50 &&
|
||||
array[analyser.binIndexForFrequency(10000)] > 200);
|
||||
});
|
||||
} finally {
|
||||
for (let t of stream.getTracks()) {
|
||||
t.stop();
|
||||
}
|
||||
ac.close();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -12,82 +12,87 @@
|
|||
bug: "1406350",
|
||||
visible: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Run a test to verify the use of LoopbackTone as audio input.
|
||||
*/
|
||||
scriptsReady.then(() => runTestWhenReady(async () => {
|
||||
let audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev", "");
|
||||
if (!audioDevice) {
|
||||
runTest(async () => {
|
||||
if (!SpecialPowers.getCharPref("media.audio_loopback_dev", "")) {
|
||||
todo(false, "No loopback device set by framework. Try --use-test-media-devices");
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point DefaultLoopbackTone has been instantiated
|
||||
// automatically on frequency TEST_AUDIO_FREQ (440 Hz). Verify
|
||||
// that a tone is detected on that frequency.
|
||||
info("Capturing at default frequency");
|
||||
let stream = await getUserMedia({audio: true});
|
||||
const stream = await getUserMedia({audio: true});
|
||||
|
||||
let audioContext = new AudioContext();
|
||||
let analyser = new AudioStreamAnalyser(audioContext, stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
// High energy on 1000 Hz low energy around that
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
try {
|
||||
const audioContext = new AudioContext();
|
||||
const analyser = new AudioStreamAnalyser(audioContext, stream);
|
||||
analyser.enableDebugCanvas();
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
// High energy on 1000 Hz low energy around that
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz < 50;
|
||||
})
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz < 50;
|
||||
});
|
||||
|
||||
// Use the LoopbackTone API to change the frequency of the default tone.
|
||||
// Verify that a tone is detected on the new frequency (800 Hz).
|
||||
info("Change loopback tone frequency");
|
||||
DefaultLoopbackTone.changeFrequency(800);
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(800)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
// Use the LoopbackTone API to change the frequency of the default tone.
|
||||
// Verify that a tone is detected on the new frequency (800 Hz).
|
||||
info("Change loopback tone frequency");
|
||||
DefaultLoopbackTone.changeFrequency(800);
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(800)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz < 50;
|
||||
})
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz < 50;
|
||||
});
|
||||
|
||||
// Create a second tone at a different frequency.
|
||||
// Verify that both tones are detected.
|
||||
info("Multiple loopback tones");
|
||||
DefaultLoopbackTone.changeFrequency(TEST_AUDIO_FREQ);
|
||||
let second_tone = new LoopbackTone(audioContext, 2000);
|
||||
second_tone.start();
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
const freq_4000Hz = array[analyser.binIndexForFrequency(4000)];
|
||||
// Create a second tone at a different frequency.
|
||||
// Verify that both tones are detected.
|
||||
info("Multiple loopback tones");
|
||||
DefaultLoopbackTone.changeFrequency(TEST_AUDIO_FREQ);
|
||||
const second_tone = new LoopbackTone(audioContext, 2000);
|
||||
second_tone.start();
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
const freq_4000Hz = array[analyser.binIndexForFrequency(4000)];
|
||||
|
||||
info("Analysing audio frequency - low:target1:target2:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz > 200 && freq_4000Hz < 50;
|
||||
})
|
||||
info("Analysing audio frequency - low:target1:target2:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz + ':' + freq_4000Hz);
|
||||
return freg_50Hz < 50 && freq > 200 && freq_2000Hz > 200 && freq_4000Hz < 50;
|
||||
});
|
||||
|
||||
// Stop all tones and verify that there is no audio on the given frequencies.
|
||||
info("Stop all loopback tones");
|
||||
DefaultLoopbackTone.stop();
|
||||
second_tone.stop()
|
||||
await analyser.waitForAnalysisSuccess( array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
// Stop all tones and verify that there is no audio on the given frequencies.
|
||||
info("Stop all loopback tones");
|
||||
DefaultLoopbackTone.stop();
|
||||
second_tone.stop()
|
||||
await analyser.waitForAnalysisSuccess(array => {
|
||||
const freg_50Hz = array[analyser.binIndexForFrequency(50)];
|
||||
const freq = array[analyser.binIndexForFrequency(TEST_AUDIO_FREQ)];
|
||||
const freq_2000Hz = array[analyser.binIndexForFrequency(2000)];
|
||||
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq < 50 && freq_2000Hz < 50;
|
||||
})
|
||||
}))
|
||||
.then(() => finish())
|
||||
info("Analysing audio frequency - low:target:high = "
|
||||
+ freg_50Hz + ':' + freq + ':' + freq_2000Hz);
|
||||
return freg_50Hz < 50 && freq < 50 && freq_2000Hz < 50;
|
||||
});
|
||||
} finally {
|
||||
for (let t of stream.getTracks()) {
|
||||
t.stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -13,18 +13,19 @@
|
|||
visible: true,
|
||||
});
|
||||
|
||||
let verifyScreenshare = async (video, helper, upleft, upright, downleft, downright) => {
|
||||
const verifyScreenshare =
|
||||
async (video, helper, upleft, upright, downleft, downright) => {
|
||||
if (video.readyState < video.HAVE_CURRENT_DATA) {
|
||||
info("Waiting for data");
|
||||
await new Promise(r => video.addEventListener("loadeddata", r, {once: true}));
|
||||
await new Promise(r => video.onloadeddata = r);
|
||||
}
|
||||
|
||||
// We assume video size will not change. Offsets help to account for a
|
||||
// square fullscreen-canvas, while the screen is rectangular.
|
||||
let offsetX = Math.max(0, video.videoWidth - video.videoHeight) / 2;
|
||||
let offsetY = Math.max(0, video.videoHeight - video.videoWidth) / 2;
|
||||
const offsetX = Math.max(0, video.videoWidth - video.videoHeight) / 2;
|
||||
const offsetY = Math.max(0, video.videoHeight - video.videoWidth) / 2;
|
||||
|
||||
let verifyAround = async (internalX, internalY, color) => {
|
||||
const verifyAround = async (internalX, internalY, color) => {
|
||||
// Pick a couple of samples around a coordinate to check for a color.
|
||||
// We check multiple rows and columns, to avoid most artifact issues.
|
||||
let areaSamples = [
|
||||
|
@ -33,21 +34,20 @@
|
|||
{dx: 8, dy: 5},
|
||||
];
|
||||
for (let {dx, dy} of areaSamples) {
|
||||
let x = offsetX + dx + internalX;
|
||||
let y = offsetY + dy + internalY;
|
||||
info("Checking screen coordinate (" + [x,y] + ") of total resolution "
|
||||
+ video.videoWidth + "x" + video.videoHeight
|
||||
+ " against " + color.name + ".");
|
||||
const x = offsetX + dx + internalX;
|
||||
const y = offsetY + dy + internalY;
|
||||
info(`Checking screen coordinate (${[x,y]}) of total resolution `
|
||||
+ `${video.videoWidth}x${video.videoHeight} against ${color.name}.`);
|
||||
await helper.waitForPixel(video, px => {
|
||||
let result = helper.isPixel(px, color, 16);
|
||||
info("Checking pixel against " + color.name + ". Got ["
|
||||
+ Array.from(px) + "] (" + (result ? "YES" : "NO") + ")");
|
||||
info(`Checking pixel against ${color.name}. Got [${Array.from(px)}` +
|
||||
`] (${(result ? "YES" : "NO")})`);
|
||||
return result;
|
||||
}, {offsetX: x, offsetY: y});
|
||||
}
|
||||
};
|
||||
|
||||
let screenSizeSq = Math.min(video.videoWidth, video.videoHeight);
|
||||
const screenSizeSq = Math.min(video.videoWidth, video.videoHeight);
|
||||
|
||||
info("Waiting for upper left quadrant to become " + upleft.name);
|
||||
await verifyAround(screenSizeSq / 4, screenSizeSq / 4, upleft);
|
||||
|
@ -74,18 +74,18 @@
|
|||
["full-screen-api.transition-duration.leave", "0 0"],
|
||||
);
|
||||
|
||||
let testVideo = createMediaElement('video', 'testVideo');
|
||||
const testVideo = createMediaElement('video', 'testVideo');
|
||||
|
||||
let canvas = document.createElement("canvas");
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = canvas.height = 20;
|
||||
document.getElementById("content").appendChild(canvas);
|
||||
let draw = (upleft, upright, downleft, downright) => {
|
||||
helper.drawColor(canvas, upleft, {offsetX: 0, offsetY: 0});
|
||||
helper.drawColor(canvas, upright, {offsetX: 10, offsetY: 0});
|
||||
helper.drawColor(canvas, downleft, {offsetX: 0, offsetY: 10});
|
||||
helper.drawColor(canvas, downright, {offsetX: 10, offsetY: 10});
|
||||
const draw = ([upleft, upright, downleft, downright]) => {
|
||||
helper.drawColor(canvas, helper[upleft], {offsetX: 0, offsetY: 0});
|
||||
helper.drawColor(canvas, helper[upright], {offsetX: 10, offsetY: 0});
|
||||
helper.drawColor(canvas, helper[downleft], {offsetX: 0, offsetY: 10});
|
||||
helper.drawColor(canvas, helper[downright], {offsetX: 10, offsetY: 10});
|
||||
};
|
||||
let helper = new CaptureStreamTestHelper2D(1, 1);
|
||||
const helper = new CaptureStreamTestHelper2D(1, 1);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
SpecialPowers.wrap(document).onfullscreenchange = resolve;
|
||||
|
@ -113,8 +113,8 @@
|
|||
"Width setting should match video width");
|
||||
is(settings.height, testVideo.videoHeight,
|
||||
"Height setting should match video height");
|
||||
let screenWidth = testVideo.videoWidth;
|
||||
let screenHeight = testVideo.videoHeight;
|
||||
const screenWidth = testVideo.videoWidth;
|
||||
const screenHeight = testVideo.videoHeight;
|
||||
await verifyScreenshare(testVideo, helper,
|
||||
helper.red, helper.blue,
|
||||
helper.green, helper.grey);
|
||||
|
@ -168,7 +168,7 @@
|
|||
helper.grey, helper.blue);
|
||||
|
||||
info("Testing modifying screenshare with applyConstraints");
|
||||
let resize = haveEvent(testVideo, "resize", wait(5000, new Error("Timeout")));
|
||||
const resize = haveEvent(testVideo, "resize", wait(5000, new Error("Timeout")));
|
||||
await testVideo.srcObject.getVideoTracks()[0].applyConstraints({
|
||||
mediaSource: 'screen',
|
||||
width: 200,
|
||||
|
@ -181,7 +181,7 @@
|
|||
// getSettings() should report correct size as soon as applyConstraints()
|
||||
// resolves - bug 1453259. Until fixed, check that we at least report
|
||||
// something sane.
|
||||
let newSettings = stream.getTracks()[0].getSettings();
|
||||
const newSettings = stream.getTracks()[0].getSettings();
|
||||
ok(newSettings.width > settings.width && newSettings.width < screenWidth,
|
||||
`Width setting ${newSettings.width} should have increased after applyConstraints`);
|
||||
ok(newSettings.height > settings.height && newSettings.height < screenHeight,
|
||||
|
|
|
@ -6,22 +6,31 @@
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({ title: "getUserMedia feed to a graph with non default rate", bug: "1387454" });
|
||||
createHTML({
|
||||
title: "getUserMedia feed to a graph with non default rate",
|
||||
bug: "1387454",
|
||||
});
|
||||
|
||||
/**
|
||||
* Run a test to verify that when we use the streem from a gUM to an AudioContext
|
||||
* with non default rate the connection fails. (gUM is always on default rate).
|
||||
*/
|
||||
scriptsReady.then(() => runTestWhenReady(async () => {
|
||||
runTest(async () => {
|
||||
// Since we do not examine the stream we do not need loopback.
|
||||
DISABLE_LOOPBACK_TONE = true;
|
||||
let stream = await getUserMedia({audio: true});
|
||||
const stream = await getUserMedia({audio: true});
|
||||
const nonDefaultRate = 32000;
|
||||
let ac = new AudioContext({sampleRate: nonDefaultRate});
|
||||
mustThrowWith("Connect stream with graph of different sample rate", "NotSupportedError", () => {
|
||||
let source = ac.createMediaStreamSource(stream);
|
||||
});
|
||||
}))
|
||||
.then(() => finish())
|
||||
const ac = new AudioContext({sampleRate: nonDefaultRate});
|
||||
mustThrowWith(
|
||||
"Connect stream with graph of different sample rate",
|
||||
"NotSupportedError", () => {
|
||||
ac.createMediaStreamSource(stream);
|
||||
}
|
||||
);
|
||||
for (let t of stream.getTracks()) {
|
||||
t.stop();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
runNetworkTest(function (options) {
|
||||
SimpleTest.requestCompleteLog();
|
||||
var test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.chain.replace("PC_LOCAL_GUM",
|
||||
[
|
||||
function PC_LOCAL_GUM_ATTACH_VIDEO_ONLY(test) {
|
||||
|
@ -47,7 +47,7 @@
|
|||
]
|
||||
);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
title: "Renegotiation: add DataChannel"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
addRenegotiation(test.chain,
|
||||
commandsCreateDataChannel,
|
||||
commandsCheckDataChannel);
|
||||
|
@ -25,7 +24,7 @@
|
|||
1);
|
||||
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
title: "Renegotiation: add DataChannel"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
options = options || { };
|
||||
options.bundle = false;
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
addRenegotiation(test.chain,
|
||||
commandsCreateDataChannel.concat(
|
||||
[
|
||||
|
@ -36,7 +35,7 @@
|
|||
1);
|
||||
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
);
|
||||
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
// TODO(bug 1093835): figure out how to verify if media flows through the new stream
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
);
|
||||
|
||||
test.setMediaConstraints([{video: true, fake: true}], [{video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
);
|
||||
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -67,7 +67,7 @@ runNetworkTest(function (options) {
|
|||
);
|
||||
|
||||
test.setMediaConstraints([{audio: true, video: true}], []);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
title: "Renegotiation: answerer adds second audio stream"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
addRenegotiationAnswerer(test.chain,
|
||||
[
|
||||
function PC_LOCAL_ADD_SECOND_STREAM(test) {
|
||||
|
@ -25,7 +24,7 @@
|
|||
);
|
||||
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -61,10 +61,7 @@
|
|||
},
|
||||
]);
|
||||
|
||||
// This inlines test.run(), to allow for multiple tests to run.
|
||||
test.updateChainSteps();
|
||||
await test.chain.execute();
|
||||
await test.close();
|
||||
await test.run();
|
||||
}
|
||||
|
||||
runNetworkTest(async (options) => {
|
||||
|
@ -77,8 +74,6 @@
|
|||
}
|
||||
info(`Tested audio for codec ${codec}`);
|
||||
}
|
||||
|
||||
networkTestFinished();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -129,16 +129,14 @@
|
|||
};
|
||||
|
||||
var test;
|
||||
runNetworkTest(function(options) {
|
||||
runNetworkTest(async function(options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW",
|
||||
[testGetContributingSources]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.pcLocal.audioElementsOnly = true;
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["privacy.reduceTimerPrecision", false]]}, function() {
|
||||
test.run();
|
||||
});
|
||||
await pushPrefs(["privacy.reduceTimerPrecision", false]);
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -12,13 +12,12 @@
|
|||
title: "Renegotiation: answerer uses a=inactive for audio"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
var helper = new AudioStreamHelper();
|
||||
const helper = new AudioStreamHelper();
|
||||
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}], []);
|
||||
var haveFirstUnmuteEvent;
|
||||
let haveFirstUnmuteEvent;
|
||||
|
||||
test.chain.insertBefore("PC_REMOTE_SET_LOCAL_DESCRIPTION", [
|
||||
function PC_REMOTE_SETUP_ONUNMUTE_1() {
|
||||
|
@ -61,7 +60,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
testSynchronizationSourceCached]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.pcLocal.audioElementsOnly = true;
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
[testGetSynchronizationSourcesUnidirectional]);
|
||||
test.setMediaConstraints([{audio: true}], []);
|
||||
test.pcLocal.audioElementsOnly = true;
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
// pc.js uses video elements by default, we want to test audio elements here
|
||||
test.pcLocal.audioElementsOnly = true;
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
}
|
||||
]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -38,7 +38,7 @@ if (!("mediaDevices" in navigator)) {
|
|||
makeOffererNonTrickle(test.chain);
|
||||
makeAnswererNonTrickle(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
}, { useIceServer: true });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -32,7 +32,7 @@ if (!("mediaDevices" in navigator)) {
|
|||
// since relayed-tcp is the only thing that can work.
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
}, { useIceServer: true });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -31,7 +31,7 @@ if (!("mediaDevices" in navigator)) {
|
|||
// since relayed-tcp is the only thing that can work.
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
}, { useIceServer: true });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -35,7 +35,7 @@ if (!("mediaDevices" in navigator)) {
|
|||
makeOffererNonTrickle(test.chain);
|
||||
makeAnswererNonTrickle(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
}, { useIceServer: true });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -31,7 +31,7 @@ if (!("mediaDevices" in navigator)) {
|
|||
// since relayed-tcp is the only thing that can work.
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
}, { useIceServer: true });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
}
|
||||
]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true, video: true}],
|
||||
[{audio: true, video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
var test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
]);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
]);
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
], 0 // first occurance
|
||||
);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "1437366",
|
||||
title: "Basic audio-only peer connection, with the MTG running at a rate not supported by the MediaPipeline (49000Hz)"
|
||||
});
|
||||
|
||||
test_peerconnection_audio_forced_sample_rate(49000);
|
||||
createHTML({
|
||||
bug: "1437366",
|
||||
title: "Basic audio-only peer connection, with the MTG running at a rate not supported by the MediaPipeline (49000Hz)"
|
||||
});
|
||||
|
||||
test_peerconnection_audio_forced_sample_rate(49000);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "1437366",
|
||||
title: "Basic audio-only peer connection, with the MTG running at a rate not supported by the MediaPipeline (24000Hz)"
|
||||
});
|
||||
createHTML({
|
||||
bug: "1437366",
|
||||
title: "Basic audio-only peer connection, with the MTG running at a rate not supported by the MediaPipeline (24000Hz)"
|
||||
});
|
||||
|
||||
test_peerconnection_audio_forced_sample_rate(24000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
options.h264 = true;
|
||||
test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
fake: false
|
||||
};
|
||||
test.setMediaConstraints([constraints], []);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
title: "Basic windowshare-only peer connection"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
var constraints = {
|
||||
const test = new PeerConnectionTest(options);
|
||||
const constraints = {
|
||||
video: {
|
||||
mozMediaSource: "window",
|
||||
mediaSource: "window"
|
||||
|
@ -22,7 +21,7 @@
|
|||
fake: false
|
||||
};
|
||||
test.setMediaConstraints([constraints], []);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
var sld = test.chain.remove("PC_REMOTE_SET_LOCAL_DESCRIPTION");
|
||||
test.chain.insertAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION", sld);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,21 +11,25 @@
|
|||
title: "Test with invalid TURN server"
|
||||
});
|
||||
|
||||
var turnConfig = { iceServers: [{"username":"mozilla","credential"
|
||||
:"mozilla","url":"turn:test@10.0.0.1"}] };
|
||||
var test;
|
||||
const turnConfig = {
|
||||
iceServers: [
|
||||
{
|
||||
username: "mozilla",
|
||||
credential: "mozilla",
|
||||
url: "turn:test@10.0.0.1",
|
||||
},
|
||||
],
|
||||
};
|
||||
runNetworkTest(function (options) {
|
||||
var exception = false;
|
||||
|
||||
let exception = false;
|
||||
try {
|
||||
pc = new RTCPeerConnection(turnConfig);
|
||||
new RTCPeerConnection(turnConfig);
|
||||
} catch (e) {
|
||||
info(e);
|
||||
exception = true;
|
||||
}
|
||||
is(exception, true, "Exception fired");
|
||||
ok("Success");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -38,7 +38,7 @@ runNetworkTest(async options => {
|
|||
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
"Can set expandos on an RTCPeerConnection");
|
||||
|
||||
pc = null;
|
||||
networkTestFinished();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -99,7 +99,7 @@ runNetworkTest(() => {
|
|||
|
||||
var push = prefs => SpecialPowers.pushPrefEnv(prefs);
|
||||
|
||||
Promise.resolve()
|
||||
return Promise.resolve()
|
||||
// This set of tests are setting the about:config User preferences for default
|
||||
// ice servers and checking the outputs when RTCPeerConnection() is
|
||||
// invoked. See Bug 1167922 for more information.
|
||||
|
@ -131,8 +131,7 @@ runNetworkTest(() => {
|
|||
"warning has this file");
|
||||
ok(remainder.includes('line: ' + lineNumberAndFunction.line),
|
||||
"warning has correct line number");
|
||||
})
|
||||
.then(networkTestFinished);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -42,7 +42,7 @@ runNetworkTest(() => {
|
|||
test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.chain.append(steps);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
var pc1 = new RTCPeerConnection();
|
||||
var pc2 = new RTCPeerConnection();
|
||||
|
||||
pc1.createOffer({ offerToReceiveAudio: true }).then(offer => {
|
||||
return pc1.createOffer({ offerToReceiveAudio: true }).then(offer => {
|
||||
// The whole point of this test is not to wait for the
|
||||
// setRemoteDescription call to succesfully complete, so we
|
||||
// don't wait for it to succeed.
|
||||
|
@ -27,7 +27,6 @@
|
|||
.then(() => {
|
||||
pc1.close();
|
||||
pc2.close();
|
||||
networkTestFinished();
|
||||
})
|
||||
.catch(reason => ok(false, reason.message));
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ runNetworkTest(function() {
|
|||
is(v2.currentTime, 0, "v2.currentTime is zero at outset");
|
||||
|
||||
// not testing legacy gUM here
|
||||
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
|
||||
return navigator.mediaDevices.getUserMedia({ video: true, audio: true })
|
||||
.then(stream => pc1.addStream(v1.srcObject = stream))
|
||||
.then(() => pcall(pc1, pc1.createOffer))
|
||||
.then(offer => pcall(pc1, pc1.setLocalDescription, offer))
|
||||
|
@ -78,9 +78,7 @@ runNetworkTest(function() {
|
|||
.then(() => waitUntil(() => v2.currentTime > 0))
|
||||
.then(() => ok(v2.currentTime > 0, "v2.currentTime is moving (" + v2.currentTime + ")"))
|
||||
.then(() => ok(true, "Connected."))
|
||||
.then(() => { v1.pause(); v2.pause(); })
|
||||
.catch(reason => ok(false, "unexpected failure: " + reason))
|
||||
.then(networkTestFinished);
|
||||
.then(() => { v1.pause(); v2.pause(); });
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -73,7 +73,7 @@ runNetworkTest(async () => {
|
|||
});
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -75,7 +75,7 @@ runNetworkTest(async (options) => {
|
|||
});
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -126,7 +126,7 @@ runNetworkTest(async () => {
|
|||
});
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -1,91 +1,80 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
<script src="pc.js"></script>
|
||||
<script src="../../../test/manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
(async () => {
|
||||
await createHTML({
|
||||
bug: "1081409",
|
||||
title: "Captured video-only over peer connection",
|
||||
visible: true
|
||||
});
|
||||
|
||||
createHTML({
|
||||
bug: "1081409",
|
||||
title: "Captured video-only over peer connection",
|
||||
visible: true
|
||||
}).then(() => new Promise(resolve => {
|
||||
// Run tests in sequence for log readability.
|
||||
PARALLEL_TESTS = 1;
|
||||
let manager = new MediaTestManager;
|
||||
window.mediaTestManager = manager;
|
||||
manager.runTests(getPlayableVideos(gLongerTests), startTest);
|
||||
manager.onFinished = () => {
|
||||
// Tear down before SimpleTest.finish.
|
||||
if ("nsINetworkInterfaceListService" in SpecialPowers.Ci) {
|
||||
getNetworkUtils().tearDownNetwork();
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
}))
|
||||
.catch(e => ok(false, "Unexpected " + e + ":\n" + e.stack));
|
||||
const manager = new MediaTestManager;
|
||||
|
||||
function startTest(media, token) {
|
||||
let manager = window.mediaTestManager;
|
||||
manager.started(token);
|
||||
info("Starting test for " + media.name);
|
||||
var video = document.createElement('video');
|
||||
video.id = "id_" + media.name;
|
||||
video.width = 160;
|
||||
video.height = 120;
|
||||
video.muted = true;
|
||||
video.controls = true;
|
||||
video.preload = "metadata";
|
||||
video.src = "../../../test/" + media.name;
|
||||
async function startTest(media, token) {
|
||||
manager.started(token);
|
||||
info(`Starting test for ${media.name}`);
|
||||
const video = document.createElement('video');
|
||||
video.id = "id_" + media.name;
|
||||
video.width = 160;
|
||||
video.height = 120;
|
||||
video.muted = true;
|
||||
video.controls = true;
|
||||
video.preload = "metadata";
|
||||
video.src = "../../../test/" + media.name;
|
||||
|
||||
document.getElementById("content").appendChild(video);
|
||||
document.getElementById("content").appendChild(video);
|
||||
|
||||
var test;
|
||||
new Promise((resolve, reject) => {
|
||||
video.onloadedmetadata = resolve;
|
||||
video.onerror = () => reject(video.error);
|
||||
})
|
||||
.then(() => {
|
||||
video.onerror = () => ok(false, media.name + " failed in playback (code=" +
|
||||
video.error.code + "). Stream should be OK. " +
|
||||
"Continuing test.");
|
||||
return runNetworkTest(() => {
|
||||
var stream = video.mozCaptureStream();
|
||||
test = new PeerConnectionTest({ config_local: { label_suffix: media.name },
|
||||
config_remote: { label_suffix: media.name } });
|
||||
test.setOfferOptions({ offerToReceiveVideo: false,
|
||||
offerToReceiveAudio: false });
|
||||
var hasVideo = stream.getVideoTracks().length > 0;
|
||||
var hasAudio = stream.getAudioTracks().length > 0;
|
||||
test.setMediaConstraints([{ video: hasVideo, audio: hasAudio }], []);
|
||||
test.chain.replace("PC_LOCAL_GUM", [
|
||||
function PC_LOCAL_CAPTUREVIDEO(test) {
|
||||
test.pcLocal.attachLocalStream(stream);
|
||||
},
|
||||
]);
|
||||
test.chain.insertBefore("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", [
|
||||
function PC_LOCAL_START_MEDIA(test) {
|
||||
video.play();
|
||||
},
|
||||
]);
|
||||
return test.chain.execute();
|
||||
});
|
||||
})
|
||||
// Handle both MediaErrors (with the `code` attribute) and other errors.
|
||||
.catch(e => ok(false, "Error (" + e + ")" +
|
||||
(e.code ? " (code=" + e.code + ")" : "") +
|
||||
" in test for " + media.name +
|
||||
(e.stack ? ":\n" + e.stack : "")))
|
||||
.then(() => test && test.close())
|
||||
.then(() => {
|
||||
const onerror = new Promise(r => video.onerror = r).then(_ =>
|
||||
new Error(`${media.name} failed in playback. code=${video.error.code}`));
|
||||
|
||||
await Promise.race([
|
||||
new Promise(res => video.onloadedmetadata = res),
|
||||
onerror,
|
||||
]);
|
||||
onerror.catch(e => ok(false, e));
|
||||
setupEnvironment();
|
||||
await testConfigured;
|
||||
const stream = video.mozCaptureStream();
|
||||
const test = new PeerConnectionTest(
|
||||
{
|
||||
config_local: { label_suffix: media.name },
|
||||
config_remote: { label_suffix: media.name },
|
||||
}
|
||||
);
|
||||
test.setOfferOptions(
|
||||
{
|
||||
offerToReceiveVideo: false,
|
||||
offerToReceiveAudio: false,
|
||||
}
|
||||
);
|
||||
const hasVideo = stream.getVideoTracks().length > 0;
|
||||
const hasAudio = stream.getAudioTracks().length > 0;
|
||||
test.setMediaConstraints([{ video: hasVideo, audio: hasAudio }], []);
|
||||
test.chain.replace("PC_LOCAL_GUM", [
|
||||
function PC_LOCAL_CAPTUREVIDEO(test) {
|
||||
test.pcLocal.attachLocalStream(stream);
|
||||
},
|
||||
]);
|
||||
test.chain.insertBefore("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", [
|
||||
function PC_LOCAL_START_MEDIA(test) {
|
||||
video.play();
|
||||
},
|
||||
]);
|
||||
await test.run();
|
||||
removeNodeAndSource(video);
|
||||
manager.finished(token);
|
||||
})
|
||||
.catch(e => ok(false, "Error (" + e + ") during shutdown."));
|
||||
};
|
||||
}
|
||||
|
||||
manager.runTests(getPlayableVideos(gLongerTests), startTest);
|
||||
})();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
await waitForSendPacket(test.pcRemote._pc, "srtcp", 1);
|
||||
}
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
pc.setIdentityProvider("Invalid Provider")},
|
||||
"setIdentityProvider() on closed PC raised expected exception");
|
||||
|
||||
Promise.all([finished, silence]).then(networkTestFinished);
|
||||
return Promise.all([finished, silence]);
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -71,7 +71,7 @@ runNetworkTest(() => {
|
|||
test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
|
||||
test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
|
||||
PC_LOCAL_CLOSE_DURING_ICE, PC_REMOTE_CLOSE_DURING_ICE]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -59,7 +59,7 @@ runNetworkTest(() => {
|
|||
checkSentTracksReceived(dummyStream.id, dummyStreamTracks);
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
await h.waitForPixel(test.pcRemote.remoteMediaElements[0],
|
||||
px => h.isPixel(px, h.black, 128));
|
||||
});
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -44,11 +44,9 @@
|
|||
// level to evoke an error in createOffer.
|
||||
|
||||
runNetworkTest(function () {
|
||||
testCreateAnswerError()
|
||||
return testCreateAnswerError()
|
||||
.then(testSetLocalDescriptionError)
|
||||
.then(testSetRemoteDescriptionError)
|
||||
.catch(reason => ok(false, "unexpected error: " + reason))
|
||||
.then(networkTestFinished);
|
||||
.then(testSetRemoteDescriptionError);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -30,11 +30,10 @@ runNetworkTest(function() {
|
|||
}
|
||||
]);
|
||||
gumTest.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW");
|
||||
gumTest.chain.execute()
|
||||
return gumTest.chain.execute()
|
||||
.then(() => forwardingTest.chain.execute())
|
||||
.then(() => gumTest.close())
|
||||
.then(() => forwardingTest.close())
|
||||
.then(() => networkTestFinished());
|
||||
.then(() => forwardingTest.close());
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -58,24 +58,25 @@ function PC_REMOTE_WAIT_FOR_ICE_FAILED(test) {
|
|||
}
|
||||
}
|
||||
|
||||
runNetworkTest(() => {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
'set': [
|
||||
['media.peerconnection.ice.stun_client_maximum_transmits', 3],
|
||||
['media.peerconnection.ice.trickle_grace_period', 3000],
|
||||
]
|
||||
}, function() {
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
|
||||
test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
|
||||
test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_FAILED);
|
||||
test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_FAILED", PC_REMOTE_WAIT_FOR_ICE_FAILED);
|
||||
test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
|
||||
test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
|
||||
PC_LOCAL_WAIT_FOR_ICE_FAILURE, PC_REMOTE_WAIT_FOR_ICE_FAILURE]);
|
||||
test.run();
|
||||
});
|
||||
runNetworkTest(async () => {
|
||||
await pushPrefs(
|
||||
['media.peerconnection.ice.stun_client_maximum_transmits', 3],
|
||||
['media.peerconnection.ice.trickle_grace_period', 3000],
|
||||
);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
|
||||
test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
|
||||
test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_FAILED);
|
||||
test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_FAILED", PC_REMOTE_WAIT_FOR_ICE_FAILED);
|
||||
test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
|
||||
test.chain.append([
|
||||
PC_REMOTE_ADD_FAKE_ICE_CANDIDATE,
|
||||
PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
|
||||
PC_LOCAL_WAIT_FOR_ICE_FAILURE,
|
||||
PC_REMOTE_WAIT_FOR_ICE_FAILURE
|
||||
]);
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -67,8 +67,7 @@ runNetworkTest(() => {
|
|||
]);
|
||||
|
||||
return pushPrefs(['media.peerconnection.dtmf.enabled', true])
|
||||
.then(() => { test.run() })
|
||||
.catch(e => ok(false, "unexpected failure: " + e));
|
||||
.then(() => test.run());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
title: "Rollback local reoffer"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
addRenegotiation(test.chain, [
|
||||
function PC_LOCAL_ADD_SECOND_STREAM(test) {
|
||||
test.setMediaConstraints([{audio: true}, {audio: true}],
|
||||
|
@ -37,7 +36,7 @@
|
|||
},
|
||||
]);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
title: "Rollback local offer"
|
||||
});
|
||||
|
||||
var test;
|
||||
runNetworkTest(function (options) {
|
||||
test = new PeerConnectionTest(options);
|
||||
const test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.chain.insertBefore('PC_LOCAL_CREATE_OFFER', [
|
||||
function PC_REMOTE_CREATE_AND_SET_OFFER(test) {
|
||||
|
@ -40,7 +39,7 @@
|
|||
test.pcRemote.setupIceCandidateHandler(test);
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
// Disable h264 hardware support, to ensure it is not prioritized over VP8
|
||||
await pushPrefs(["media.webrtc.hw.h264.enabled", false]);
|
||||
await testScale("VP8");
|
||||
networkTestFinished();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -107,7 +107,7 @@ runNetworkTest(async () => {
|
|||
])
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
await test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
makeAnswererNonTrickle(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
test = new PeerConnectionTest(options);
|
||||
makeOffererNonTrickle(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
makeOffererNonTrickle(test.chain);
|
||||
makeAnswererNonTrickle(test.chain);
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
return test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче