Backed out changeset a7c030a81408 (bug 1295352)

This commit is contained in:
Iris Hsiao 2016-08-26 18:26:35 +08:00
Родитель 66918d6929
Коммит eea175e0b3
13 изменённых файлов: 75 добавлений и 89 удалений

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

@ -18,7 +18,6 @@ var spinEventLoop = () => new Promise(r => setTimeout(r, 0));
var stream;
var clone;
var newStream;
var tracks = [];
var addTrack = track => {
info("Adding track " + track.id);
@ -50,15 +49,15 @@ runTest(() => getUserMedia({audio: true, video: true})
})
.then(s => {
newStream = s;
// TODO: Uncomment once bug 1294605 is fixed
// info("Stopping an original track");
// stopTrack(stream.getTracks()[0]);
info("Stopping an original track");
stopTrack(stream.getTracks()[0]);
return spinEventLoop();
})
.then(() => {
info("Removing original tracks");
stream.getTracks().forEach(t => (stream.removeTrack(t), tracks.push(t)));
stream.getTracks().forEach(t => stream.removeTrack(t));
return spinEventLoop();
})
@ -90,7 +89,6 @@ runTest(() => getUserMedia({audio: true, video: true})
.then(() => {
info("Stopping originals");
stream.getTracks().forEach(t => stopTrack(t));
tracks.forEach(t => stopTrack(t));
return spinEventLoop();
})

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

@ -31,8 +31,7 @@
ok(video.videoHeight > 0, "Expected nonzero video width");
resolve();
});
})
.then(() => stream.getTracks().forEach(t => t.stop()));
});
});
});

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

@ -24,8 +24,7 @@
video.play();
var h = new CaptureStreamTestHelper2D();
var removedTrack = stream.getVideoTracks()[0];
stream.removeTrack(removedTrack);
stream.removeTrack(stream.getVideoTracks()[0]);
video.onloadeddata = () => {
info("loadeddata");
var canvas = document.createElement("canvas");
@ -41,10 +40,7 @@
return listenUntil(video, "loadeddata", () => true)
.then(() => h.waitForPixelColor(video, h.grey, 5,
"The canvas track should be rendered by the media element"))
.then(() => {
[removedTrack, ...stream.getAudioTracks()].forEach(t => t.stop());
});
"The canvas track should be rendered by the media element"));
}));
</script>
</pre>

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

@ -102,8 +102,8 @@ var mustFailWith = (msg, reason, constraint, f) =>
* test by verifying that the right resolution and rejection is fired.
*/
runTest(() => Promise.resolve()
.then(() => {
runTest(function() {
// Check supported constraints first.
var dict = navigator.mediaDevices.getSupportedConstraints();
var supported = Object.keys(dict);
@ -114,27 +114,27 @@ runTest(() => Promise.resolve()
var unexpected = supported.filter(key => mustSupport.indexOf(key) == -1);
is(unexpected.length, 0,
"Unanticipated support (please update test): " + unexpected);
})
.then(() => pushPrefs(["media.getusermedia.browser.enabled", false],
["media.getusermedia.screensharing.enabled", false]))
.then(() => tests.reduce((p, test) => p.then(() => getUserMedia(test.constraints))
.then(stream => {
is(null, test.error, test.message);
stream.getTracks().forEach(t => t.stop());
}, e => {
// Run constraint tests
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
set : [ ['media.getusermedia.browser.enabled', false],
['media.getusermedia.screensharing.enabled', false] ]
}, resolve));
return tests.reduce((p, test) =>
p.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
.then(() => is(null, test.error, test.message), e => {
is(e.name, test.error, test.message + ": " + e.message);
if (test.constraint) {
is(e.constraint, test.constraint,
test.message + " w/correct constraint.");
}
}), Promise.resolve()))
.then(() => getUserMedia({video: true, audio: true}))
}), p)
.then(() => navigator.mediaDevices.getUserMedia({video: true, audio: true}))
.then(stream => stream.getVideoTracks()[0].applyConstraints({ width: 320 })
.then(() => stream.getAudioTracks()[0].applyConstraints({ }))
.then(() => {
stream.getTracks().forEach(track => track.stop());
ok(true, "applyConstraints code exercised");
}))
.then(() => stream.getAudioTracks()[0].applyConstraints({ })))
.then(() => ok(true, "applyConstraints code exercised"))
// TODO: Test outcome once fake devices support constraints (Bug 1088621)
.then(() => mustFailWith("applyConstraints fails on non-Gum tracks",
"OverconstrainedError", "",
@ -144,8 +144,11 @@ runTest(() => Promise.resolve()
.then(() => mustFailWith(
"getUserMedia with unsatisfied required constraint",
"OverconstrainedError", "deviceId",
() => getUserMedia({ audio: true,
video: { deviceId: { exact: "unheardof" } } }))));
() => navigator.mediaDevices.getUserMedia({
audio: true,
video: { deviceId: { exact: "unheardof" } },
})));
});
</script>
</pre>

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

