Bug 1175523 - Update most (but not all) tests to use elem.srcObject over .mozSrcObject. r=pehrsons

--HG--
extra : rebase_source : bac0027f4bf5d75b8730c44a10141c114002633b
This commit is contained in:
Jan-Ivar Bruaroey 2015-07-14 10:12:31 -04:00
parent f01e4a40fe
commit 0ccb51ddc8
27 changed files with 77 additions and 69 deletions

View File

@ -85,7 +85,7 @@ function CameraTestSuite() {
var self = this;
this._window.addEventListener('beforeunload', function() {
if (isDefinedObj(self.viewfinder)) {
self.viewfinder.mozSrcObject = null;
self.viewfinder.srcObject = null;
}
self.hw = null;
@ -211,7 +211,7 @@ CameraTestSuite.prototype = {
function postTest(pass) {
ok(pass, test.name + ' finished');
var camera = self.camera;
self.viewfinder.mozSrcObject = null;
self.viewfinder.srcObject = null;
self.camera = null;
if (!isDefinedObj(camera)) {
@ -325,7 +325,7 @@ CameraTestSuite.prototype = {
return;
}
self.viewfinder.mozSrcObject = self.camera;
self.viewfinder.srcObject = self.camera;
self.viewfinder.play();
self.camera.addEventListener('previewstatechange', onPreviewStateChange);
});

View File

@ -42,7 +42,7 @@ var Camera = {
var camera = d.camera;
var cfg = d.configuration;
Camera.cameraObj = camera;
Camera.viewfinder.mozSrcObject = camera;
Camera.viewfinder.srcObject = camera;
Camera.viewfinder.play();
// Check the default configuration
@ -66,7 +66,7 @@ var Camera = {
SimpleTest.waitForExplicitFinish();
window.addEventListener('beforeunload', function() {
Camera.viewfinder.mozSrcObject = null;
Camera.viewfinder.srcObject = null;
if (Camera.cameraObj) {
Camera.cameraObj.release();
Camera.cameraObj = null;

View File

@ -232,7 +232,7 @@ var Camera = {
Camera.cameraObj.addEventListener('configurationchanged', Camera.onConfigChange);
Camera.cameraObj.addEventListener('shutter', Camera.shutter);
Camera.cameraObj.addEventListener('picture', Camera.takePictureEvent.bind(Camera));
Camera.viewfinder.mozSrcObject = d.camera;
Camera.viewfinder.srcObject = d.camera;
Camera.viewfinder.play();
SimpleTest.expectAssertions(0);
ok(true, "Camera Control object has been successfully initialized");
@ -245,7 +245,7 @@ var Camera = {
SimpleTest.waitForExplicitFinish();
window.addEventListener('beforeunload', function() {
Camera.viewfinder.mozSrcObject = null;
Camera.viewfinder.srcObject = null;
Camera.cameraObj.release();
Camera.cameraObj = null;
});

View File

@ -179,7 +179,7 @@ var Camera = {
Camera.cameraObj = d.camera;
Camera.cameraObj.addEventListener('previewstatechange', Camera.onPreviewStateChange);
Camera.cameraObj.addEventListener('shutter', Camera.shutter);
Camera.viewfinder.mozSrcObject = d.camera;
Camera.viewfinder.srcObject = d.camera;
Camera.viewfinder.play();
SimpleTest.expectAssertions(0);
};
@ -190,7 +190,7 @@ var Camera = {
SimpleTest.waitForExplicitFinish();
window.addEventListener('beforeunload', function() {
Camera.viewfinder.mozSrcObject = null;
Camera.viewfinder.srcObject = null;
Camera.cameraObj.release();
Camera.cameraObj = null;
});

View File

@ -54,7 +54,7 @@ var Camera = {
function onSuccess(d) {
Camera.cameraObj = d.camera;
Camera.cameraObj.addEventListener('previewstatechange', Camera.onPreviewStateChange);
Camera.viewfinder.mozSrcObject = d.camera;
Camera.viewfinder.srcObject = d.camera;
Camera.viewfinder.play();
};
navigator.mozCameras.getCamera(whichCamera, options).then(onSuccess, onError);
@ -64,7 +64,7 @@ var Camera = {
SimpleTest.waitForExplicitFinish();
window.addEventListener('beforeunload', function() {
Camera.viewfinder.mozSrcObject = null;
Camera.viewfinder.srcObject = null;
Camera.cameraObj.release();
Camera.cameraObj = null;
});

View File

@ -35,7 +35,7 @@ CaptureStreamTestHelper.prototype = {
/* Request a frame from the stream played by |video|. */
requestFrame: function (video) {
info("Requesting frame from " + video.id);
video.mozSrcObject.requestFrame();
video.srcObject.requestFrame();
},
/* Tests the top left pixel of |video| against |refData|. Format [R,G,B,A]. */

View File

@ -19,7 +19,7 @@ function runTest() {
context.fillRect(0, 0, canvas.width, canvas.height);
var video = document.getElementById('video');
video.mozSrcObject = canvas.captureStream(0);
video.srcObject = canvas.captureStream(0);
video.play();
video.onloadeddata = finished;
video.onerror = finished;

View File

@ -33,7 +33,7 @@ function runTest() {
gl.clear(gl.COLOR_BUFFER_BIT);
var video = document.getElementById('video');
video.mozSrcObject = canvas.captureStream(0);
video.srcObject = canvas.captureStream(0);
video.play();
video.onloadeddata = finished;
video.onerror = finished;

View File

@ -19,9 +19,9 @@ function checkDrawColorInitialRed() {
h.drawColor(c, h.red);
vauto.mozSrcObject = c.captureStream();
vmanual.mozSrcObject = c.captureStream(0);
vrate.mozSrcObject = c.captureStream(10);
vauto.srcObject = c.captureStream();
vmanual.srcObject = c.captureStream(0);
vrate.srcObject = c.captureStream(10);
ok(h.testPixel(vauto, [0, 0, 0, 0], 0), "vauto hould not be drawn to before stable state");
ok(h.testPixel(vrate, [0, 0, 0, 0], 0), "vrate Should not be drawn to before stable state");

View File

@ -50,9 +50,9 @@ function checkClearColorInitialRed() {
h.clearColor(c, h.red);
vauto.mozSrcObject = c.captureStream();
vmanual.mozSrcObject = c.captureStream(0);
vrate.mozSrcObject = c.captureStream(10);
vauto.srcObject = c.captureStream();
vmanual.srcObject = c.captureStream(0);
vrate.srcObject = c.captureStream(10);
ok(h.testPixel(vauto, [0, 0, 0, 0], 0), "Should not be drawn to before stable state");
ok(h.testPixel(vrate, [0, 0, 0, 0], 0), "Should not be drawn to before stable state");

View File

@ -1338,12 +1338,12 @@ function getMajorMimeType(mimetype) {
// Force releasing decoder to avoid timeout in waiting for decoding resource.
function removeNodeAndSource(n) {
n.remove();
// Clearing mozSrcObject and/or src will actually set them to some default
// Clearing srcObject and/or src will actually set them to some default
// URI that will fail to load, so make sure we don't produce a spurious
// bailing error.
n.onerror = null;
// reset |mozSrcObject| first since it takes precedence over |src|.
n.mozSrcObject = null;
// reset |srcObject| first since it takes precedence over |src|.
n.srcObject = null;
n.src = "";
while (n.firstChild) {
n.removeChild(n.firstChild);

View File

@ -120,7 +120,7 @@ var startTest = function(media, token) {
v1.src = media.name;
v2.src = media.name;
v3.mozSrcObject = v2.mozCaptureStreamUntilEnded();
v3.srcObject = v2.mozCaptureStreamUntilEnded();
}
manager.runTests(getPlayableVideos(gSmallTests), startTest);

View File

@ -31,7 +31,7 @@ function startTest() {
source.channelCountMode = 'explicit';
source.connect(dest);
var elem = document.createElement('audio');
elem.mozSrcObject = dest.stream;
elem.srcObject = dest.stream;
mMediaStream = dest.stream;
source.start(0);
elem.play();

View File

@ -25,7 +25,7 @@ function startTest() {
var dest = context.createMediaStreamDestination();
source.connect(dest);
var elem = document.createElement('audio');
elem.mozSrcObject = dest.stream;
elem.srcObject = dest.stream;
mMediaStream = dest.stream;
source.start(0);
elem.play();

View File

@ -128,7 +128,7 @@ function startTest() {
}
var steps = 0;
element.mozSrcObject = stream;
element.srcObject = stream;
element.onplaying = onplaying;
element.onended = onended;
element.play();

View File

@ -21,7 +21,7 @@ function startTest() {
};
mStream = stream;
element.mozSrcObject = mStream;
element.srcObject = mStream;
element.play();
})
.catch(function(reason) {

View File

@ -20,7 +20,7 @@ if (media == null) {
SimpleTest.finish();
} else {
v1.src = media.name;
v2.mozSrcObject = v1.mozCaptureStream();
v2.srcObject = v1.mozCaptureStream();
var onPlayingEventFired = false;
v2.onplaying = function() {

View File

@ -38,8 +38,8 @@ function startTest(test, token) {
v.src = test.name;
var stream = v.mozCaptureStreamUntilEnded();
is(stream.currentTime, 0, test.name + " stream initial currentTime");
vout.mozSrcObject = stream;
is(vout.mozSrcObject, stream, test.name + " set output element .srcObject correctly");
vout.srcObject = stream;
is(vout.srcObject, stream, test.name + " set output element .srcObject correctly");
var checkEnded = function(test, vout, stream) { return function() {
is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime");

View File

@ -17,8 +17,8 @@ SimpleTest.waitForExplicitFinish();
var v = document.getElementById('v');
var vout = document.getElementById('vout');
var vout_untilended = document.getElementById('vout_untilended');
vout.mozSrcObject = v.mozCaptureStream();
vout_untilended.mozSrcObject = v.mozCaptureStreamUntilEnded();
vout.srcObject = v.mozCaptureStream();
vout_untilended.srcObject = v.mozCaptureStreamUntilEnded();
function dumpEvent(event) {
var v = event.target;

View File

@ -6,48 +6,56 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body onload="doTest()">
<audio id="a"></audio>
<body onload="doTests()">
<audio id="a1"></audio>
<audio id="a2"></audio>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var a = document.getElementById('a');
a.src = getPlayableAudio(gSmallTests).name;
var doTest = srcObject => new Promise(resolve => {
var a = document.getElementById('a1');
a.src = getPlayableAudio(gSmallTests).name;
var b = new Audio();
var b = new Audio();
function doTest() {
var newSrc = a.src + "?2";
b.src = newSrc;
is(b.mozSrcObject, null, "Initial srcObject is null");
is(b[srcObject], null, "Initial srcObject is null");
var stream = a.mozCaptureStream();
b.mozSrcObject = stream;
is(b.mozSrcObject, stream, "Stream set correctly");
b[srcObject] = stream;
is(b[srcObject], stream, "Stream set correctly");
try {
b.mozSrcObject = "invalid";
ok(false, "Setting mozSrcObject to an invalid value should throw.");
b[srcObject] = "invalid";
ok(false, "Setting srcObject to an invalid value should throw.");
} catch (e) {
ok(e instanceof TypeError, "Exception should be a TypeError");
}
is(b.mozSrcObject, stream, "Stream not set to invalid value");
is(b[srcObject], stream, "Stream not set to invalid value");
is(b.src, newSrc, "src attribute not affected by setting srcObject");
var step = 0;
b.addEventListener("loadedmetadata", function() {
if (step == 0) {
is(b.currentSrc, "", "currentSrc set to empty string while playing srcObject");
b.mozSrcObject = null;
is(b.mozSrcObject, null, "Stream set to null");
b[srcObject] = null;
is(b[srcObject], null, "Stream set to null");
// The resource selection algorithm will run again and choose b.src
} else if (step == 1) {
is(b.currentSrc, b.src, "currentSrc set to src now that srcObject is null");
SimpleTest.finish();
resolve();
}
++step;
});
a.play();
b.play();
}
});
// TODO: remove prefixed version soon (1183495).
var doTests = () => doTest("srcObject").then(() => doTest("mozSrcObject"))
.catch(e => ok(false, "Unexpected error: " + e))
.then(() => SimpleTest.finish())
.catch(e => ok(false, "Coding error: " + e));
</script>
</pre>
</body>

View File

@ -65,7 +65,7 @@
function checkAudio(constraintApplied, stream) {
var audio = mkElement('audio');
audio.mozSrcObject = stream;
audio.srcObject = stream;
audio.play();
var context = new AudioContext();
@ -93,7 +93,7 @@
function checkVideo(constraintApplied, stream) {
var video = mkElement('video');
video.mozSrcObject = stream;
video.srcObject = stream;
video.play();
return periodicCheck(() => {

View File

@ -122,7 +122,7 @@ MediaStreamPlayback.prototype = {
false);
// Hooks up the media stream to the media element and starts playing it
this.mediaElement.mozSrcObject = this.mediaStream;
this.mediaElement.srcObject = this.mediaStream;
this.mediaElement.play();
// If canplaythrough doesn't fire in enough time, we fail the test
@ -142,7 +142,7 @@ MediaStreamPlayback.prototype = {
*/
stopMediaElement : function() {
this.mediaElement.pause();
this.mediaElement.mozSrcObject = null;
this.mediaElement.srcObject = null;
}
}

View File

@ -813,7 +813,7 @@ PeerConnectionWrapper.prototype = {
var element = createMediaElement(type, this.label + '_' + side + this.streams.length);
this.mediaElements.push(element);
element.mozSrcObject = stream;
element.srcObject = stream;
element.play();
// Store local media elements so that we can stop them when done.

View File

@ -24,7 +24,7 @@
var playback = new LocalMediaStreamPlayback(testVideo, stream);
var video = playback.mediaElement;
video.mozSrcObject = stream;
video.srcObject = stream;
return new Promise(resolve => {
ok(playback.mediaElement.paused,
"Media element should be paused before play()ing");

View File

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
@ -27,7 +27,7 @@
var v1, v2;
var delivered = new Promise(resolve =>
pc2.onaddstream = e => resolve(v2.mozSrcObject = e.stream));
pc2.onaddstream = e => resolve(v2.srcObject = e.stream));
runNetworkTest(function() {
v1 = createMediaElement('video', 'v1');
@ -37,7 +37,7 @@
is(v2.currentTime, 0, "v2.currentTime is zero at outset");
navigator.mediaDevices.getUserMedia({ fake: true, video: true, audio: true })
.then(stream => pc1.addStream(v1.mozSrcObject = stream))
.then(stream => pc1.addStream(v1.srcObject = stream))
.then(() => pc1.createOffer({})) // check that createOffer accepts arg.
.then(offer => pc1.setLocalDescription(offer))
.then(() => pc2.setRemoteDescription(pc1.localDescription))
@ -46,7 +46,7 @@
.then(() => pc1.setRemoteDescription(pc2.localDescription))
.then(() => delivered)
// .then(() => canPlayThrough) // why doesn't this fire?
.then(() => waitUntil(() => v2.currentTime > 0 && v2.mozSrcObject.currentTime > 0))
.then(() => waitUntil(() => v2.currentTime > 0 && v2.srcObject.currentTime > 0))
.then(() => ok(v2.currentTime > 0, "v2.currentTime is moving (" + v2.currentTime + ")"))
.then(() => ok(true, "Connected."))
.catch(reason => ok(false, "unexpected failure: " + reason))

View File

@ -27,7 +27,7 @@ addLoadEvent(function() {
source.connect(dest);
var elem = document.getElementById('audioelem');
elem.mozSrcObject = dest.stream;
elem.srcObject = dest.stream;
elem.onloadedmetadata = function() {
ok(true, "got metadata event");
setTimeout(function() {

View File

@ -35,15 +35,15 @@
function stopMedia() {
if (video_status) {
video.mozSrcObject.stop();
video.mozSrcObject = null;
video.srcObject.stop();
video.srcObject = null;
content.removeChild(video);
capturing = false;
video_status = false;
}
if (audio_status) {
audio.mozSrcObject.stop();
audio.mozSrcObject = null;
audio.srcObject.stop();
audio.srcObject = null;
content.removeChild(audio);
audio_status = false;
}
@ -54,12 +54,12 @@
window.navigator.mozGetUserMedia(param, function(stream) {
if (video_status) {
content.appendChild(video);
video.mozSrcObject = stream;
video.srcObject = stream;
video.play();
}
if (audio_status) {
content.appendChild(audio);
audio.mozSrcObject = stream;
audio.srcObject = stream;
audio.play();
}
var audioTracks = stream.getAudioTracks();
@ -72,8 +72,8 @@
document.title += "video";
}
document.title += " gumtest";
audio.mozSrcObject.stop();
video.mozSrcObject.stop();
audio.srcObject.stop();
video.srcObject.stop();
}, function(err) {
document.title = "failed gumtest";
stopMedia();