@ -40,7 +40,6 @@
newStream.addTrack(videoTrack);
is(newStream.getTrackById(videoTrack.id), videoTrack,
"getTrackByid with matching id should return the track");
[audioTrack, videoTrack].forEach(t => t.stop());
});
});

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

@ -23,13 +23,11 @@
var constraints = {video: true, audio: true};
return getUserMedia(constraints).then(stream => new Promise(resolve => {
v.srcObject = stream;
v.onloadedmetadata = () => {
v.onloadedmetadata = resolve;
})).then(() => {
isnot(v.videoWidth, 0, "videoWidth shall be set on 'loadedmetadata'");
isnot(v.videoHeight, 0, "videoHeight shall be set on 'loadedmetadata'");
resolve();
};
})
.then(() => stream.getTracks().forEach(t => t.stop())));
});
});
</script>

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

@ -73,9 +73,8 @@
}))
.then(() => getUserMedia({audio: true, video: true})).then(stream => {
info("Test cloning a stream into inception");
var clone = stream;
var clones = Array(10).fill().map(() => clone = clone.clone());
var inceptionClone = clones.pop();
var inceptionClone = stream.clone().clone().clone().clone().clone()
.clone().clone().clone().clone().clone();
checkMediaStreamCloneAgainstOriginal(inceptionClone, stream);
stream.getTracks().forEach(t => (stream.removeTrack(t),
inceptionClone.addTrack(t)));
@ -86,8 +85,7 @@
var test = createMediaElement('video', 'testClonePlayback');
var playback = new MediaStreamPlayback(test, inceptionClone);
return playback.playMedia(false)
.then(() => clones.forEach(c => c.getTracks().forEach(t => t.stop())));
return playback.playMedia(false);
})
.then(() => getUserMedia({audio: true, video: true})).then(stream => {
info("Test adding tracks from many stream clones to the original stream");

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

@ -40,9 +40,8 @@
.then(() => getUserMedia({video: true})).then(stream => {
info("Test cloning a track into inception");
var track = stream.getTracks()[0];
var clone = track;
var clones = Array(10).fill().map(() => clone = clone.clone());
var inceptionClone = clones.pop();
var inceptionClone = track.clone().clone().clone().clone().clone()
.clone().clone().clone().clone().clone();
checkMediaStreamTrackCloneAgainstOriginal(inceptionClone, track);
var cloneStream = new MediaStream();
@ -53,16 +52,10 @@
var test = createMediaElement('video', 'testClonePlayback');
var playback = new MediaStreamPlayback(test, cloneStream);
return playback.playMedia(false).then(() => {
// TODO: Uncomment once bug 1294605 is fixed
// info("Testing that clones of ended tracks are ended");
// cloneStream.clone().getTracks().forEach(t =>
// is(t.readyState, "ended", "Track " + t.id + " should be ended"));
})
.then(() => {
clones.forEach(t => t.stop());
track.stop();
});
return playback.playMedia(false)
.then(() => info("Testing that clones of ended tracks are ended"))
.then(() => cloneStream.clone().getTracks().forEach(t =>
is(t.readyState, "ended", "Track " + t.id + " should be ended")));
})
.then(() => getUserMedia({audio: true, video: true})).then(stream => {
info("Test adding many track clones to the original stream");

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

@ -22,7 +22,7 @@ function theTest() {
.then(stream => Promise.all([
audioIsSilence(withConstraint, stream),
videoIsBlack(withConstraint, stream)
]).then(() => stream.getTracks().forEach(t => t.stop())));
]));
};
// both without and with the constraint

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

@ -15,8 +15,9 @@
var testAudio = createMediaElement('audio', 'testAudio');
var playback = new LocalMediaStreamPlayback(testAudio, audioStream);
return playback.playMediaWithoutStoppingTracks(false)
.then(() => playback.playMedia(true));
return playback.playMedia(false)
.then(() => playback.playMedia(true))
.then(() => audioStream.stop());
});
});
</script>

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

@ -15,8 +15,9 @@
var testVideo = createMediaElement('video', 'testVideo');
var playback = new LocalMediaStreamPlayback(testVideo, stream);
return playback.playMediaWithoutStoppingTracks(false)
.then(() => playback.playMedia(true));
return playback.playMedia(false)
.then(() => playback.playMedia(true))
.then(() => stream.stop());
});
});

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

@ -15,8 +15,9 @@
var testVideo = createMediaElement('video', 'testVideo');
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
return streamPlayback.playMediaWithoutStoppingTracks(false)
.then(() => streamPlayback.playMedia(true));
return streamPlayback.playMedia(false)
.then(() => streamPlayback.playMedia(true))
.then(() => stream.stop());
});
});

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

@ -13,10 +13,9 @@
runTest(() => {
var testAudio = createMediaElement('audio', 'testAudio');
return new Promise((resolve, reject) => {
navigator.mozGetUserMedia({ audio: true }, stream => {
navigator.mozGetUserMedia({ audio: true }, () => {
SpecialPowers.spinEventLoop(window);
ok(true, "Didn't crash");
stream.getTracks().forEach(t => t.stop());
resolve();
}, () => {});
});