Backed out 5 changesets (bug 1556854) for mda failures on /test_media_selection.html CLOSED TREE

Backed out changeset 61a4022333fa (bug 1556854)
Backed out changeset cfd809c63877 (bug 1556854)
Backed out changeset 057cc9878594 (bug 1556854)
Backed out changeset 0f02ff8a5c67 (bug 1556854)
Backed out changeset 8719996c65b3 (bug 1556854)
This commit is contained in:
Narcis Beleuzu 2019-10-24 13:47:37 +03:00
parent 7b85f15477
commit 6a96b612b6
127 changed files with 1891 additions and 2389 deletions

View file

@ -11,6 +11,10 @@
# Exclude expected objdirs. # Exclude expected objdirs.
obj*/ obj*/
# dom/ exclusions which should be removed (aka ESLint enabled)
dom/media/test/
!dom/media/test/marionette/yttest/*.js
# build/ third-party code # build/ third-party code
build/pgo/js-input/ build/pgo/js-input/
@ -155,8 +159,6 @@ dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js dom/encoding/test/file_utf16_le_bom.js
# Not parsable # Not parsable
dom/media/test/marionette/yttest/duration_test.js
dom/media/test/marionette/yttest/until_end_test.js
dom/tests/mochitest/general/test_focusrings.xul dom/tests/mochitest/general/test_focusrings.xul
dom/html/test/test_bug677658.html dom/html/test/test_bug677658.html

View file

@ -1,5 +1,3 @@
/* import-globals-from manifest.js */
function playAndPostResult(muted, parent_window) { function playAndPostResult(muted, parent_window) {
let element = document.createElement("video"); let element = document.createElement("video");
element.preload = "auto"; element.preload = "auto";
@ -10,10 +8,10 @@ function playAndPostResult(muted, parent_window) {
let allowedToPlay = element.allowedToPlay; let allowedToPlay = element.allowedToPlay;
element.play().then( element.play().then(
() => { () => {
parent_window.postMessage({ played: true, allowedToPlay }, "*"); parent_window.postMessage({played: true, allowedToPlay}, "*");
}, },
() => { () => {
parent_window.postMessage({ played: false, allowedToPlay }, "*"); parent_window.postMessage({played: false, allowedToPlay}, "*");
} }
); );
} }
@ -32,15 +30,10 @@ const autoplayPermission = "autoplay-media";
async function pushAutoplayAllowedPermission() { async function pushAutoplayAllowedPermission() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
SpecialPowers.pushPermissions( SpecialPowers.pushPermissions([{
[ 'type': autoplayPermission,
{ 'allow': true,
type: autoplayPermission, 'context': document
allow: true, }], resolve);
context: document,
},
],
resolve
);
}); });
} }

View file

@ -1,35 +1,33 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* jshint esversion: 6, -W097 */
// This file expects manager to be defined in the global scope. /* globals SimpleTest, SpecialPowers, document, info, is, manager, ok */
/* global manager */
/* import-globals-from manifest.js */
"use strict"; "use strict";
function startTest(test) { function startTest(test) {
info(test.desc); info(test.desc);
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ set: test.prefs }, () => { SpecialPowers.pushPrefEnv({ 'set': test.prefs }, () => {
manager.runTests(test.tests, test.runTest); manager.runTests(test.tests, test.runTest);
}); });
} }
function nextVideoEnded(video) { function nextVideoEnded(video) {
return nextEvent(video, "ended"); return nextEvent(video, 'ended');
} }
function nextVideoPlaying(video) { function nextVideoPlaying(video) {
return nextEvent(video, "playing"); return nextEvent(video, 'playing');
} }
function nextVideoResumes(video) { function nextVideoResumes(video) {
return nextEvent(video, "mozexitvideosuspend"); return nextEvent(video, 'mozexitvideosuspend');
} }
function nextVideoSuspends(video) { function nextVideoSuspends(video) {
return nextEvent(video, "mozentervideosuspend"); return nextEvent(video, 'mozentervideosuspend');
} }
/** /**
@ -38,14 +36,10 @@ function nextVideoSuspends(video) {
*/ */
function appendVideoToDoc(url, token, width, height) { function appendVideoToDoc(url, token, width, height) {
// Default size of (160, 120) is used by other media tests. // Default size of (160, 120) is used by other media tests.
if (width === undefined) { if (width === undefined) { width = 160; }
width = 160; if (height === undefined) { height = 3 * width / 4; }
}
if (height === undefined) {
height = (3 * width) / 4;
}
let v = document.createElement("video"); let v = document.createElement('video');
v.token = token; v.token = token;
v.width = width; v.width = width;
v.height = height; v.height = height;
@ -56,14 +50,10 @@ function appendVideoToDoc(url, token, width, height) {
function appendVideoToDocWithoutLoad(token, width, height) { function appendVideoToDocWithoutLoad(token, width, height) {
// Default size of (160, 120) is used by other media tests. // Default size of (160, 120) is used by other media tests.
if (width === undefined) { if (width === undefined) { width = 160; }
width = 160; if (height === undefined) { height = 3*width/4; }
}
if (height === undefined) {
height = (3 * width) / 4;
}
let v = document.createElement("video"); let v = document.createElement('video');
v.token = token; v.token = token;
document.body.appendChild(v); document.body.appendChild(v);
v.width = width; v.width = width;
@ -74,13 +64,7 @@ function appendVideoToDocWithoutLoad(token, width, height) {
function loadAndWaitUntilLoadedmetadata(video, url, preloadType = "metadata") { function loadAndWaitUntilLoadedmetadata(video, url, preloadType = "metadata") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
video.preload = preloadType; video.preload = preloadType;
video.addEventListener( video.addEventListener("loadedmetadata", () => { resolve(); }, true);
"loadedmetadata",
() => {
resolve();
},
true
);
video.src = url; video.src = url;
}); });
} }
@ -111,9 +95,7 @@ function waitUntilVisible(video) {
* @returns {Promise} Promise that is resolved when video 'playing' event fires. * @returns {Promise} Promise that is resolved when video 'playing' event fires.
*/ */
function waitUntilPlaying(video) { function waitUntilPlaying(video) {
var p = once(video, "playing", () => { var p = once(video, 'playing', () => { ok(true, `${video.token} played.`); });
ok(true, `${video.token} played.`);
});
Log(video.token, "Start playing"); Log(video.token, "Start playing");
video.play(); video.play();
return p; return p;
@ -130,9 +112,7 @@ function waitUntilEnded(video) {
return Promise.resolve(); return Promise.resolve();
} }
return once(video, "ended", () => { return once(video, 'ended', () => { ok(true, `${video.token} ended`); });
ok(true, `${video.token} ended`);
});
} }
/** /**
@ -141,10 +121,10 @@ function waitUntilEnded(video) {
* suspend timer. * suspend timer.
*/ */
function testSuspendTimerStartedWhenHidden(video) { function testSuspendTimerStartedWhenHidden(video) {
var p = once(video, "mozstartvideosuspendtimer").then(() => { var p = once(video, 'mozstartvideosuspendtimer').then(() => {
ok(true, `${video.token} suspend begins`); ok(true, `${video.token} suspend begins`)
}); });
Log(video.token, "Set Hidden"); Log(video.token, 'Set Hidden');
video.setVisible(false); video.setVisible(false);
return p; return p;
} }
@ -154,7 +134,7 @@ function testSuspendTimerStartedWhenHidden(video) {
* @returns {Promise} Promise that is resolved when video decode suspends. * @returns {Promise} Promise that is resolved when video decode suspends.
*/ */
function testVideoSuspendsWhenHidden(video) { function testVideoSuspendsWhenHidden(video) {
let p = once(video, "mozentervideosuspend").then(() => { let p = once(video, 'mozentervideosuspend').then(() => {
ok(true, `${video.token} suspends`); ok(true, `${video.token} suspends`);
}); });
Log(video.token, "Set hidden"); Log(video.token, "Set hidden");
@ -167,7 +147,7 @@ function testVideoSuspendsWhenHidden(video) {
* @returns {Promise} Promise that is resolved when video decode resumes. * @returns {Promise} Promise that is resolved when video decode resumes.
*/ */
function testVideoResumesWhenShown(video) { function testVideoResumesWhenShown(video) {
var p = once(video, "mozexitvideosuspend").then(() => { var p = once(video, 'mozexitvideosuspend').then(() => {
ok(true, `${video.token} resumes`); ok(true, `${video.token} resumes`);
}); });
Log(video.token, "Set visible"); Log(video.token, "Set visible");
@ -180,7 +160,7 @@ function testVideoResumesWhenShown(video) {
* @returns {Promise} Promise that is resolved when video decode resumes. * @returns {Promise} Promise that is resolved when video decode resumes.
*/ */
function testVideoOnlySeekCompletedWhenShown(video) { function testVideoOnlySeekCompletedWhenShown(video) {
var p = once(video, "mozvideoonlyseekcompleted").then(() => { var p = once(video, 'mozvideoonlyseekcompleted').then(() => {
ok(true, `${video.token} resumes`); ok(true, `${video.token} resumes`);
}); });
Log(video.token, "Set visible"); Log(video.token, "Set visible");
@ -194,12 +174,8 @@ function testVideoOnlySeekCompletedWhenShown(video) {
*/ */
function checkVideoDoesntSuspend(video) { function checkVideoDoesntSuspend(video) {
let p = Promise.race([ let p = Promise.race([
waitUntilEnded(video).then(() => { waitUntilEnded(video).then(() => { ok(true, `${video.token} ended before decode was suspended`) }),
ok(true, `${video.token} ended before decode was suspended`); once(video, 'mozentervideosuspend', () => { Promise.reject(new Error(`${video.token} suspended`)) })
}),
once(video, "mozentervideosuspend", () => {
Promise.reject(new Error(`${video.token} suspended`));
}),
]); ]);
Log(video.token, "Set hidden."); Log(video.token, "Set hidden.");
video.setVisible(false); video.setVisible(false);
@ -214,7 +190,7 @@ function checkVideoDoesntSuspend(video) {
function waitTil(video, time) { function waitTil(video, time) {
Log(video.token, `Waiting for time to reach ${time}s`); Log(video.token, `Waiting for time to reach ${time}s`);
return new Promise(resolve => { return new Promise(resolve => {
video.addEventListener("timeupdate", function timeUpdateEvent() { video.addEventListener('timeupdate', function timeUpdateEvent() {
if (video.currentTime > time) { if (video.currentTime > time) {
video.removeEventListener(name, timeUpdateEvent); video.removeEventListener(name, timeUpdateEvent);
resolve(); resolve();

View file

@ -11,10 +11,10 @@ function check_dash(v, enabled) {
check("application/dash+xml; codecs=vorbis", "probably"); check("application/dash+xml; codecs=vorbis", "probably");
check("application/dash+xml; codecs=vorbis,vp8", "probably"); check("application/dash+xml; codecs=vorbis,vp8", "probably");
check("application/dash+xml; codecs=vorbis,vp8.0", "probably"); check("application/dash+xml; codecs=vorbis,vp8.0", "probably");
check('application/dash+xml; codecs="vorbis,vp8"', "probably"); check("application/dash+xml; codecs=\"vorbis,vp8\"", "probably");
check('application/dash+xml; codecs="vorbis,vp8.0"', "probably"); check("application/dash+xml; codecs=\"vorbis,vp8.0\"", "probably");
check('application/dash+xml; codecs="vp8, vorbis"', "probably"); check("application/dash+xml; codecs=\"vp8, vorbis\"", "probably");
check('application/dash+xml; codecs="vp8.0, vorbis"', "probably"); check("application/dash+xml; codecs=\"vp8.0, vorbis\"", "probably");
check("application/dash+xml; codecs=vp8", "probably"); check("application/dash+xml; codecs=vp8", "probably");
check("application/dash+xml; codecs=vp8.0", "probably"); check("application/dash+xml; codecs=vp8.0", "probably");

View file

@ -1,3 +1,4 @@
function check_ogg(v, enabled, finish) { function check_ogg(v, enabled, finish) {
function check(type, expected) { function check(type, expected) {
is(v.canPlayType(type), enabled ? expected : "", type); is(v.canPlayType(type), enabled ? expected : "", type);
@ -14,7 +15,7 @@ function check_ogg(v, enabled, finish) {
check("audio/ogg; codecs=vorbis", "probably"); check("audio/ogg; codecs=vorbis", "probably");
check("video/ogg; codecs=vorbis", "probably"); check("video/ogg; codecs=vorbis", "probably");
check("video/ogg; codecs=vorbis,theora", "probably"); check("video/ogg; codecs=vorbis,theora", "probably");
check('video/ogg; codecs="vorbis, theora"', "probably"); check("video/ogg; codecs=\"vorbis, theora\"", "probably");
check("video/ogg; codecs=theora", "probably"); check("video/ogg; codecs=theora", "probably");
resolve(); resolve();
@ -24,33 +25,31 @@ function check_ogg(v, enabled, finish) {
// Verify Opus support // Verify Opus support
function verify_opus_support() { function verify_opus_support() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var OpusEnabled = SpecialPowers.getBoolPref( var OpusEnabled = undefined;
"media.opus.enabled", try {
undefined OpusEnabled = SpecialPowers.getBoolPref("media.opus.enabled");
); } catch (ex) {
// SpecialPowers failed, perhaps because Opus isn't compiled in
console.log("media.opus.enabled pref not found; skipping Opus validation");
}
if (OpusEnabled != undefined) { if (OpusEnabled != undefined) {
resolve(); resolve();
} else { } else {
console.log(
"media.opus.enabled pref not found; skipping Opus validation"
);
reject(); reject();
} }
}); });
} }
function opus_enable() { function opus_enable() {
return SpecialPowers.pushPrefEnv({ return SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', true]]})
set: [["media.opus.enabled", true]], .then(function() {
}).then(function() {
check("audio/ogg; codecs=opus", "probably"); check("audio/ogg; codecs=opus", "probably");
}); });
} }
function opus_disable() { function opus_disable() {
return SpecialPowers.pushPrefEnv({ return SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', false]]})
set: [["media.opus.enabled", false]], .then(function() {
}).then(function() {
check("audio/ogg; codecs=opus", ""); check("audio/ogg; codecs=opus", "");
}); });
} }
@ -69,4 +68,5 @@ function check_ogg(v, enabled, finish) {
.then(opus_enable) .then(opus_enable)
.then(opus_disable) .then(opus_disable)
.then(unspported_ogg, unspported_ogg); .then(unspported_ogg, unspported_ogg);
} }

View file

@ -15,15 +15,15 @@ function check_wave(v, enabled) {
check("audio/wave; codecs=7", "probably"); check("audio/wave; codecs=7", "probably");
// "no codecs" should be supported, I guess // "no codecs" should be supported, I guess
check("audio/wave; codecs=", "maybe"); check("audio/wave; codecs=", "maybe");
check('audio/wave; codecs=""', "maybe"); check("audio/wave; codecs=\"\"", "maybe");
// Unsupported Wave codecs // Unsupported Wave codecs
check("audio/wave; codecs=0", ""); check("audio/wave; codecs=0", "");
check("audio/wave; codecs=2", ""); check("audio/wave; codecs=2", "");
check("audio/wave; codecs=xyz,1", ""); check("audio/wave; codecs=xyz,1", "");
check("audio/wave; codecs=1,xyz", ""); check("audio/wave; codecs=1,xyz", "");
check('audio/wave; codecs="xyz, 1"', ""); check("audio/wave; codecs=\"xyz, 1\"", "");
// empty codec names // empty codec names
check("audio/wave; codecs=,", ""); check("audio/wave; codecs=,", "");
check('audio/wave; codecs="0, 1,"', ""); check("audio/wave; codecs=\"0, 1,\"", "");
} }

View file

@ -1,18 +1,14 @@
async function check_webm(v, enabled) { async function check_webm(v, enabled) {
function check(type, expected) { function check(type, expected) {
is( is(v.canPlayType(type), enabled ? expected : "", type + "='" + expected + "'");
v.canPlayType(type),
enabled ? expected : "",
type + "='" + expected + "'"
);
} }
// WebM types // WebM types
check("video/webm", "maybe"); check("video/webm", "maybe");
check("audio/webm", "maybe"); check("audio/webm", "maybe");
var video = ["vp8", "vp8.0", "vp9", "vp9.0"]; var video = ['vp8', 'vp8.0', 'vp9', 'vp9.0'];
var audio = ["vorbis", "opus"]; var audio = ['vorbis', 'opus'];
audio.forEach(function(acodec) { audio.forEach(function(acodec) {
check("audio/webm; codecs=" + acodec, "probably"); check("audio/webm; codecs=" + acodec, "probably");
@ -21,8 +17,8 @@ async function check_webm(v, enabled) {
video.forEach(function(vcodec) { video.forEach(function(vcodec) {
check("video/webm; codecs=" + vcodec, "probably"); check("video/webm; codecs=" + vcodec, "probably");
audio.forEach(function(acodec) { audio.forEach(function(acodec) {
check('video/webm; codecs="' + vcodec + ", " + acodec + '"', "probably"); check("video/webm; codecs=\"" + vcodec + ", " + acodec + "\"", "probably");
check('video/webm; codecs="' + acodec + ", " + vcodec + '"', "probably"); check("video/webm; codecs=\"" + acodec + ", " + vcodec + "\"", "probably");
}); });
}); });
@ -31,9 +27,17 @@ async function check_webm(v, enabled) {
check("video/webm; codecs=xyz,vorbis", ""); check("video/webm; codecs=xyz,vorbis", "");
check("video/webm; codecs=vorbis,xyz", ""); check("video/webm; codecs=vorbis,xyz", "");
await SpecialPowers.pushPrefEnv({ set: [["media.av1.enabled", true]] }); function getPref(name) {
check('video/webm; codecs="av1"', "probably"); var pref = false;
try {
pref = SpecialPowers.getBoolPref(name);
} catch(ex) { }
return pref;
}
await SpecialPowers.pushPrefEnv({ set: [["media.av1.enabled", false]] }); await SpecialPowers.pushPrefEnv({"set": [["media.av1.enabled", true]]});
check('video/webm; codecs="av1"', ""); check("video/webm; codecs=\"av1\"", "probably");
await SpecialPowers.pushPrefEnv({"set": [["media.av1.enabled", false]]});
check("video/webm; codecs=\"av1\"", "");
} }

View file

@ -4,20 +4,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/frame-script */
"use strict"; "use strict";
// eslint-disable-next-line mozilla/use-services const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
const dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService( getService(Ci.nsIProperties);
Ci.nsIProperties
);
addMessageListener("media-test:getcwd", () => { addMessageListener('media-test:getcwd', () => {
let cwd; let cwd;
try { try {
cwd = dirSvc.get("CurWorkD", Ci.nsIFile).path; cwd = dirSvc.get("CurWorkD", Ci.nsIFile).path;
} finally { } finally {
sendAsyncMessage("media-test:cwd", cwd); sendAsyncMessage('media-test:cwd', cwd);
} }
}); });

View file

@ -1,7 +1,5 @@
const TEST_VIDEO_1 = const TEST_VIDEO_1 = "http://mochi.test:8888/tests/dom/media/test/bipbop_225w_175kbps.mp4";
"http://mochi.test:8888/tests/dom/media/test/bipbop_225w_175kbps.mp4"; const TEST_VIDEO_2 = "http://mochi.test:8888/tests/dom/media/test/pixel_aspect_ratio.mp4";
const TEST_VIDEO_2 =
"http://mochi.test:8888/tests/dom/media/test/pixel_aspect_ratio.mp4";
const LONG_VIDEO = "http://mochi.test:8888/tests/dom/media/test/gizmo.mp4"; const LONG_VIDEO = "http://mochi.test:8888/tests/dom/media/test/gizmo.mp4";
/** /**
@ -11,11 +9,11 @@ const LONG_VIDEO = "http://mochi.test:8888/tests/dom/media/test/gizmo.mp4";
async function setup() { async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [
["media.test.video-suspend", true], [ "media.test.video-suspend", true ],
["media.suspend-bkgnd-video.enabled", true], [ "media.suspend-bkgnd-video.enabled", true ],
["media.suspend-bkgnd-video.delay-ms", 500], [ "media.suspend-bkgnd-video.delay-ms", 500 ],
["media.dormant-on-pause-timeout-ms", 0], [ "media.dormant-on-pause-timeout-ms", 0 ],
["media.cloneElementVisually.testing", true], [ "media.cloneElementVisually.testing", true ],
], ],
}); });
@ -91,19 +89,11 @@ async function assertVideosMatch(video1, video2) {
let video2Frame = captureFrameImageData(video2); let video2Frame = captureFrameImageData(video2);
let left = document.getElementById("left"); let left = document.getElementById("left");
let leftCtx = getWrappedScaledCanvasContext( let leftCtx = getWrappedScaledCanvasContext(left, video1Frame.width, video1Frame.height);
left,
video1Frame.width,
video1Frame.height
);
leftCtx.putImageData(video1Frame, 0, 0); leftCtx.putImageData(video1Frame, 0, 0);
let right = document.getElementById("right"); let right = document.getElementById("right");
let rightCtx = getWrappedScaledCanvasContext( let rightCtx = getWrappedScaledCanvasContext(right, video2Frame.width, video2Frame.height);
right,
video2Frame.width,
video2Frame.height
);
rightCtx.putImageData(video2Frame, 0, 0); rightCtx.putImageData(video2Frame, 0, 0);
if (video1Frame.data.length != video2Frame.data.length) { if (video1Frame.data.length != video2Frame.data.length) {
@ -220,7 +210,7 @@ async function ensureVideoSuspendable(video) {
video.setVisible(false); video.setVisible(false);
await suspendPromise; await suspendPromise;
ok(true, "Suspended after the video was made invisible."); ok(true, "Suspended after the video was made invisible.");
video.setVisible(true); video.setVisible(true)
ok(!video.hasSuspendTaint(), "Should still be suspendable."); ok(!video.hasSuspendTaint(), "Should still be suspendable.");
@ -230,3 +220,5 @@ async function ensureVideoSuspendable(video) {
ok(true, "Shutdown decoder after the video was paused."); ok(true, "Shutdown decoder after the video was paused.");
await video.play(); await video.play();
} }

View file

@ -1,14 +1,10 @@
/* import-globals-from manifest.js */
const CLEARKEY_KEYSYSTEM = "org.w3.clearkey"; const CLEARKEY_KEYSYSTEM = "org.w3.clearkey";
const gCencMediaKeySystemConfig = [ const gCencMediaKeySystemConfig = [{
{ initDataTypes: ['cenc'],
initDataTypes: ["cenc"], videoCapabilities: [{ contentType: 'video/mp4' }],
videoCapabilities: [{ contentType: "video/mp4" }], audioCapabilities: [{ contentType: 'audio/mp4' }],
audioCapabilities: [{ contentType: "audio/mp4" }], }];
},
];
function IsMacOSSnowLeopardOrEarlier() { function IsMacOSSnowLeopardOrEarlier() {
var re = /Mac OS X (\d+)\.(\d+)/; var re = /Mac OS X (\d+)\.(\d+)/;
@ -21,21 +17,23 @@ function IsMacOSSnowLeopardOrEarlier() {
return major == 10 && minor <= 6; return major == 10 && minor <= 6;
} }
function bail(message) { function bail(message)
{
return function(err) { return function(err) {
if (err) { if (err) {
message += "; " + String(err); message += "; " + String(err)
} }
ok(false, message); ok(false, message);
if (err) { if (err) {
info(String(err)); info(String(err));
} }
SimpleTest.finish(); SimpleTest.finish();
}; }
} }
function ArrayBufferToString(arr) { function ArrayBufferToString(arr)
var str = ""; {
var str = '';
var view = new Uint8Array(arr); var view = new Uint8Array(arr);
for (var i = 0; i < view.length; i++) { for (var i = 0; i < view.length; i++) {
str += String.fromCharCode(view[i]); str += String.fromCharCode(view[i]);
@ -43,7 +41,8 @@ function ArrayBufferToString(arr) {
return str; return str;
} }
function StringToArrayBuffer(str) { function StringToArrayBuffer(str)
{
var arr = new ArrayBuffer(str.length); var arr = new ArrayBuffer(str.length);
var view = new Uint8Array(arr); var view = new Uint8Array(arr);
for (var i = 0; i < str.length; i++) { for (var i = 0; i < str.length; i++) {
@ -52,7 +51,7 @@ function StringToArrayBuffer(str) {
return arr; return arr;
} }
function StringToHex(str) { function StringToHex(str){
var res = ""; var res = "";
for (var i = 0; i < str.length; ++i) { for (var i = 0; i < str.length; ++i) {
res += ("0" + str.charCodeAt(i).toString(16)).slice(-2); res += ("0" + str.charCodeAt(i).toString(16)).slice(-2);
@ -60,7 +59,8 @@ function StringToHex(str) {
return res; return res;
} }
function Base64ToHex(str) { function Base64ToHex(str)
{
var bin = window.atob(str.replace(/-/g, "+").replace(/_/g, "/")); var bin = window.atob(str.replace(/-/g, "+").replace(/_/g, "/"));
var res = ""; var res = "";
for (var i = 0; i < bin.length; i++) { for (var i = 0; i < bin.length; i++) {
@ -69,56 +69,46 @@ function Base64ToHex(str) {
return res; return res;
} }
function HexToBase64(hex) { function HexToBase64(hex)
{
var bin = ""; var bin = "";
for (var i = 0; i < hex.length; i += 2) { for (var i = 0; i < hex.length; i += 2) {
bin += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); bin += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
} }
return window return window.btoa(bin).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
.btoa(bin)
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
} }
function TimeRangesToString(trs) { function TimeRangesToString(trs)
{
var l = trs.length; var l = trs.length;
if (l === 0) { if (l === 0) { return "-"; }
return "-";
}
var s = ""; var s = "";
var i = 0; var i = 0;
for (;;) { for (;;) {
s += trs.start(i) + "-" + trs.end(i); s += trs.start(i) + "-" + trs.end(i);
if (++i === l) { if (++i === l) { return s; }
return s;
}
s += ","; s += ",";
} }
} }
function SourceBufferToString(sb) { function SourceBufferToString(sb)
return ( {
"SourceBuffer{" + return ("SourceBuffer{"
"AppendMode=" + + "AppendMode=" + (sb.AppendMode || "-")
(sb.AppendMode || "-") + + ", updating=" + (sb.updating ? "true" : "false")
", updating=" + + ", buffered=" + TimeRangesToString(sb.buffered)
(sb.updating ? "true" : "false") + + ", audioTracks=" + (sb.audioTracks ? sb.audioTracks.length : "-")
", buffered=" + + ", videoTracks=" + (sb.videoTracks ? sb.videoTracks.length : "-")
TimeRangesToString(sb.buffered) + + "}");
", audioTracks=" +
(sb.audioTracks ? sb.audioTracks.length : "-") +
", videoTracks=" +
(sb.videoTracks ? sb.videoTracks.length : "-") +
"}"
);
} }
function SourceBufferListToString(sbl) { function SourceBufferListToString(sbl)
{
return "SourceBufferList[" + sbl.map(SourceBufferToString).join(", ") + "]"; return "SourceBufferList[" + sbl.map(SourceBufferToString).join(", ") + "]";
} }
function GenerateClearKeyLicense(licenseRequest, keyStore) { function GenerateClearKeyLicense(licenseRequest, keyStore)
{
var msgStr = ArrayBufferToString(licenseRequest); var msgStr = ArrayBufferToString(licenseRequest);
var msg = JSON.parse(msgStr); var msg = JSON.parse(msgStr);
@ -130,51 +120,47 @@ function GenerateClearKeyLicense(licenseRequest, keyStore) {
if (key) { if (key) {
keys.push({ keys.push({
kty: "oct", "kty": "oct",
kid: id64, "kid": id64,
k: HexToBase64(key), "k": HexToBase64(key)
}); });
} }
} }
return new TextEncoder().encode( return new TextEncoder().encode(JSON.stringify({
JSON.stringify({ "keys" : keys,
keys, "type" : msg.type || "temporary"
type: msg.type || "temporary", }));
})
);
} }
function UpdateSessionFunc(test, token, sessionType, resolve, reject) { function UpdateSessionFunc(test, token, sessionType, resolve, reject) {
return function(ev) { return function(ev) {
var license = GenerateClearKeyLicense(ev.message, test.keys); var license = GenerateClearKeyLicense(ev.message, test.keys);
Log( Log(token, "sending update message to CDM: " + (new TextDecoder().decode(license)));
token, ev.target.update(license).then(function() {
"sending update message to CDM: " + new TextDecoder().decode(license)
);
ev.target
.update(license)
.then(function() {
Log(token, "MediaKeySession update ok!"); Log(token, "MediaKeySession update ok!");
resolve(ev.target); resolve(ev.target);
}) }).catch(function(reason) {
.catch(function(reason) {
reject(`${token} MediaKeySession update failed: ${reason}`); reject(`${token} MediaKeySession update failed: ${reason}`);
}); });
}; }
} }
function MaybeCrossOriginURI(test, uri) { function MaybeCrossOriginURI(test, uri)
{
if (test.crossOrigin) { if (test.crossOrigin) {
return "https://example.com:443/tests/dom/media/test/allowed.sjs?" + uri; return "https://example.com:443/tests/dom/media/test/allowed.sjs?" + uri;
} } else {
return uri; return uri;
}
} }
function AppendTrack(test, ms, track, token) { function AppendTrack(test, ms, track, token)
{
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var sb; var sb;
var curFragment = 0; var curFragment = 0;
var resolved = false;
var fragments = track.fragments; var fragments = track.fragments;
var fragmentFile; var fragmentFile;
@ -182,6 +168,7 @@ function AppendTrack(test, ms, track, token) {
if (curFragment >= fragments.length) { if (curFragment >= fragments.length) {
Log(token, track.name + ": end of track"); Log(token, track.name + ": end of track");
resolve(); resolve();
resolved = true;
return; return;
} }
@ -192,10 +179,7 @@ function AppendTrack(test, ms, track, token) {
req.responseType = "arraybuffer"; req.responseType = "arraybuffer";
req.addEventListener("load", function() { req.addEventListener("load", function() {
Log( Log(token, track.name + ": fetch of " + fragmentFile + " complete, appending");
token,
track.name + ": fetch of " + fragmentFile + " complete, appending"
);
sb.appendBuffer(new Uint8Array(req.response)); sb.appendBuffer(new Uint8Array(req.response));
}); });
@ -206,26 +190,14 @@ function AppendTrack(test, ms, track, token) {
reject(`${token} - ${track.name}: aborted fetching ${fragmentFile}`); reject(`${token} - ${track.name}: aborted fetching ${fragmentFile}`);
}); });
Log( Log(token, track.name + ": addNextFragment() fetching next fragment " + fragmentFile);
token,
track.name +
": addNextFragment() fetching next fragment " +
fragmentFile
);
req.send(null); req.send(null);
} }
Log(token, track.name + ": addSourceBuffer(" + track.type + ")"); Log(token, track.name + ": addSourceBuffer(" + track.type + ")");
sb = ms.addSourceBuffer(track.type); sb = ms.addSourceBuffer(track.type);
sb.addEventListener("updateend", function() { sb.addEventListener("updateend", function() {
Log( Log(token, track.name + ": updateend for " + fragmentFile + ", " + SourceBufferToString(sb));
token,
track.name +
": updateend for " +
fragmentFile +
", " +
SourceBufferToString(sb)
);
addNextFragment(); addNextFragment();
}); });
@ -235,7 +207,8 @@ function AppendTrack(test, ms, track, token) {
//Returns a promise that is resolved when the media element is ready to have //Returns a promise that is resolved when the media element is ready to have
//its play() function called; when it's loaded MSE fragments. //its play() function called; when it's loaded MSE fragments.
function LoadTest(test, elem, token, endOfStream = true) { function LoadTest(test, elem, token, endOfStream = true)
{
if (!test.tracks) { if (!test.tracks) {
ok(false, token + " test does not have a tracks list"); ok(false, token + " test does not have a tracks list");
return Promise.reject(); return Promise.reject();
@ -245,27 +218,19 @@ function LoadTest(test, elem, token, endOfStream = true) {
elem.src = URL.createObjectURL(ms); elem.src = URL.createObjectURL(ms);
elem.crossOrigin = test.crossOrigin || false; elem.crossOrigin = test.crossOrigin || false;
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
ms.addEventListener( ms.addEventListener("sourceopen", function () {
"sourceopen",
function() {
Log(token, "sourceopen"); Log(token, "sourceopen");
Promise.all( Promise.all(test.tracks.map(function(track) {
test.tracks.map(function(track) {
return AppendTrack(test, ms, track, token); return AppendTrack(test, ms, track, token);
}) })).then(function() {
)
.then(function() {
Log(token, "Tracks loaded, calling MediaSource.endOfStream()"); Log(token, "Tracks loaded, calling MediaSource.endOfStream()");
if (endOfStream) { if (endOfStream) {
ms.endOfStream(); ms.endOfStream();
} }
resolve(); resolve();
}) }).catch(reject);
.catch(reject); }, {once: true});
},
{ once: true }
);
}); });
} }
@ -283,7 +248,7 @@ function EMEPromise() {
* or will be rejected with a string that describes the failure. * or will be rejected with a string that describes the failure.
*/ */
function CreateMediaKeys(v, test, token) { function CreateMediaKeys(v, test, token) {
let p = new EMEPromise(); let p = new EMEPromise;
function streamType(type) { function streamType(type) {
var x = test.tracks.find(o => o.name == type); var x = test.tracks.find(o => o.name == type);
@ -293,24 +258,21 @@ function CreateMediaKeys(v, test, token) {
function onencrypted(ev) { function onencrypted(ev) {
var options = { initDataTypes: [ev.initDataType] }; var options = { initDataTypes: [ev.initDataType] };
if (streamType("video")) { if (streamType("video")) {
options.videoCapabilities = [{ contentType: streamType("video") }]; options.videoCapabilities = [{contentType: streamType("video")}];
} }
if (streamType("audio")) { if (streamType("audio")) {
options.audioCapabilities = [{ contentType: streamType("audio") }]; options.audioCapabilities = [{contentType: streamType("audio")}];
} }
navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, [options]).then( navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, [options])
keySystemAccess => { .then(keySystemAccess => {
keySystemAccess keySystemAccess.createMediaKeys().then(
.createMediaKeys() p.resolve,
.then(p.resolve, () => () => p.reject(`${token} Failed to create MediaKeys object.`)
p.reject(`${token} Failed to create MediaKeys object.`)
);
},
() => p.reject(`${token} Failed to request key system access.`)
); );
}, () => p.reject(`${token} Failed to request key system access.`));
} }
v.addEventListener("encrypted", onencrypted, { once: true }); v.addEventListener("encrypted", onencrypted, {once: true});
return p.promise; return p.promise;
} }
@ -320,13 +282,14 @@ function CreateMediaKeys(v, test, token) {
* with a string that describes the failure. * with a string that describes the failure.
*/ */
function CreateAndSetMediaKeys(v, test, token) { function CreateAndSetMediaKeys(v, test, token) {
let p = new EMEPromise(); let p = new EMEPromise;
CreateMediaKeys(v, test, token).then(mediaKeys => { CreateMediaKeys(v, test, token).then(mediaKeys => {
v.setMediaKeys(mediaKeys).then(p.resolve, () => v.setMediaKeys(mediaKeys).then(
p.reject(`${token} Failed to set MediaKeys on <video> element.`) p.resolve,
() => p.reject(`${token} Failed to set MediaKeys on <video> element.`)
); );
}, p.reject); }, p.reject)
return p.promise; return p.promise;
} }
@ -337,25 +300,18 @@ function CreateAndSetMediaKeys(v, test, token) {
* is completed (specified by test.sessionCount). * is completed (specified by test.sessionCount).
*/ */
function LoadInitData(v, test, token) { function LoadInitData(v, test, token) {
let p = new EMEPromise(); let p = new EMEPromise;
let initDataQueue = []; let initDataQueue = [];
// Call SimpleTest._originalSetTimeout() to bypass the flaky timeout checker. // Call SimpleTest._originalSetTimeout() to bypass the flaky timeout checker.
let timer = SimpleTest._originalSetTimeout.call( let timer = SimpleTest._originalSetTimeout.call(window, () => {
window,
() => {
p.reject(`${token} Timed out in waiting for the init data.`); p.reject(`${token} Timed out in waiting for the init data.`);
}, }, 60000);
60000
);
function onencrypted(ev) { function onencrypted(ev) {
initDataQueue.push(ev); initDataQueue.push(ev);
Log( Log(token, `got encrypted(${ev.initDataType}, ` +
token, `${StringToHex(ArrayBufferToString(ev.initData))}) event.`);
`got encrypted(${ev.initDataType}, ` +
`${StringToHex(ArrayBufferToString(ev.initData))}) event.`
);
if (test.sessionCount == initDataQueue.length) { if (test.sessionCount == initDataQueue.length) {
p.resolve(initDataQueue); p.resolve(initDataQueue);
clearTimeout(timer); clearTimeout(timer);
@ -373,18 +329,16 @@ function LoadInitData(v, test, token) {
*/ */
function MakeRequest(test, token, ev, session, sessionType) { function MakeRequest(test, token, ev, session, sessionType) {
sessionType = sessionType || "temporary"; sessionType = sessionType || "temporary";
let p = new EMEPromise(); let p = new EMEPromise;
let str = let str = `session[${session.sessionId}].generateRequest(` +
`session[${session.sessionId}].generateRequest(` +
`${ev.initDataType}, ${StringToHex(ArrayBufferToString(ev.initData))})`; `${ev.initDataType}, ${StringToHex(ArrayBufferToString(ev.initData))})`;
session.addEventListener( session.addEventListener("message",
"message", UpdateSessionFunc(test, token, sessionType, p.resolve, p.reject));
UpdateSessionFunc(test, token, sessionType, p.resolve, p.reject)
);
Log(token, str); Log(token, str);
session.generateRequest(ev.initDataType, ev.initData).catch(reason => { session.generateRequest(ev.initDataType, ev.initData)
.catch(reason => {
// Reject the promise if generateRequest() failed. // Reject the promise if generateRequest() failed.
// Otherwise it will be resolved in UpdateSessionFunc(). // Otherwise it will be resolved in UpdateSessionFunc().
p.reject(`${token}: ${str} failed; ${reason}`); p.reject(`${token}: ${str} failed; ${reason}`);
@ -421,7 +375,8 @@ function CleanUpMedia(v) {
* Close all sessions and clean up the |v| element. * Close all sessions and clean up the |v| element.
*/ */
function CloseSessions(v, sessions) { function CloseSessions(v, sessions) {
return Promise.all(sessions.map(s => s.close())).then(CleanUpMedia(v)); return Promise.all(sessions.map(s => s.close()))
.then(CleanUpMedia(v));
} }
/* /*
@ -430,17 +385,16 @@ function CloseSessions(v, sessions) {
* if any failure. * if any failure.
*/ */
function SetupEME(v, test, token) { function SetupEME(v, test, token) {
let p = new EMEPromise(); let p = new EMEPromise;
v.onerror = function() { v.onerror = function() {
p.reject(`${token} got an error event.`); p.reject(`${token} got an error event.`);
}; }
Promise.all([ Promise.all([
LoadInitData(v, test, token), LoadInitData(v, test, token),
CreateAndSetMediaKeys(v, test, token), CreateAndSetMediaKeys(v, test, token),
LoadTest(test, v, token), LoadTest(test, v, token)])
])
.then(values => { .then(values => {
let initData = values[0]; let initData = values[0];
return ProcessInitData(v, test, token, initData); return ProcessInitData(v, test, token, initData);
@ -452,19 +406,17 @@ function SetupEME(v, test, token) {
function SetupEMEPref(callback) { function SetupEMEPref(callback) {
var prefs = [ var prefs = [
["media.mediasource.enabled", true], [ "media.mediasource.enabled", true ],
["media.mediasource.webm.enabled", true], [ "media.mediasource.webm.enabled", true ],
]; ];
if ( if (SpecialPowers.Services.appinfo.name == "B2G" ||
SpecialPowers.Services.appinfo.name == "B2G" || !manifestVideo().canPlayType("video/mp4")) {
!manifestVideo().canPlayType("video/mp4")
) {
// XXX remove once we have mp4 PlatformDecoderModules on all platforms. // XXX remove once we have mp4 PlatformDecoderModules on all platforms.
prefs.push(["media.use-blank-decoder", true]); prefs.push([ "media.use-blank-decoder", true ]);
} }
SpecialPowers.pushPrefEnv({ set: prefs }, callback); SpecialPowers.pushPrefEnv({ "set" : prefs }, callback);
} }
function fetchWithXHR(uri, onLoadFunction) { function fetchWithXHR(uri, onLoadFunction) {
@ -472,12 +424,8 @@ function fetchWithXHR(uri, onLoadFunction) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("GET", uri, true); xhr.open("GET", uri, true);
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";
xhr.addEventListener("load", function() { xhr.addEventListener("load", function () {
is( is(xhr.status, 200, "fetchWithXHR load uri='" + uri + "' status=" + xhr.status);
xhr.status,
200,
"fetchWithXHR load uri='" + uri + "' status=" + xhr.status
);
resolve(xhr.response); resolve(xhr.response);
}); });
xhr.send(); xhr.send();
@ -488,17 +436,13 @@ function fetchWithXHR(uri, onLoadFunction) {
} }
return p; return p;
} };
function once(target, name, cb) { function once(target, name, cb) {
var p = new Promise(function(resolve, reject) { var p = new Promise(function(resolve, reject) {
target.addEventListener( target.addEventListener(name, function(arg) {
name,
function(arg) {
resolve(arg); resolve(arg);
}, }, {once: true});
{ once: true }
);
}); });
if (cb) { if (cb) {
p.then(cb); p.then(cb);

View file

@ -23,7 +23,7 @@
} else if (event.data == "play-muted") { } else if (event.data == "play-muted") {
playAndPostResult(true, event.source); playAndPostResult(true, event.source);
} }
}); }, false);
let w = window.opener || window.parent; let w = window.opener || window.parent;
w.postMessage("ready", "*"); w.postMessage("ready", "*");
</script> </script>

View file

@ -36,12 +36,12 @@
let x = eventNames.map( let x = eventNames.map(
(eventName) => { (eventName) => {
return new Promise(function (resolve, reject) { return new Promise(async function (resolve, reject) {
window.addEventListener(eventName, async function (event) { window.addEventListener(eventName, async function (event) {
let p = await element.play().then(() => true, () => false); let played = await element.play().then(() => true, () => false);
ok(p, "Expect to be activated already in " + eventName); ok(played, "Expect to be activated already in " + eventName);
resolve(); resolve();
}); }, false);
}); });
}); });

View file

@ -1,19 +1,14 @@
function test_fragment_noplay(v, start, end, is, ok, finish) { function test_fragment_noplay(v, start, end, is, ok, finish) {
function onLoadedMetadata() {
function onLoadedMetadata() {
var s = start == null ? 0 : start; var s = start == null ? 0 : start;
var e = end == null ? v.duration : end; var e = end == null ? v.duration : end;
var a = s - 0.15; var a = s - 0.15;
var b = s + 0.15; var b = s + 0.15;
ok( ok(v.currentTime >= a && v.currentTime <= b, "loadedmetadata currentTime is " + a + " < " + v.currentTime + " < " + b);
v.currentTime >= a && v.currentTime <= b, ok(v.mozFragmentEnd == e, "mozFragmentEnd (" + v.mozFragmentEnd + ") == end Time (" + e + ")");
"loadedmetadata currentTime is " + a + " < " + v.currentTime + " < " + b
);
ok(
v.mozFragmentEnd == e,
"mozFragmentEnd (" + v.mozFragmentEnd + ") == end Time (" + e + ")"
);
finish(); finish();
} }
v.addEventListener("loadedmetadata", onLoadedMetadata); v.addEventListener("loadedmetadata", onLoadedMetadata);
} }

View file

@ -1,77 +1,52 @@
function test_fragment_play(v, start, end, is, ok, finish) { function test_fragment_play(v, start, end, is, ok, finish) {
var completed = false;
var loadedMetadataRaised = false;
var seekedRaised = false;
var pausedRaised = false;
function onLoadedMetadata() { var completed = false;
var loadedMetadataRaised = false;
var seekedRaised = false;
var pausedRaised = false;
function onLoadedMetadata() {
var s = start == null ? 0 : start; var s = start == null ? 0 : start;
var e = end == null ? v.duration : end; var e = end == null ? v.duration : end;
ok( ok(v.currentTime == s, "loadedmetadata currentTime is " + v.currentTime + " != " + s);
v.currentTime == s, ok(v.mozFragmentEnd == e, "mozFragmentEnd (" + v.mozFragmentEnd + ") == end Time (" + e + ")");
"loadedmetadata currentTime is " + v.currentTime + " != " + s
);
ok(
v.mozFragmentEnd == e,
"mozFragmentEnd (" + v.mozFragmentEnd + ") == end Time (" + e + ")"
);
loadedMetadataRaised = true; loadedMetadataRaised = true;
v.play(); v.play();
} }
function onSeeked() { function onSeeked() {
if (completed) { if (completed)
return; return;
}
var s = start == null ? 0 : start; var s = start == null ? 0 : start;
ok( ok(v.currentTime - s < 0.1, "seeked currentTime is " + v.currentTime + " != " + s + " (fuzzy compare +-0.1)");
v.currentTime - s < 0.1,
"seeked currentTime is " +
v.currentTime +
" != " +
s +
" (fuzzy compare +-0.1)"
);
seekedRaised = true; seekedRaised = true;
} }
function onTimeUpdate() { function onTimeUpdate() {
if (completed) { if (completed)
return; return;
}
v._lastTimeUpdate = v.currentTime; v._lastTimeUpdate = v.currentTime;
} }
function onPause() { function onPause() {
if (completed) { if (completed)
return; return;
}
var e = end == null ? v.duration : end; var e = end == null ? v.duration : end;
var a = e - 0.05; var a = e - 0.05;
var b = e + 0.05; var b = e + 0.05;
ok( ok(v.currentTime >= a && v.currentTime <= b, "paused currentTime is " + a + " < " + v.currentTime + " < " + b + " ? " + v._lastTimeUpdate);
v.currentTime >= a && v.currentTime <= b,
"paused currentTime is " +
a +
" < " +
v.currentTime +
" < " +
b +
" ? " +
v._lastTimeUpdate
);
pausedRaised = true; pausedRaised = true;
v.play(); v.play();
} }
function onEnded() {
if (completed) { function onEnded() {
if (completed)
return; return;
}
completed = true; completed = true;
ok(loadedMetadataRaised, "loadedmetadata event"); ok(loadedMetadataRaised, "loadedmetadata event");
@ -82,11 +57,11 @@ function test_fragment_play(v, start, end, is, ok, finish) {
ok(pausedRaised, "paused event: " + end + " " + v.duration); ok(pausedRaised, "paused event: " + end + " " + v.duration);
} }
finish(); finish();
} }
v.addEventListener("ended", onEnded); v.addEventListener("ended", onEnded);
v.addEventListener("loadedmetadata", onLoadedMetadata); v.addEventListener("loadedmetadata", onLoadedMetadata);
v.addEventListener("seeked", onSeeked); v.addEventListener("seeked", onSeeked);
v.addEventListener("pause", onPause); v.addEventListener("pause", onPause);
v.addEventListener("timeupdate", onTimeUpdate); v.addEventListener("timeupdate", onTimeUpdate);
} }

View file

@ -9,26 +9,17 @@ async function pushGetUserMediaTestPrefs({
fakeAudio = false, fakeAudio = false,
fakeVideo = false, fakeVideo = false,
loopbackAudio = false, loopbackAudio = false,
loopbackVideo = false, loopbackVideo = false}) {
}) {
// Make sure we have sensical arguments // Make sure we have sensical arguments
if (!fakeAudio && !loopbackAudio) { if (!fakeAudio && !loopbackAudio) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Should have fake or loopback audio!");
"pushGetUserMediaTestPrefs: Should have fake or loopback audio!"
);
} else if (fakeAudio && loopbackAudio) { } else if (fakeAudio && loopbackAudio) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Should not have both fake and loopback audio!");
"pushGetUserMediaTestPrefs: Should not have both fake and loopback audio!"
);
} }
if (!fakeVideo && !loopbackVideo) { if (!fakeVideo && !loopbackVideo) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Should have fake or loopback video!");
"pushGetUserMediaTestPrefs: Should have fake or loopback video!"
);
} else if (fakeVideo && loopbackVideo) { } else if (fakeVideo && loopbackVideo) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Should not have both fake and loopback video!");
"pushGetUserMediaTestPrefs: Should not have both fake and loopback video!"
);
} }
let testPrefs = []; let testPrefs = [];
@ -41,15 +32,10 @@ async function pushGetUserMediaTestPrefs({
if (loopbackAudio) { if (loopbackAudio) {
// If audio loopback is requested we expect the test harness to have set // If audio loopback is requested we expect the test harness to have set
// the loopback device pref, make sure it's set // the loopback device pref, make sure it's set
let audioLoopDev = SpecialPowers.getCharPref( let audioLoopDev = SpecialPowers.getCharPref("media.audio_loopback_dev", "");
"media.audio_loopback_dev",
""
);
if (!audioLoopDev) { if (!audioLoopDev) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Loopback audio requested but " +
"pushGetUserMediaTestPrefs: Loopback audio requested but " + "media.audio_loopback_dev does not appear to be set!");
"media.audio_loopback_dev does not appear to be set!"
);
} }
} }
if (fakeVideo) { if (fakeVideo) {
@ -61,23 +47,18 @@ async function pushGetUserMediaTestPrefs({
if (loopbackVideo) { if (loopbackVideo) {
// If video loopback is requested we expect the test harness to have set // If video loopback is requested we expect the test harness to have set
// the loopback device pref, make sure it's set // the loopback device pref, make sure it's set
let videoLoopDev = SpecialPowers.getCharPref( let videoLoopDev = SpecialPowers.getCharPref("media.video_loopback_dev", "");
"media.video_loopback_dev",
""
);
if (!videoLoopDev) { if (!videoLoopDev) {
throw new Error( throw new Error("pushGetUserMediaTestPrefs: Loopback video requested but " +
"pushGetUserMediaTestPrefs: Loopback video requested but " + "media.video_loopback_dev does not appear to be set!");
"media.video_loopback_dev does not appear to be set!"
);
} }
} }
if (loopbackAudio || loopbackVideo) { if (loopbackAudio || loopbackVideo) {
// Prevent gUM permission prompt. Since loopback devices are considered // Prevent gUM permission prompt. Since loopback devices are considered
// real devices we need to set prefs so the gUM prompt isn't presented. // real devices we need to set prefs so the gUM prompt isn't presented.
testPrefs.push(["media.navigator.permission.disabled", true]); testPrefs.push(['media.navigator.permission.disabled', true]);
} }
return SpecialPowers.pushPrefEnv({ set: testPrefs }); return SpecialPowers.pushPrefEnv({set: testPrefs});
} }
// Setup preconditions for tests using getUserMedia. This function will // Setup preconditions for tests using getUserMedia. This function will
@ -85,7 +66,7 @@ async function pushGetUserMediaTestPrefs({
// names already set in the prefs. If no loopback device name can be found then // names already set in the prefs. If no loopback device name can be found then
// prefs are setup such that a fake device is used. // prefs are setup such that a fake device is used.
async function setupGetUserMediaTestPrefs() { async function setupGetUserMediaTestPrefs() {
let prefRequests = {}; prefRequests = {};
let audioLoopDev = SpecialPowers.getCharPref("media.audio_loopback_dev", ""); let audioLoopDev = SpecialPowers.getCharPref("media.audio_loopback_dev", "");
if (audioLoopDev) { if (audioLoopDev) {
prefRequests.fakeAudio = false; prefRequests.fakeAudio = false;

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,18 @@
/* global video, result, resolve */
video.mozRequestDebugInfo().then(debugInfo => { video.mozRequestDebugInfo().then(debugInfo => {
// The parsing won't be necessary once we have bug 1542674 // The parsing won't be necessary once we have bug 1542674
try { try {
debugInfo = debugInfo.replace(/\t/g, "").split(/\n/g); debugInfo = debugInfo.replace(/\t/g, '').split(/\n/g);
var JSONDebugInfo = "{"; var JSONDebugInfo = "{";
for (let g = 0; g < debugInfo.length - 1; g++) { for(let g =0; g<debugInfo.length-1; g++){
var pair = debugInfo[g].split(": "); var pair = debugInfo[g].split(": ");
JSONDebugInfo += '"' + pair[0] + '":"' + pair[1] + '",'; JSONDebugInfo += '"' + pair[0] + '":"' + pair[1] + '",';
} }
JSONDebugInfo = JSONDebugInfo.slice(0, JSONDebugInfo.length - 1); JSONDebugInfo = JSONDebugInfo.slice(0,JSONDebugInfo.length-1);
JSONDebugInfo += "}"; JSONDebugInfo += "}";
result.mozRequestDebugInfo = JSON.parse(JSONDebugInfo); result["mozRequestDebugInfo"] = JSON.parse(JSONDebugInfo);
} catch (err) { } catch (err) {
console.log(`Error '${err.toString()} in JSON.parse(${debugInfo})`); console.log(`Error '${err.toString()} in JSON.parse(${debugInfo})`);
result.mozRequestDebugInfo = debugInfo; result["mozRequestDebugInfo"] = debugInfo;
} }
resolve(result); resolve(result);
}); });

View file

@ -2,29 +2,23 @@
// https://addons.mozilla.org/en-US/firefox/addon/youtube-auto-hd-lq/ // https://addons.mozilla.org/en-US/firefox/addon/youtube-auto-hd-lq/
// licence: MPL 2.0 // licence: MPL 2.0
var config = { var config = {
HD: true, "HD": true,
LQ: false, "LQ": false,
ID: "auto-hd-lq-for-ytb", "ID": "auto-hd-lq-for-ytb",
type(t) { "type": function (t) {
config.HD = t === "hd"; config.HD = t === 'hd';
config.LQ = t === "lq"; config.LQ = t === 'lq';
}, },
quality() { "quality": function () {
if (config.HD || config.LQ) { if (config.HD || config.LQ) {
var youtubePlayerListener = function(LQ, HD) { var youtubePlayerListener = function (LQ, HD) {
return function(e) { return function youtubePlayerListener (e) {
if (e === 1) { if (e === 1) {
var player = document.getElementById("movie_player"); var player = document.getElementById('movie_player');
if (player) { if (player) {
var levels = player.getAvailableQualityLevels(); var levels = player.getAvailableQualityLevels();
if (levels.length) { if (levels.length) {
var q = var q = (HD && levels[0]) ? levels[0] : ((LQ && levels[levels.length - 2]) ? levels[levels.length - 2] : null);
// eslint-disable-next-line no-nested-ternary
HD && levels[0]
? levels[0]
: LQ && levels[levels.length - 2]
? levels[levels.length - 2]
: null;
if (q) { if (q) {
player.setPlaybackQuality(q); player.setPlaybackQuality(q);
player.setPlaybackQualityRange(q, q); player.setPlaybackQualityRange(q, q);
@ -32,17 +26,15 @@ var config = {
} }
} }
} }
}; }
}; }
/* */ /* */
var inject = function() { var inject = function () {
var action = function() { var action = function () {
var player = document.getElementById("movie_player"); var player = document.getElementById('movie_player');
if (player && player.addEventListener && player.getPlayerState) { if (player && player.addEventListener && player.getPlayerState) {
player.addEventListener("onStateChange", "youtubePlayerListener"); player.addEventListener("onStateChange", "youtubePlayerListener");
} else { } else window.setTimeout(action, 1000);
window.setTimeout(action, 1000);
}
}; };
/* */ /* */
action(); action();
@ -55,30 +47,19 @@ var config = {
document.documentElement.appendChild(script); document.documentElement.appendChild(script);
} }
/* */ /* */
script.textContent = script.textContent = "var youtubePlayerListener = (" + youtubePlayerListener + ')(' + config.LQ + ',' + config.HD + ');(' + inject + ')();';
"var youtubePlayerListener = (" + }
youtubePlayerListener +
")(" +
config.LQ +
"," +
config.HD +
");(" +
inject +
")();";
} }
},
}; };
if (/^https?:\/\/www\.youtube.com\/watch\?/.test(document.location.href)) { if (/^https?:\/\/www\.youtube.com\/watch\?/.test(document.location.href)) config.quality();
config.quality(); var content = document.getElementById('content');
} if (content) {
var content = document.getElementById("content"); var observer = new window.MutationObserver(function (e) {
if (content) { e.forEach(function (m) {
var observer = new window.MutationObserver(function(e) {
e.forEach(function(m) {
if (m.addedNodes !== null) { if (m.addedNodes !== null) {
for (var i = 0; i < m.addedNodes.length; i++) { for (var i = 0; i < m.addedNodes.length; i++) {
if (m.addedNodes[i].id === "movie_player") { if (m.addedNodes[i].id === 'movie_player') {
config.quality(); config.quality();
return; return;
} }
@ -87,5 +68,6 @@ if (content) {
}); });
}); });
/* */ /* */
observer.observe(content, { childList: true, subtree: true }); observer.observe(content, {"childList": true, "subtree": true});
} }

View file

@ -1,2 +1 @@
/* global video */ var result = {"getVideoPlaybackQuality": video.getVideoPlaybackQuality()};
var result = { getVideoPlaybackQuality: video.getVideoPlaybackQuality() };

View file

@ -1,20 +1,16 @@
// This file expects manifest.js to be included in the same scope. var manager = new MediaTestManager;
/* import-globals-from manifest.js */
// This file expects SEEK_TEST_NUMBER to be defined by the test.
/* global SEEK_TEST_NUMBER */
var manager = new MediaTestManager();
function createTestArray() { function createTestArray() {
var tests = []; var tests = [];
var tmpVid = document.createElement("video"); var tmpVid = document.createElement("video");
for (var testNum = 0; testNum < gSeekTests.length; testNum++) { for (var testNum=0; testNum<gSeekTests.length; testNum++) {
var test = gSeekTests[testNum]; var test = gSeekTests[testNum];
if (!tmpVid.canPlayType(test.type)) { if (!tmpVid.canPlayType(test.type)) {
continue; continue;
} }
var t = {}; var t = new Object;
t.name = test.name; t.name = test.name;
t.type = test.type; t.type = test.type;
t.duration = test.duration; t.duration = test.duration;
@ -25,37 +21,25 @@ function createTestArray() {
} }
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement("video"); var v = document.createElement('video');
video.token = token += "-seek" + test.number + ".js"; v.token = token += "-seek" + test.number + ".js";
manager.started(video.token); manager.started(v.token);
video.src = test.name; v.src = test.name;
video.preload = "metadata"; v.preload = "metadata";
document.body.appendChild(video); document.body.appendChild(v);
var name = test.name + " seek test " + test.number; var name = test.name + " seek test " + test.number;
var localIs = (function(n) { var localIs = function(name) { return function(a, b, msg) {
return function(a, b, msg) { is(a, b, name + ": " + msg);
is(a, b, n + ": " + msg); }}(name);
}; var localOk = function(name) { return function(a, msg) {
})(name); ok(a, name + ": " + msg);
var localOk = (function(n) { }}(name);
return function(a, msg) { var localFinish = function(v, manager) { return function() {
ok(a, n + ": " + msg);
};
})(name);
var localFinish = (function(v, m) {
return function() {
v.onerror = null; v.onerror = null;
removeNodeAndSource(v); removeNodeAndSource(v);
dump("SEEK-TEST: Finished " + name + " token: " + v.token + "\n"); dump("SEEK-TEST: Finished " + name + " token: " + v.token + "\n");
m.finished(v.token); manager.finished(v.token);
}; }}(v, manager);
})(video, manager);
dump("SEEK-TEST: Started " + name + "\n"); dump("SEEK-TEST: Started " + name + "\n");
window["test_seek" + test.number]( window['test_seek' + test.number](v, test.duration/2, localIs, localOk, localFinish);
video,
test.duration / 2,
localIs,
localOk,
localFinish
);
} }

View file

@ -41,10 +41,8 @@ function receiveMessage(event)
return; return;
} }
if (event.data.done == "true") { if (event.data.done == "true")
done(); return done();
return;
}
ok(event.data.result, event.data.message); ok(event.data.result, event.data.message);
} }

View file

@ -136,7 +136,7 @@
let child_url = "file_autoplay_policy_activation_window.html"; let child_url = "file_autoplay_policy_activation_window.html";
async function runTest() { async function runTest() {
for (const test_case of test_cases) { for (test_case of test_cases) {
// Run each test in a new window, to ensure its user gesture // Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests. // activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");

View file

@ -31,7 +31,7 @@
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load"); await once(child, "load");
child.postMessage("run keydown test", window.origin); child.postMessage("run keydown test", window.origin);
await nextWindowMessage(); let result = await nextWindowMessage();
child.close(); child.close();
} }
@ -39,7 +39,7 @@
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load"); await once(child, "load");
child.postMessage("run mousedown test", window.origin); child.postMessage("run mousedown test", window.origin);
await nextWindowMessage(); let result = await nextWindowMessage();
child.close(); child.close();
} }

View file

@ -33,7 +33,7 @@
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load"); await once(child, "load");
child.postMessage("run test", window.origin); child.postMessage("run test", window.origin);
await nextWindowMessage(); let result = await nextWindowMessage();
child.close(); child.close();
SimpleTest.finish(); SimpleTest.finish();
} }

View file

@ -52,13 +52,13 @@
let child_url = "file_autoplay_policy_play_before_loadedmetadata.html"; let child_url = "file_autoplay_policy_play_before_loadedmetadata.html";
async function runTest() { async function runTest() {
for (const testCase of testCases) { for (testCase of testCases) {
// Run each test in a new window, to ensure its user gesture // Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests. // activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load"); await once(child, "load");
child.postMessage(testCase, window.origin); child.postMessage(testCase, window.origin);
await nextWindowMessage(); let result = await nextWindowMessage();
child.close(); child.close();
} }
SimpleTest.finish(); SimpleTest.finish();

View file

@ -43,13 +43,13 @@
let child_url = "file_autoplay_policy_unmute_pauses.html"; let child_url = "file_autoplay_policy_unmute_pauses.html";
async function runTest() { async function runTest() {
for (const testCase of testCases) { for (testCase of testCases) {
// Run each test in a new window, to ensure its user gesture // Run each test in a new window, to ensure its user gesture
// activation state isn't tainted by preceeding tests. // activation state isn't tainted by preceeding tests.
let child = window.open(child_url, "", "width=500,height=500"); let child = window.open(child_url, "", "width=500,height=500");
await once(child, "load"); await once(child, "load");
child.postMessage(testCase, window.origin); child.postMessage(testCase, window.origin);
await nextWindowMessage(); let result = await nextWindowMessage();
child.close(); child.close();
} }
SimpleTest.finish(); SimpleTest.finish();

View file

@ -51,7 +51,6 @@ function setupTestPreferences() {
} }
function createAudioContext() { function createAudioContext() {
/* global ac */
window.ac = new AudioContext(); window.ac = new AudioContext();
ac.allowedToStart = new Promise(resolve => { ac.allowedToStart = new Promise(resolve => {
@ -102,7 +101,7 @@ function createAudioParams(nodeType) {
return [ac.createStereoPanner().pan]; return [ac.createStereoPanner().pan];
default: default:
ok(false, `non-defined node type ${nodeType}.`); ok(false, `non-defined node type ${nodeType}.`);
return []; return;
} }
} }

View file

@ -46,7 +46,6 @@ function setupTestPreferences() {
} }
function createAudioContexts() { function createAudioContexts() {
/* global ac1, ac2 */
window.ac1 = new AudioContext(); window.ac1 = new AudioContext();
window.ac2 = new AudioContext(); window.ac2 = new AudioContext();

View file

@ -49,7 +49,6 @@ function setupTestPreferences() {
} }
function createAudioContext() { function createAudioContext() {
/* global ac */
window.ac = new AudioContext(); window.ac = new AudioContext();
ac.allowedToStart = new Promise(resolve => { ac.allowedToStart = new Promise(resolve => {

View file

@ -49,7 +49,6 @@ function setupTestPreferences() {
} }
async function createAudioContext() { async function createAudioContext() {
/* global ac */
window.ac = new AudioContext(); window.ac = new AudioContext();
await once(ac, "blocked"); await once(ac, "blocked");
is(ac.state, "suspended", `AudioContext is blocked.`); is(ac.state, "suspended", `AudioContext is blocked.`);

View file

@ -17,7 +17,9 @@ var manager = new MediaTestManager;
function drawVideoToCanvas(v) { function drawVideoToCanvas(v) {
console.log('drawVideoToCanvas'); console.log('drawVideoToCanvas');
let c = document.createElement('canvas'); let w = v.width,
h = v.height,
c = document.createElement('canvas');
c.width = 4; c.width = 4;
c.height = 4; c.height = 4;
c.style.width = 64; c.style.width = 64;

View file

@ -76,6 +76,6 @@
["privacy.reduceTimerPrecision", false] ["privacy.reduceTimerPrecision", false]
], ],
tests: gDecodeSuspendTests, tests: gDecodeSuspendTests,
runTest runTest: runTest
}); });
</script> </script>

View file

@ -50,6 +50,6 @@
["media.suspend-bkgnd-video.delay-ms", 1000] ["media.suspend-bkgnd-video.delay-ms", 1000]
], ],
tests: gDecodeSuspendTests, tests: gDecodeSuspendTests,
runTest runTest: runTest
}); });
</script> </script>

View file

@ -11,7 +11,7 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function captureVideoAsStream(v) { function captureVideoAsStream(v) {
v.mozCaptureStream(); let stream = v.mozCaptureStream();
} }
startTest({ startTest({

View file

@ -36,32 +36,32 @@ function testBuffered(e) {
var caught = false; var caught = false;
try { try {
b.start(-1); b.start(-1);
} catch (ex) { } catch (e) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR; caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} }
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under start bounds range"); is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under start bounds range");
caught = false; caught = false;
try { try {
b.end(-1); b.end(-1);
} catch (ex) { } catch (e) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR; caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} }
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under end bounds range"); is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on under end bounds range");
caught = false; caught = false;
try { try {
b.start(b.length); b.start(b.length);
} catch (ex) { } catch (e) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR; caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} }
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over start bounds range"); is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over start bounds range");
caught = false; caught = false;
try { try {
b.end(b.length); b.end(b.length);
} catch (ex) { } catch (e) {
caught = ex.name == "IndexSizeError" && ex.code == DOMException.INDEX_SIZE_ERR; caught = e.name == "IndexSizeError" && e.code == DOMException.INDEX_SIZE_ERR;
} }
is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over end bounds range"); is(caught, true, v._name + ": Should throw INDEX_SIZE_ERR on over end bounds range");

View file

@ -13,7 +13,6 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
function doTest() { function doTest() {
/* global v */
window.oak = v.mozCaptureStreamUntilEnded(); window.oak = v.mozCaptureStreamUntilEnded();
v.mozCaptureStreamUntilEnded(); v.mozCaptureStreamUntilEnded();
v.play(); v.play();

View file

@ -16,8 +16,6 @@
*/ */
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
/* global a, b */
function areChannelsInverted(b1, b2) { function areChannelsInverted(b1, b2) {
for (var i = 0; i < b1.length; i++) { for (var i = 0; i < b1.length; i++) {
if (Math.abs(b1[i] + b2[i]) > 9e-2) { if (Math.abs(b1[i] + b2[i]) > 9e-2) {

View file

@ -27,7 +27,7 @@ for (let ev of events) {
a.addEventListener(ev, dumpEvent); a.addEventListener(ev, dumpEvent);
} }
(async () => { (async _ => {
try { try {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("Timeouts for shortcutting test-timeout"); SimpleTest.requestFlakyTimeout("Timeouts for shortcutting test-timeout");
@ -42,7 +42,7 @@ for (let ev of events) {
a.src = test.name; a.src = test.name;
a.name = test.name; a.name = test.name;
const ac = new AudioContext(); const ac = new AudioContext();
ac.createMediaElementSource(a); const src = ac.createMediaElementSource(a);
a.play(); a.play();
do { do {
await new Promise(r => a.ontimeupdate = r); await new Promise(r => a.ontimeupdate = r);
@ -60,7 +60,7 @@ for (let ev of events) {
a.currentTime = test.duration - 1; a.currentTime = test.duration - 1;
await Promise.race([ await Promise.race([
new Promise(res => a.onended = res), new Promise(res => a.onended = res),
wait(30000).then(() => Promise.reject(new Error("Timeout"))), wait(30000).then(_ => Promise.reject(new Error("Timeout"))),
]); ]);
} catch(e) { } catch(e) {
ok(false, e); ok(false, e);

View file

@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463162
<head> <head>
<title>Test for Bug 463162</title> <title>Test for Bug 463162</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script> <script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script> <script src="/tests/SimpleTest/EventUtils.js"/>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script> <script type="text/javascript" src="manifest.js"></script>
</head> </head>

View file

@ -21,7 +21,7 @@ function onloaded(event) {
var v = event.target; var v = event.target;
v.removeEventListener("loadedmetadata", onloaded); v.removeEventListener("loadedmetadata", onloaded);
v.currentTime = v.duration; v.currentTime = v.duration;
return;
} }
function checkNotPlaying(v) { function checkNotPlaying(v) {

View file

@ -22,7 +22,6 @@ SimpleTest.waitForExplicitFinish();
var audio = document.createElement("audio"); var audio = document.createElement("audio");
// Check leaking on TextTrackList objects. // Check leaking on TextTrackList objects.
/* global ttl, ttc */
window.ttl = audio.textTracks; window.ttl = audio.textTracks;
ttl.addEventListener("click", function(){}); ttl.addEventListener("click", function(){});

View file

@ -131,7 +131,11 @@ function IsLinux() {
} }
function getPref(name) { function getPref(name) {
return SpecialPowers.getBoolPref(name, false); var pref = false;
try {
pref = SpecialPowers.getBoolPref(name);
} catch(ex) { }
return pref;
} }
function IsSupportedAndroid() { function IsSupportedAndroid() {

View file

@ -21,8 +21,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Test that when we start cloning a video that has already ended, the * Test that when we start cloning a video that has already ended, the
* clone displays the last frame from the video. * clone displays the last frame from the video.

View file

@ -23,8 +23,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Test that we can clone a video that is playing a MediaStream. * Test that we can clone a video that is playing a MediaStream.
*/ */

View file

@ -23,8 +23,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Tests that cloning a video prevents the decoder from being suspended * Tests that cloning a video prevents the decoder from being suspended
* if the original video stops being visible. * if the original video stops being visible.

View file

@ -21,8 +21,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Test that when we start cloning a paused video, the clone displays * Test that when we start cloning a paused video, the clone displays
* the first paused frame. * the first paused frame.

View file

@ -21,8 +21,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Test that when we start cloning a paused video, the clone displays * Test that when we start cloning a paused video, the clone displays
* the first paused frame. * the first paused frame.

View file

@ -23,8 +23,6 @@
<script type="application/javascript"> <script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
/** /**
* Tests that cloning survives changes to the underlying video resource. * Tests that cloning survives changes to the underlying video resource.
*/ */

View file

@ -30,17 +30,17 @@ function startTest(test, token) {
clone.token = evt.target.token; clone.token = evt.target.token;
clone.play(); clone.play();
clone.onloadstart = function(event) { clone.onloadstart = function(evt) {
info("cloned " + event.target.token + " start loading."); info("cloned " + evt.target.token + " start loading.");
event.target.onloadstart = null; evt.target.onloadstart = null;
removeNodeAndSource(v); removeNodeAndSource(v);
} }
clone.onended = function(event) { clone.onended = function(evt) {
ok(true, "cloned " + event.target.token + " ended."); ok(true, "cloned " + evt.target.token + " ended.");
event.target.onended = null; evt.target.onended = null;
removeNodeAndSource(event.target); removeNodeAndSource(evt.target);
manager.finished(event.target.token); manager.finished(evt.target.token);
} }
} }
} }

View file

@ -42,7 +42,7 @@ function testWebM1(e) {
ok(v.buffered.length >= 1, "Should have a buffered range"); ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2; var halfBuffered = v.buffered.end(0) / 2;
function start() { function startTest() {
is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start"); is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end"); is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
ok(!completed, "Should not be completed yet"); ok(!completed, "Should not be completed yet");
@ -51,8 +51,8 @@ function testWebM1(e) {
v.seeking = true; v.seeking = true;
readonly = v.seeking === false; readonly = v.seeking === false;
} }
catch(ex) { catch(e) {
readonly = "threw exception: " + ex; readonly = "threw exception: " + e;
} }
is(readonly, true, "seeking should be readonly"); is(readonly, true, "seeking should be readonly");
@ -90,7 +90,7 @@ function testWebM1(e) {
once(v, "seeking", seekStarted); once(v, "seeking", seekStarted);
once(v, "seeked", seekEnded); once(v, "seeked", seekEnded);
start(); startTest();
} }
// Fetch the media resource using XHR so we can be sure the entire // Fetch the media resource using XHR so we can be sure the entire

View file

@ -39,7 +39,7 @@ function testWebM2(e) {
ok(v.buffered.length >= 1, "Should have a buffered range"); ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2; var halfBuffered = v.buffered.end(0) / 2;
function start() { function startTest() {
if (completed) if (completed)
return; return;
@ -80,7 +80,7 @@ function testWebM2(e) {
v.addEventListener("seeking", seekStarted); v.addEventListener("seeking", seekStarted);
v.addEventListener("seeked", seekEnded); v.addEventListener("seeked", seekEnded);
start(); startTest();
} }
// Fetch the media resource using XHR so we can be sure the entire // Fetch the media resource using XHR so we can be sure the entire

View file

@ -32,13 +32,14 @@ function testWebM3(e) {
var v = e.target; var v = e.target;
v.removeEventListener('loadeddata', testWebM3); v.removeEventListener('loadeddata', testWebM3);
var startPassed = false;
var completed = false; var completed = false;
var gotTimeupdate = false; var gotTimeupdate = false;
ok(v.buffered.length >= 1, "Should have a buffered range"); ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2; var halfBuffered = v.buffered.end(0) / 2;
function start() { function startTest() {
if (completed) if (completed)
return; return;
@ -57,6 +58,7 @@ function testWebM3(e) {
return; return;
v.addEventListener("timeupdate", timeupdate); v.addEventListener("timeupdate", timeupdate);
startPassed = true;
} }
function seekEnded() { function seekEnded() {
@ -74,7 +76,7 @@ function testWebM3(e) {
v.addEventListener("seeking", seekStarted); v.addEventListener("seeking", seekStarted);
v.addEventListener("seeked", seekEnded); v.addEventListener("seeked", seekEnded);
start() startTest()
} }
// Fetch the media resource using XHR so we can be sure the entire // Fetch the media resource using XHR so we can be sure the entire

View file

@ -24,11 +24,11 @@ function e(id) {
return document.getElementById(id); return document.getElementById(id);
} }
var gLoadError = {}; var gLoadError = new Object();
gLoadError.video1 = 0; gLoadError['video1'] = 0;
gLoadError.video2 = 0; gLoadError['video2'] = 0;
gLoadError.video3 = 0; gLoadError['video3'] = 0;
var gErrorCount = 0; var gErrorCount = 0;
@ -45,9 +45,9 @@ function finishTest() {
filename(e('video3').src), filename(e('video3').src),
'video3 currentSrc should match src'); 'video3 currentSrc should match src');
is(gLoadError.video1, 2, "Expect one error per invalid source child on video1"); is(gLoadError['video1'], 2, "Expect one error per invalid source child on video1");
is(gLoadError.video2, 1, "Expect one error on video2"); is(gLoadError['video2'], 1, "Expect one error on video2");
is(gLoadError.video3, 1, "Expect one error on video3"); is(gLoadError['video3'], 1, "Expect one error on video3");
SimpleTest.finish(); SimpleTest.finish();
} }

View file

@ -10,7 +10,6 @@
<body> <body>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
var EMEmanifest = [ var EMEmanifest = [
@ -45,8 +44,8 @@ function startTest(test, token)
var eventCounts = { play: 0, playing: 0}; var eventCounts = { play: 0, playing: 0};
function ForbiddenEvents(e) { function ForbiddenEvents(e) {
var video = e.target; var v = e.target;
ok(video.readyState >= video.HAVE_FUTURE_DATA, "Must not have received event too early"); ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
is(eventCounts[e.type], 0, "event should have only be fired once"); is(eventCounts[e.type], 0, "event should have only be fired once");
eventCounts[e.type]++; eventCounts[e.type]++;
} }

View file

@ -11,7 +11,6 @@
<pre id="test"> <pre id="test">
<video id="v" controls></video> <video id="v" controls></video>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
var EMEmanifest = [ var EMEmanifest = [

View file

@ -10,10 +10,9 @@
<body> <body>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
function DoSetMediaKeys(v, test, token) function DoSetMediaKeys(v, test)
{ {
var options = [{ var options = [{
initDataTypes: ["cenc"], initDataTypes: ["cenc"],
@ -70,7 +69,7 @@ function TestSetSrc(test, token)
manager.finished(token); manager.finished(token);
}); });
DoSetMediaKeys(v, test, token) DoSetMediaKeys(v, test)
.then(function() { .then(function() {
v.src = test.name; v.src = test.name;
@ -101,3 +100,4 @@ if (!IsMacOSSnowLeopardOrEarlier()) {
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -10,7 +10,6 @@
<body> <body>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
function ArrayBuffersEqual(a, b) { function ArrayBuffersEqual(a, b) {
@ -34,12 +33,12 @@ function KeysChangeFunc(session, keys, token) {
session.keyIdsReceived[keyid] = false; session.keyIdsReceived[keyid] = false;
} }
return function(ev) { return function(ev) {
var s = ev.target; var session = ev.target;
s.gotKeysChanged = true; session.gotKeysChanged = true;
var keyList = []; var keyList = [];
var valueList = []; var valueList = [];
var map = s.keyStatuses; var map = session.keyStatuses;
// Test that accessing keys not known to the CDM has expected behaviour. // Test that accessing keys not known to the CDM has expected behaviour.
var absentKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var absentKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
@ -48,7 +47,7 @@ function KeysChangeFunc(session, keys, token) {
is(map.get(absentKey), undefined, "Unknown keys should undefined status"); is(map.get(absentKey), undefined, "Unknown keys should undefined status");
// Verify known keys have expected status. // Verify known keys have expected status.
for (let [key, val] of map.entries()) { for (var [key, val] of map.entries()) {
is(key.constructor, ArrayBuffer, "keyId should be ArrayBuffer"); is(key.constructor, ArrayBuffer, "keyId should be ArrayBuffer");
ok(map.has(key), "MediaKeyStatusMap.has() should work."); ok(map.has(key), "MediaKeyStatusMap.has() should work.");
is(map.get(key), val, "MediaKeyStatusMap.get() should work."); is(map.get(key), val, "MediaKeyStatusMap.get() should work.");
@ -56,8 +55,8 @@ function KeysChangeFunc(session, keys, token) {
valueList.push(val); valueList.push(val);
is(val, "usable", token + ": key status should be usable"); is(val, "usable", token + ": key status should be usable");
var kid = Base64ToHex(window.btoa(ArrayBufferToString(key))); var kid = Base64ToHex(window.btoa(ArrayBufferToString(key)));
ok(kid in s.keyIdsReceived, TimeStamp(token) + " session[" + s.sessionId + "].keyIdsReceived contained " + kid + " as expected."); ok(kid in session.keyIdsReceived, TimeStamp(token) + " session[" + session.sessionId + "].keyIdsReceived contained " + kid + " as expected.");
s.keyIdsReceived[kid] = true; session.keyIdsReceived[kid] = true;
} }
var index = 0; var index = 0;
@ -66,7 +65,7 @@ function KeysChangeFunc(session, keys, token) {
index++; index++;
} }
index = 0; index = 0;
for (let val of map.values()) { for (var val of map.values()) {
is(val, valueList[index], "MediaKeyStatusMap.values() should correspond to entries"); is(val, valueList[index], "MediaKeyStatusMap.values() should correspond to entries");
index++; index++;
} }
@ -143,7 +142,7 @@ function startTest(test, token)
ok(session.gotKeysChanged, ok(session.gotKeysChanged,
TimeStamp(token) + " session[" + session.sessionId TimeStamp(token) + " session[" + session.sessionId
+ "] should have received at least one keychange event"); + "] should have received at least one keychange event");
for (let kid in session.keyIdsReceived) { for (var kid in session.keyIdsReceived) {
Log(token, "session[" + session.sessionId + "] key " + kid + " = " + (session.keyIdsReceived[kid] ? "true" : "false")); Log(token, "session[" + session.sessionId + "] key " + kid + " = " + (session.keyIdsReceived[kid] ? "true" : "false"));
if (session.keyIdsReceived[kid]) { keyIdsReceived[kid] = true; } if (session.keyIdsReceived[kid]) { keyIdsReceived[kid] = true; }
} }
@ -155,7 +154,7 @@ function startTest(test, token)
is(session.numMessageEvents, session.numOnMessageEvents, is(session.numMessageEvents, session.numOnMessageEvents,
TimeStamp(token) + " should have as many message event listener calls as event handler calls."); TimeStamp(token) + " should have as many message event listener calls as event handler calls.");
} }
for (let kid in keyIdsReceived) { for (var kid in keyIdsReceived) {
ok(keyIdsReceived[kid], TimeStamp(token) + " key with id " + kid + " was usable as expected"); ok(keyIdsReceived[kid], TimeStamp(token) + " key with id " + kid + " was usable as expected");
} }

View file

@ -109,15 +109,15 @@
Log(token, "encrypted event => len=" + initData.length + " " + hexStr); Log(token, "encrypted event => len=" + initData.length + " " + hexStr);
let session = event.target.mediaKeys.createSession(); let session = event.target.mediaKeys.createSession();
initDatas.set(hexStr, session); initDatas.set(hexStr, session);
session.addEventListener("message", e => { session.addEventListener("message", event => {
e.target.update( event.target.update(
GenerateClearKeyLicense(event.message, test.keys)); GenerateClearKeyLicense(event.message, test.keys));
}); });
session.generateRequest(event.initDataType, event.initData); session.generateRequest(event.initDataType, event.initData);
} }
video.addEventListener("encrypted", handleEncrypted); video.addEventListener("encrypted", handleEncrypted, false);
video.addEventListener("ended", () => { video.addEventListener("ended", () => {
let expectedEncryptedEvents = let expectedEncryptedEvents =

View file

@ -28,6 +28,7 @@ function observe() {
function Test(test) { function Test(test) {
var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve(); var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
observedStatus = "nothing";
var name = "'" + test.keySystem + "'"; var name = "'" + test.keySystem + "'";
var res = observe().then((status) => { var res = observe().then((status) => {

View file

@ -15,6 +15,7 @@ var manager = new MediaTestManager;
function startTest(test, token) function startTest(test, token)
{ {
// Case 1. setting MediaKeys on an element captured by MediaElementSource should fail. // Case 1. setting MediaKeys on an element captured by MediaElementSource should fail.
var p1 = new EMEPromise;
var case1token = token + "_case1"; var case1token = token + "_case1";
let v1 = document.createElement("video"); let v1 = document.createElement("video");
@ -34,7 +35,7 @@ function startTest(test, token)
} }
var context = new AudioContext(); var context = new AudioContext();
context.createMediaElementSource(v1); var node = context.createMediaElementSource(v1);
v1.addEventListener("loadeddata", function(ev) { v1.addEventListener("loadeddata", function(ev) {
ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail"); ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail");
}); });

View file

@ -25,7 +25,7 @@ function startTest(test, token)
var threw = false; var threw = false;
try { try {
var context = new AudioContext(); var context = new AudioContext();
context.createMediaElementSource(v2); var node = context.createMediaElementSource(v2);
} catch (e) { } catch (e) {
threw = true; threw = true;
} }

View file

@ -23,7 +23,7 @@ function startTest(test, token)
ok(true, TimeStamp(case3token) + " should reach loadeddata"); ok(true, TimeStamp(case3token) + " should reach loadeddata");
var threw = false; var threw = false;
try { try {
v3.mozCaptureStreamUntilEnded(); var stream = v3.mozCaptureStreamUntilEnded();
} catch (e) { } catch (e) {
threw = true; threw = true;
} }

View file

@ -10,7 +10,6 @@
<body> <body>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
// Test that if we can capture a video frame while playing clear content after // Test that if we can capture a video frame while playing clear content after
@ -42,15 +41,15 @@ function startTest(test, token)
function playClearVideo() { function playClearVideo() {
var p1 = once(v, 'loadeddata', (e) => { var p1 = once(v, 'loadeddata', (e) => {
ok(true, TimeStamp(token) + " Receiving event 'loadeddata' for (CLEAR) content."); ok(true, TimeStamp(token) + " Receiving event 'loadeddata' for (CLEAR) content.");
let canvasElem = document.createElement('canvas'); canvasElem = document.createElement('canvas');
document.body.appendChild(canvasElem); document.body.appendChild(canvasElem);
let ctx2d = canvasElem.getContext('2d'); ctx2d = canvasElem.getContext('2d');
var gotTypeError = false; var gotTypeError = false;
try { try {
ctx2d.drawImage(v, 0, 0); ctx2d.drawImage(v, 0, 0);
} catch (ex) { } catch (e) {
if (ex instanceof TypeError) { if (e instanceof TypeError) {
gotTypeError = true; gotTypeError = true;
} }
} }

View file

@ -10,7 +10,6 @@
<body> <body>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from eme.js */
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) function startTest(test, token)

View file

@ -57,7 +57,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1022913
function startTest(test, token) { function startTest(test, token) {
manager.started(token); manager.started(token);
let v = document.createElement("video"); v = document.createElement("video");
v.src = test.name; v.src = test.name;
v.name = test.name; v.name = test.name;
v.preload = "metadata"; v.preload = "metadata";

View file

@ -67,7 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=778077
function startTest(test, token) { function startTest(test, token) {
manager.started(token); manager.started(token);
let v = document.createElement("video"); v = document.createElement("video");
v.src = test.name; v.src = test.name;
v.name = test.name; v.name = test.name;
v.preload = "metadata"; v.preload = "metadata";

View file

@ -85,7 +85,7 @@ function createTestArray() {
for (var fragNum=0; fragNum<gFragmentParams.length; fragNum++) { for (var fragNum=0; fragNum<gFragmentParams.length; fragNum++) {
var p = gFragmentParams[fragNum]; var p = gFragmentParams[fragNum];
var t = {}; var t = new Object;
t.name = test.name + p.fragment; t.name = test.name + p.fragment;
t.type = test.type; t.type = test.type;
t.duration = test.duration; t.duration = test.duration;
@ -98,25 +98,25 @@ function createTestArray() {
} }
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
manager.started(token); manager.started(token);
video.preload = "metadata"; v.preload = "metadata";
video.src = test.name; v.src = test.name;
video.token = token; v.token = token;
video.controls = true; v.controls = true;
document.body.appendChild(video); document.body.appendChild(v);
var name = test.name + " fragment test"; var name = test.name + " fragment test";
var localIs = function(n) { return function(a, b, msg) { var localIs = function(name) { return function(a, b, msg) {
is(a, b, n + ": " + msg); is(a, b, name + ": " + msg);
}}(name); }}(name);
var localOk = function(n) { return function(a, msg) { var localOk = function(name) { return function(a, msg) {
ok(a, n + ": " + msg); ok(a, name + ": " + msg);
}}(name); }}(name);
var localFinish = function(v, m) { return function() { var localFinish = function(v, manager) { return function() {
removeNodeAndSource(v); removeNodeAndSource(v);
m.finished(v.token); manager.finished(v.token);
}}(video, manager); }}(v, manager);
window.test_fragment_noplay(video, test.start, test.end, localIs, localOk, localFinish); window['test_fragment_noplay'](v, test.start, test.end, localIs, localOk, localFinish);
} }
manager.runTests(createTestArray(), startTest); manager.runTests(createTestArray(), startTest);

View file

@ -44,7 +44,7 @@ function createTestArray() {
for (var fragNum=0; fragNum<gFragmentParams.length; fragNum++) { for (var fragNum=0; fragNum<gFragmentParams.length; fragNum++) {
var p = gFragmentParams[fragNum]; var p = gFragmentParams[fragNum];
var t = {}; var t = new Object;
t.name = test.name + p.fragment; t.name = test.name + p.fragment;
t.type = test.type; t.type = test.type;
t.duration = test.duration; t.duration = test.duration;
@ -62,25 +62,25 @@ function startTest(test, token) {
todo(false, test.todo); todo(false, test.todo);
return; return;
} }
var video = document.createElement('video'); var v = document.createElement('video');
manager.started(token); manager.started(token);
video.preload = "metadata"; v.preload = "metadata";
video.src = test.name; v.src = test.name;
video.token = token; v.token = token;
video.controls = true; v.controls = true;
document.body.appendChild(video); document.body.appendChild(v);
var name = test.name + " fragment test"; var name = test.name + " fragment test";
var localIs = function(n) { return function(a, b, msg) { var localIs = function(name) { return function(a, b, msg) {
is(a, b, n + ": " + msg); is(a, b, name + ": " + msg);
}}(name); }}(name);
var localOk = function(n) { return function(a, msg) { var localOk = function(name) { return function(a, msg) {
ok(a, n + ": " + msg); ok(a, name + ": " + msg);
}}(name); }}(name);
var localFinish = function(v, m) { return function() { var localFinish = function(v, manager) { return function() {
removeNodeAndSource(v); removeNodeAndSource(v);
m.finished(v.token); manager.finished(v.token);
}}(video, manager); }}(v, manager);
window.test_fragment_play(video, test.start, test.end, localIs, localOk, localFinish); window['test_fragment_play'](v, test.start, test.end, localIs, localOk, localFinish);
} }
manager.runTests(createTestArray(), startTest); manager.runTests(createTestArray(), startTest);

View file

@ -42,7 +42,7 @@ function createTestArray() {
continue; continue;
} }
var t = {}; var t = new Object;
t.name = test.src; t.name = test.src;
t.type = test.type; t.type = test.type;
@ -55,7 +55,6 @@ function createTestArray() {
function log(msg) { function log(msg) {
info(msg); info(msg);
var l = document.getElementById('log'); var l = document.getElementById('log');
// eslint-disable-next-line no-unsanitized/property
l.innerHTML += msg + "<br>"; l.innerHTML += msg + "<br>";
} }

View file

@ -89,14 +89,16 @@ function prependSource(src, type) {
var gTests = [ var gTests = [
{ {
// Test 0: adding video to doc, then setting src should load implicitly. // Test 0: adding video to doc, then setting src should load implicitly.
create(src, type) { create:
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
gMedia.src = src; gMedia.src = src;
}, },
expectedEvents: ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata'] expectedEvents: ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata']
}, { }, {
// Test 1: adding video to doc, then adding source. // Test 1: adding video to doc, then adding source.
create(src, type) { create:
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
addSource(src, type); addSource(src, type);
}, },
@ -104,7 +106,8 @@ var gTests = [
},{ },{
// Test 2: video with multiple source, the first of which are bad, we should load the last, // Test 2: video with multiple source, the first of which are bad, we should load the last,
// and receive error events for failed loads on the source children. // and receive error events for failed loads on the source children.
create(src, type) { create:
function(src, type) {
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
addSource("404a", type); addSource("404a", type);
addSource("404b", type); addSource("404b", type);
@ -113,7 +116,8 @@ var gTests = [
expectedEvents: ['loadstart', 'source_error', 'source_error', 'durationchange', 'loadedmetadata', 'loadeddata'] expectedEvents: ['loadstart', 'source_error', 'source_error', 'durationchange', 'loadedmetadata', 'loadeddata']
}, { }, {
// Test 3: video with bad src, good <source>, ensure that <source> aren't used. // Test 3: video with bad src, good <source>, ensure that <source> aren't used.
create(src, type) { create:
function(src, type) {
gMedia.src = "404a"; gMedia.src = "404a";
addSource(src, type); addSource(src, type);
document.body.appendChild(gMedia); document.body.appendChild(gMedia);
@ -122,7 +126,8 @@ var gTests = [
}, { }, {
// Test 4: video with only bad source, loading, then adding a good source // Test 4: video with only bad source, loading, then adding a good source
// - should resume load. // - should resume load.
create(src, type) { create:
function(src, type) {
addSource("404a", type); addSource("404a", type);
var s2 = addSource("404b", type); var s2 = addSource("404b", type);
s2.addEventListener("error", s2.addEventListener("error",
@ -138,7 +143,8 @@ var gTests = [
// a good <source> to the video, it shouldn't be selected, because the // a good <source> to the video, it shouldn't be selected, because the
// "pointer" should be after the last child - the bad source. // "pointer" should be after the last child - the bad source.
prepended: false, prepended: false,
create(src, type) { create:
function(src, type) {
var prepended = false; var prepended = false;
addSource("404a", type); addSource("404a", type);
var s2 = addSource("404b", type); var s2 = addSource("404b", type);
@ -156,7 +162,8 @@ var gTests = [
}, { }, {
// Test 6: (Bug 1165203) preload="none" then followed by an explicit // Test 6: (Bug 1165203) preload="none" then followed by an explicit
// call to load() should load metadata // call to load() should load metadata
create(src, type) { create:
function(src, type) {
gMedia.preload = "none"; gMedia.preload = "none";
gMedia.src = src; gMedia.src = src;
document.body.appendChild(gMedia); document.body.appendChild(gMedia);

View file

@ -38,11 +38,11 @@ function tryClone(e) {
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort", "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause"]; "waiting", "pause"];
function logEvent(evt) { function logEvent(evt) {
var event = evt.target; var e = evt.target;
info(`${event.token} got ${evt.type}`); info(`${e.token} got ${evt.type}`);
} }
events.forEach(function(event) { events.forEach(function(e) {
clone.addEventListener(event, logEvent); clone.addEventListener(e, logEvent);
}); });

View file

@ -107,8 +107,8 @@ for (var i = 0; i < gSmallTests.length; ++i) {
// The following nested function hack is to ensure that 'test' is correctly // The following nested function hack is to ensure that 'test' is correctly
// captured in the closure and we don't end up getting the value 'test' // captured in the closure and we don't end up getting the value 'test'
// had in the last iteration of the loop. I blame Brendan. // had in the last iteration of the loop. I blame Brendan.
var check = function(t) { return function (e) { var check = function(test) { return function (e) {
checkMetadata(t.name, e, test); checkMetadata(test.name, e, test);
}}(test); }}(test);
var otherType = type.match(/^video\//) ? "audio/x-wav" : "video/ogg"; var otherType = type.match(/^video\//) ? "audio/x-wav" : "video/ogg";
@ -130,8 +130,8 @@ for (var i = 0; i < gSmallTests.length; ++i) {
maketest(late_add_sources_first, src, type, check)); maketest(late_add_sources_first, src, type, check));
} }
function startTest(t, token) { function startTest(test, token) {
t(token); test(token);
} }
manager.runTests(subtests, startTest); manager.runTests(subtests, startTest);

View file

@ -24,6 +24,7 @@ function startTest(test, token) {
function runTest(test, token, bitrate) { function runTest(test, token, bitrate) {
var element = document.createElement('video'); var element = document.createElement('video');
var expectedMimeType = test.type.substring(0, test.type.indexOf(';'));
element.token = token; element.token = token;

View file

@ -13,7 +13,6 @@
<video id="recorded-video"></video> <video id="recorded-video"></video>
</div> </div>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from ../../canvas/test/captureStream_common.js */
function startTest() { function startTest() {
// Setup canvas and take a stream from it // Setup canvas and take a stream from it
@ -35,7 +34,7 @@ function startTest() {
// Recorded data that will be playback. // Recorded data that will be playback.
let blob; let blob;
let mediaRecorder = new MediaRecorder(canvasStream); mediaRecorder = new MediaRecorder(canvasStream);
is(mediaRecorder.stream, canvasStream, is(mediaRecorder.stream, canvasStream,
"Media recorder stream = canvas stream at the start of recording"); "Media recorder stream = canvas stream at the start of recording");

View file

@ -13,7 +13,6 @@
<video id="recorded-video" loop></video> <video id="recorded-video" loop></video>
</div> </div>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from ../../canvas/test/captureStream_common.js */
function startTest() { function startTest() {
let canvas = document.getElementById("video-src-canvas"); let canvas = document.getElementById("video-src-canvas");

View file

@ -27,13 +27,15 @@ function startTest() {
var onstopTriggered = false; var onstopTriggered = false;
dest.channelCount = 4; dest.channelCount = 4;
var expectedMimeType = 'audio/ogg; codecs=opus'; var expectedMimeType = 'audio/ogg; codecs=opus';
var totalBlobSize = 0;
source.channelCountMode = 'explicit'; source.channelCountMode = 'explicit';
source.connect(dest); source.connect(dest);
var elem = document.createElement('audio'); var elem = document.createElement('audio');
elem.srcObject = dest.stream; elem.srcObject = dest.stream;
mMediaStream = dest.stream;
source.start(0); source.start(0);
elem.play(); elem.play();
let mMediaRecorder = new MediaRecorder(dest.stream); mMediaRecorder = new MediaRecorder(dest.stream);
mMediaRecorder.onwarning = function() { mMediaRecorder.onwarning = function() {
ok(false, 'onwarning unexpectedly fired'); ok(false, 'onwarning unexpectedly fired');
}; };
@ -50,6 +52,7 @@ function startTest() {
}; };
mMediaRecorder.ondataavailable = function (e) { mMediaRecorder.ondataavailable = function (e) {
ok(e.data.size > 0, 'check blob has data'); ok(e.data.size > 0, 'check blob has data');
totalBlobSize += e.data.size;
is(e.data.type, expectedMimeType, 'blob should have expected mimetype'); is(e.data.type, expectedMimeType, 'blob should have expected mimetype');
if (!stopTriggered) { if (!stopTriggered) {
is(mMediaRecorder.mimeType, expectedMimeType, 'recorder should have expected mimetype'); is(mMediaRecorder.mimeType, expectedMimeType, 'recorder should have expected mimetype');

View file

@ -12,8 +12,6 @@
<div id="content"> <div id="content">
</div> </div>
<script> <script>
/* import-globals-from ../../canvas/test/captureStream_common.js */
/* import-globals-from ../tests/mochitest/head.js */
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runTestWhenReady(async () => { runTestWhenReady(async () => {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
@ -35,7 +33,7 @@ runTestWhenReady(async () => {
const blobs = []; const blobs = [];
let mediaRecorder = new MediaRecorder(stream); mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream, is(mediaRecorder.stream, stream,
"Media recorder stream = constructed stream at the start of recording"); "Media recorder stream = constructed stream at the start of recording");

View file

@ -12,6 +12,7 @@
function startTest() { function startTest() {
var context = new AudioContext(); var context = new AudioContext();
var hasonstop = false;
var buffer = context.createBuffer(1, 80920, context.sampleRate); var buffer = context.createBuffer(1, 80920, context.sampleRate);
for (var i = 0; i < 80920; ++i) { for (var i = 0; i < 80920; ++i) {
buffer.getChannelData(0)[i] = Math.sin(1000 * 2 * Math.PI * i / context.sampleRate); buffer.getChannelData(0)[i] = Math.sin(1000 * 2 * Math.PI * i / context.sampleRate);
@ -25,9 +26,10 @@ function startTest() {
source.connect(dest); source.connect(dest);
var elem = document.createElement('audio'); var elem = document.createElement('audio');
elem.srcObject = dest.stream; elem.srcObject = dest.stream;
mMediaStream = dest.stream;
source.start(0); source.start(0);
elem.play(); elem.play();
let mMediaRecorder = new MediaRecorder(dest.stream); mMediaRecorder = new MediaRecorder(dest.stream);
mMediaRecorder.onwarning = function() { mMediaRecorder.onwarning = function() {
ok(false, 'onwarning unexpectedly fired'); ok(false, 'onwarning unexpectedly fired');
}; };

View file

@ -11,7 +11,6 @@
<div id="content"> <div id="content">
</div> </div>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from ../../canvas/test/captureStream_common.js */
function startTest() { function startTest() {
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");
@ -25,7 +24,7 @@ function startTest() {
var blob; var blob;
let mediaRecorder = new MediaRecorder(stream); mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream, is(mediaRecorder.stream, stream,
"Media recorder stream = canvas stream at the start of recording"); "Media recorder stream = canvas stream at the start of recording");

View file

@ -11,7 +11,6 @@
<div id="content"> <div id="content">
</div> </div>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from ../../canvas/test/captureStream_common.js */
function startTest() { function startTest() {
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");

View file

@ -20,7 +20,7 @@ async function startTest() {
let onDataAvailableFirst = false; let onDataAvailableFirst = false;
const expectedMimeType = 'video/webm; codecs="vp8, opus"'; const expectedMimeType = 'video/webm; codecs="vp8, opus"';
let mediaRecorder = new MediaRecorder(stream); mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream, is(mediaRecorder.stream, stream,
'Media recorder stream = element stream at the start of recording'); 'Media recorder stream = element stream at the start of recording');
mediaRecorder.onwarning = function() { mediaRecorder.onwarning = function() {
@ -49,7 +49,7 @@ async function startTest() {
// We'll stop recording upon the 1st blob being received // We'll stop recording upon the 1st blob being received
if (dataAvailableCount === 1) { if (dataAvailableCount === 1) {
mediaRecorder.onstop = function (event) { mediaRecorder.onstop = function (evt) {
info('onstop fired'); info('onstop fired');
if (!onDataAvailableFirst) { if (!onDataAvailableFirst) {

View file

@ -13,7 +13,7 @@ function unexpected({type}) {
ok(false, `${type} unexpectedly fired`); ok(false, `${type} unexpectedly fired`);
} }
(async () => { (async _ => {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
let blobUrl = null; let blobUrl = null;
let stream = null; let stream = null;
@ -32,7 +32,7 @@ function unexpected({type}) {
{audio: true, video: true}); {audio: true, video: true});
const blobs = []; const blobs = [];
let mediaRecorder = new MediaRecorder(stream); mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream, is(mediaRecorder.stream, stream,
"Media recorder stream = element stream at the start of recording"); "Media recorder stream = element stream at the start of recording");
mediaRecorder.start(); mediaRecorder.start();
@ -78,7 +78,7 @@ function unexpected({type}) {
await Promise.race([ await Promise.race([
new Promise(res => video.onended = res), new Promise(res => video.onended = res),
new Promise((res, rej) => video.onerror = () => rej(video.error.message)), new Promise((_, rej) => video.onerror = _ => rej(video.error.message)),
]); ]);
} catch (e) { } catch (e) {
ok(false, e); ok(false, e);

View file

@ -68,7 +68,7 @@ function startTest(test, token) {
// We'll stop recording upon the 1st blob being received // We'll stop recording upon the 1st blob being received
if (dataAvailableCount === 1) { if (dataAvailableCount === 1) {
mediaRecorder.onstop = function (event) { mediaRecorder.onstop = function (evt) {
info('onstop fired'); info('onstop fired');
if (!onDataAvailableFirst) { if (!onDataAvailableFirst) {

View file

@ -11,7 +11,6 @@
<div id="content"> <div id="content">
</div> </div>
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/* import-globals-from ../../canvas/test/captureStream_common.js */
function startTest() { function startTest() {
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");

View file

@ -11,15 +11,13 @@
a Bug 894348</a> a Bug 894348</a>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
for (let i = 0; i< 5; i++) { for (i = 0; i< 5; i++) {
/* eslint-disable no-undef */
try { o0 = document.createElement('audio') } catch(e) { } try { o0 = document.createElement('audio') } catch(e) { }
try { o0.src = "sound.ogg" } catch(e) { } try { o0.src = "sound.ogg" } catch(e) { }
try { (document.body || document.documentElement).appendChild(o0) } catch(e) { } try { (document.body || document.documentElement).appendChild(o0) } catch(e) { }
try { o1 = o0.mozCaptureStreamUntilEnded(); } catch(e) { } try { o1 = o0.mozCaptureStreamUntilEnded(); } catch(e) { }
try { o2 = new MediaRecorder(o1) } catch(e) { } try { o2 = new MediaRecorder(o1) } catch(e) { }
try { o2.start(0) } catch(e) { } try { o2.start(0) } catch(e) { }
/* eslint-enable no-undef */
SpecialPowers.gc(); SpecialPowers.gc();
} }
ok(true, "pass the crash test"); ok(true, "pass the crash test");

View file

@ -223,12 +223,12 @@ var operationTests = [
* operation tests * operation tests
*/ */
function runStateTransitionTests(testStream) { function runStateTransitionTests(testStream) {
for (const operationTest of operationTests) { for (operationTest of operationTests) {
var mediaRecorder = new MediaRecorder(testStream); var mediaRecorder = new MediaRecorder(testStream);
var operationsString = operationTest.operations.toString(); var operationsString = operationTest.operations.toString();
try { try {
for (const operation of operationTest.operations) { for (operation of operationTest.operations) {
if (operationTest.timeSlice && operation === 'start') { if (operationTest.timeSlice && operation === 'start') {
operationsString += ' with timeslice ' + operationTest.timeSlice; operationsString += ' with timeslice ' + operationTest.timeSlice;
mediaRecorder[operation](operationTest.timeSlice); mediaRecorder[operation](operationTest.timeSlice);
@ -256,6 +256,7 @@ function runStateTransitionTests(testStream) {
*/ */
function startTest(test, token) { function startTest(test, token) {
var element = document.createElement('audio'); var element = document.createElement('audio');
var expectedMimeType = test.type.substring(0, test.type.indexOf(';'));
element.token = token; element.token = token;
manager.started(token); manager.started(token);

View file

@ -14,8 +14,10 @@ async function startTest() {
let steps = 0; let steps = 0;
let audioOnchange = 0; let audioOnchange = 0;
let audioOnaddtrack = 0; let audioOnaddtrack = 0;
let audioOnremovetrack = 0;
let videoOnchange = 0; let videoOnchange = 0;
let videoOnaddtrack = 0; let videoOnaddtrack = 0;
let videoOnremovetrack = 0;
let isPlaying = false; let isPlaying = false;
let element = document.createElement("video"); let element = document.createElement("video");
let stream; let stream;
@ -32,6 +34,10 @@ async function startTest() {
audioOnaddtrack++; audioOnaddtrack++;
}; };
element.audioTracks.onremovetrack = function(e) {
audioOnremovetrack++;
};
element.audioTracks.onchange = function(e) { element.audioTracks.onchange = function(e) {
audioOnchange++; audioOnchange++;
}; };
@ -40,6 +46,10 @@ async function startTest() {
videoOnaddtrack++; videoOnaddtrack++;
}; };
element.videoTracks.onremovetrack = function(e) {
videoOnremovetrack++;
};
element.videoTracks.onchange = function(e) { element.videoTracks.onchange = function(e) {
videoOnchange++; videoOnchange++;
}; };

View file

@ -26,8 +26,10 @@ function startTest(test, token) {
var elemType = getMajorMimeType(test.type); var elemType = getMajorMimeType(test.type);
var element = document.createElement(elemType); var element = document.createElement(elemType);
var audioOnchange = 0;
var audioOnaddtrack = 0; var audioOnaddtrack = 0;
var audioOnremovetrack = 0; var audioOnremovetrack = 0;
var videoOnchange = 0;
var videoOnaddtrack = 0; var videoOnaddtrack = 0;
var videoOnremovetrack = 0; var videoOnremovetrack = 0;
var isPlaying = false; var isPlaying = false;

View file

@ -26,7 +26,7 @@ function startTest(test, token) {
// Tags should not be available immediately. // Tags should not be available immediately.
var exception_fired = false; var exception_fired = false;
try { try {
a.mozGetMetadata(); var m = a.mozGetMetadata();
} catch (e) { } catch (e) {
is(e.name, 'InvalidStateError', is(e.name, 'InvalidStateError',
"early mozGetMetadata() should throw InvalidStateError"); "early mozGetMetadata() should throw InvalidStateError");
@ -38,7 +38,7 @@ function startTest(test, token) {
// Wait until metadata has loaded. // Wait until metadata has loaded.
a.addEventListener('loadedmetadata', function() { a.addEventListener('loadedmetadata', function() {
// read decoded tags // read decoded tags
let tags = a.mozGetMetadata(); tags = a.mozGetMetadata();
ok(tags, "mozGetMetadata() should return a truthy value"); ok(tags, "mozGetMetadata() should return a truthy value");
// Dump them out. // Dump them out.
var d = document.getElementById('output'); var d = document.getElementById('output');
@ -47,7 +47,7 @@ function startTest(test, token) {
html += ' on '+test.name+'</p></caption>\n'; html += ' on '+test.name+'</p></caption>\n';
html += '<tr><th>tag</th>'; html += '<tr><th>tag</th>';
html += '<th>decoded value</th><th>expected value</th></tr>\n'; html += '<th>decoded value</th><th>expected value</th></tr>\n';
for (let tag in tags) { for (tag in tags) {
html += '<tr><td>'+tag+'</td>'; html += '<tr><td>'+tag+'</td>';
html += '<td>'+tags[tag]+'</td>'; html += '<td>'+tags[tag]+'</td>';
html += '<td>'+test.tags[tag]+'</td>'; html += '<td>'+test.tags[tag]+'</td>';
@ -58,15 +58,14 @@ function startTest(test, token) {
} }
html += '</table>\n'; html += '</table>\n';
var div = document.createElement('div'); var div = document.createElement('div');
// eslint-disable-next-line no-unsanitized/property
div.innerHTML = html; div.innerHTML = html;
d.appendChild(div); d.appendChild(div);
// Verify decoded tag values. // Verify decoded tag values.
for (let tag in tags) { for (tag in tags) {
is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match"); is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match");
} }
// Verify expected tag values // Verify expected tag values
for (let tag in test.tags) { for (tag in test.tags) {
is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match"); is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match");
} }
removeNodeAndSource(a); removeNodeAndSource(a);

View file

@ -34,13 +34,14 @@
element.addEventListener("loadedmetadata", ()=>{ element.addEventListener("loadedmetadata", ()=>{
resolve(true); resolve(true);
removeNodeAndSource(element); removeNodeAndSource(element);
}); }, false);
element.addEventListener("error", ()=>{ element.addEventListener("error", ()=>{
resolve(false); resolve(false);
removeNodeAndSource(element); removeNodeAndSource(element);
}); }, false);
var noise = Math.floor(Math.random() * 100000000);
// Note: request redirect before the end of metadata, otherwise we won't // Note: request redirect before the end of metadata, otherwise we won't
// error before metadata has loaded if mixed origins are allowed. // error before metadata has loaded if mixed origins are allowed.
element.src = "midflight-redirect.sjs?resource=" + test.name element.src = "midflight-redirect.sjs?resource=" + test.name
@ -56,11 +57,14 @@
let v = document.createElement("video"); let v = document.createElement("video");
const testCases = gSmallTests.filter(t => v.canPlayType(t.type)); const testCases = gSmallTests.filter(t => v.canPlayType(t.type));
async function testMediaLoad(expectedToLoad, message, useCors) { function testMediaLoad(expectedToLoad, message, useCors) {
return new Promise(async function(resolve, reject) {
for (let test of testCases) { for (let test of testCases) {
let loaded = await testIfLoadsToMetadata(test, useCors); let loaded = await testIfLoadsToMetadata(test, useCors);
is(loaded, expectedToLoad, test.name + " " + message); is(loaded, expectedToLoad, test.name + " " + message);
} }
resolve();
});
} }
async function runTest() { async function runTest() {

View file

@ -13,21 +13,21 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
video.token = token; v.token = token;
manager.started(token); manager.started(token);
video.src = test.name; v.src = test.name;
video.name = test.name; v.name = test.name;
video.playingCount = 0; v.playingCount = 0;
video._playedOnce = false; v._playedOnce = false;
var check = function(t, v) { return function() { var check = function(test, v) { return function() {
checkMetadata(t.name, v, test); checkMetadata(test.name, v, test);
}}(test, video); }}(test, v);
var noLoad = function(t, v) { return function() { var noLoad = function(test, v) { return function() {
ok(false, t.name + " should not fire 'load' event"); ok(false, test.name + " should not fire 'load' event");
}}(test, video); }}(test, v);
function finish(v) { function finish(v) {
removeNodeAndSource(v); removeNodeAndSource(v);
@ -40,14 +40,14 @@ function startTest(test, token) {
} }
} }
var checkEnded = function(t, v) { return function() { var checkEnded = function(test, v) { return function() {
if (t.duration) { if (test.duration) {
ok(Math.abs(v.currentTime - t.duration) < 0.1, ok(Math.abs(v.currentTime - test.duration) < 0.1,
t.name + " current time at end: " + v.currentTime); test.name + " current time at end: " + v.currentTime);
} }
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState"); is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended"); ok(v.ended, test.name + " checking playback has ended");
ok(v.playingCount > 0, "Expect at least one playing event"); ok(v.playingCount > 0, "Expect at least one playing event");
v.playingCount = 0; v.playingCount = 0;
@ -58,33 +58,33 @@ function startTest(test, token) {
v._playedOnce = true; v._playedOnce = true;
v.play(); v.play();
} }
}}(test, video); }}(test, v);
var checkSuspended = function(t, v) { return function() { var checkSuspended = function(test, v) { return function() {
if (v.seenSuspend) { if (v.seenSuspend) {
return; return;
} }
v.seenSuspend = true; v.seenSuspend = true;
ok(true, t.name + " got suspend"); ok(true, test.name + " got suspend");
mayFinish(v); mayFinish(v);
}}(test, video); }}(test, v);
var checkPlaying = function(t, v) { return function() { var checkPlaying = function(test, v) { return function() {
is(t.name, v.name, "Should be testing file we think we're testing..."); is(test.name, v.name, "Should be testing file we think we're testing...");
v.playingCount++; v.playingCount++;
}}(test, video); }}(test, v);
video.addEventListener("load", noLoad); v.addEventListener("load", noLoad);
video.addEventListener("loadedmetadata", check); v.addEventListener("loadedmetadata", check);
video.addEventListener("playing", checkPlaying); v.addEventListener("playing", checkPlaying);
// We should get "ended" and "suspend" events for every resource // We should get "ended" and "suspend" events for every resource
video.addEventListener("ended", checkEnded); v.addEventListener("ended", checkEnded);
video.addEventListener("suspend", checkSuspended); v.addEventListener("suspend", checkSuspended);
document.body.appendChild(video); document.body.appendChild(v);
video.play(); v.play();
} }
manager.runTests(gReplayTests, startTest); manager.runTests(gReplayTests, startTest);

View file

@ -13,91 +13,91 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
video.preload = "metadata"; v.preload = "metadata";
video.token = token; v.token = token;
video.prevTime = 0; v.prevTime = 0;
video.seenEnded = false; v.seenEnded = false;
video.seenSuspend = false; v.seenSuspend = false;
var handler = { var handler = {
"ontimeout": function() { "ontimeout": function() {
Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend); Log(token, "timed out: ended=" + v.seenEnded + ", suspend=" + v.seenSuspend);
} }
}; };
manager.started(token, handler); manager.started(token, handler);
video.src = test.name; v.src = test.name;
video.name = test.name; v.name = test.name;
var check = function(t, v) { return function() { var check = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1"); is(test.name, v.name, test.name + ": Name should match #1");
checkMetadata(t.name, v, t); checkMetadata(test.name, v, test);
}}(test, video); }}(test, v);
var noLoad = function(t, v) { return function() { var noLoad = function(test, v) { return function() {
ok(false, t.name + " should not fire 'load' event"); ok(false, test.name + " should not fire 'load' event");
}}(test, video); }}(test, v);
var noError = function(t, v) { return function() { var noError = function(test, v) { return function() {
ok(false, t.name + " should not fire 'error' event " + v.error.message); ok(false, test.name + " should not fire 'error' event " + v.error.message);
}}(test, video); }}(test, v);
var finish = function() { var finish = function() {
video.finished = true; v.finished = true;
video.removeEventListener("timeupdate", timeUpdate); v.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(video); removeNodeAndSource(v);
manager.finished(video.token); manager.finished(v.token);
} }
// We should get "ended" and "suspend" events to finish the test. // We should get "ended" and "suspend" events to finish the test.
var mayFinish = function() { var mayFinish = function() {
if (video.seenEnded && video.seenSuspend) { if (v.seenEnded && v.seenSuspend) {
finish(); finish();
} }
} }
var checkEnded = function(t, v) { return function() { var checkEnded = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2"); is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(t.name, v, test); checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState"); is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended"); ok(v.ended, test.name + " checking playback has ended");
ok(!v.finished, t.name + " shouldn't be finished"); ok(!v.finished, test.name + " shouldn't be finished");
ok(!v.seenEnded, t.name + " shouldn't be ended"); ok(!v.seenEnded, test.name + " shouldn't be ended");
v.seenEnded = true; v.seenEnded = true;
mayFinish(); mayFinish();
}}(test, video); }}(test, v);
var checkSuspended = function(t, v) { return function() { var checkSuspended = function(test, v) { return function() {
if (v.seenSuspend) { if (v.seenSuspend) {
return; return;
} }
is(t.name, v.name, t.name + ": Name should match #3"); is(test.name, v.name, test.name + ": Name should match #3");
v.seenSuspend = true; v.seenSuspend = true;
mayFinish(); mayFinish();
}}(test, video); }}(test, v);
var timeUpdate = function(t, v) { return function() { var timeUpdate = function(test, v) { return function() {
if (v.prevTime > v.currentTime) { if (v.prevTime > v.currentTime) {
ok(false, t.name + " time should run forwards: p=" + ok(false, test.name + " time should run forwards: p=" +
v.prevTime + " c=" + v.currentTime); v.prevTime + " c=" + v.currentTime);
} }
v.prevTime = v.currentTime; v.prevTime = v.currentTime;
}}(test, video); }}(test, v);
video.addEventListener("load", noLoad); v.addEventListener("load", noLoad);
video.addEventListener("error", noError); v.addEventListener("error", noError);
video.addEventListener("loadedmetadata", check); v.addEventListener("loadedmetadata", check);
video.addEventListener("timeupdate", timeUpdate); v.addEventListener("timeupdate", timeUpdate);
// We should get "ended" and "suspend" events for every resource // We should get "ended" and "suspend" events for every resource
video.addEventListener("ended", checkEnded); v.addEventListener("ended", checkEnded);
video.addEventListener("suspend", checkSuspended); v.addEventListener("suspend", checkSuspended);
document.body.appendChild(video); document.body.appendChild(v);
video.play(); v.play();
} }
manager.runTests(gPlayTests, startTest); manager.runTests(gPlayTests, startTest);

View file

@ -13,10 +13,10 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
manager.started(token); manager.started(token);
video._errorCount = 0; v._errorCount = 0;
video._ignore = false; v._ignore = false;
function endedTest(v) { function endedTest(v) {
if (v._ignore) if (v._ignore)
return; return;
@ -24,20 +24,20 @@ function startTest(test, token) {
v.remove(); v.remove();
manager.finished(token); manager.finished(token);
} }
var checkError = function(t, v) { return function(evt) { var checkError = function(test, v) { return function(evt) {
v._errorCount++; v._errorCount++;
is(v._errorCount, 1, t.name + " only one error fired"); is(v._errorCount, 1, test.name + " only one error fired");
endedTest(v); endedTest(v);
}}(test, video); }}(test, v);
var checkEnded = function(t, v) { return function() { var checkEnded = function(test, v) { return function() {
ok(false, t.name + " successfully played"); ok(false, test.name + " successfully played");
endedTest(v); endedTest(v);
}}(test, video); }}(test, v);
video.addEventListener("error", checkError); v.addEventListener("error", checkError);
video.addEventListener("ended", checkEnded); v.addEventListener("ended", checkEnded);
video.src = test.name; v.src = test.name;
document.body.appendChild(video); document.body.appendChild(v);
video.play(); v.play();
} }
manager.runTests(gErrorTests, startTest); manager.runTests(gErrorTests, startTest);

View file

@ -13,74 +13,74 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
video.preload = "metadata"; v.preload = "metadata";
video.token = token; v.token = token;
video.prevTime = 0; v.prevTime = 0;
video.seenEnded = false; v.seenEnded = false;
var handler = { var handler = {
"ontimeout": function() { "ontimeout": function() {
Log(token, "timed out: ended=" + video.seenEnded); Log(token, "timed out: ended=" + v.seenEnded);
} }
}; };
manager.started(token, handler); manager.started(token, handler);
video.src = test.name; v.src = test.name;
video.name = test.name; v.name = test.name;
var check = function(t, v) { return function() { var check = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1"); is(test.name, v.name, test.name + ": Name should match #1");
checkMetadata(t.name, v, t); checkMetadata(test.name, v, test);
}}(test, video); }}(test, v);
var noLoad = function(t, v) { return function() { var noLoad = function(test, v) { return function() {
ok(false, t.name + " should not fire 'load' event"); ok(false, test.name + " should not fire 'load' event");
}}(test, video); }}(test, v);
var finish = function() { var finish = function() {
video.finished = true; v.finished = true;
video.removeEventListener("timeupdate", timeUpdate); v.removeEventListener("timeupdate", timeUpdate);
removeNodeAndSource(video); removeNodeAndSource(v);
manager.finished(video.token); manager.finished(v.token);
} }
// We should get "ended" events to finish the test. // We should get "ended" events to finish the test.
var mayFinish = function() { var mayFinish = function() {
if (video.seenEnded) { if (v.seenEnded) {
finish(); finish();
} }
} }
var checkEnded = function(t, v) { return function() { var checkEnded = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2"); is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(t.name, v, test); checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState"); is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended"); ok(v.ended, test.name + " checking playback has ended");
ok(!v.finished, t.name + " shouldn't be finished"); ok(!v.finished, test.name + " shouldn't be finished");
ok(!v.seenEnded, t.name + " shouldn't be ended"); ok(!v.seenEnded, test.name + " shouldn't be ended");
v.seenEnded = true; v.seenEnded = true;
mayFinish(); mayFinish();
}}(test, video); }}(test, v);
var timeUpdate = function(t, v) { return function() { var timeUpdate = function(test, v) { return function() {
if (v.prevTime > v.currentTime) { if (v.prevTime > v.currentTime) {
ok(false, t.name + " time should run forwards: p=" + ok(false, test.name + " time should run forwards: p=" +
v.prevTime + " c=" + v.currentTime); v.prevTime + " c=" + v.currentTime);
} }
v.prevTime = v.currentTime; v.prevTime = v.currentTime;
}}(test, video); }}(test, v);
video.addEventListener("load", noLoad); v.addEventListener("load", noLoad);
video.addEventListener("loadedmetadata", check); v.addEventListener("loadedmetadata", check);
video.addEventListener("timeupdate", timeUpdate); v.addEventListener("timeupdate", timeUpdate);
// We should get "ended" events for the hls resource // We should get "ended" events for the hls resource
video.addEventListener("ended", checkEnded); v.addEventListener("ended", checkEnded);
document.body.appendChild(video); document.body.appendChild(v);
video.play(); v.play();
} }
manager.runTests(gHLSTests, startTest); manager.runTests(gHLSTests, startTest);

View file

@ -20,22 +20,22 @@
var manager = new MediaTestManager; var manager = new MediaTestManager;
function startTest(test, token) { function startTest(test, token) {
var video = document.createElement('video'); var v = document.createElement('video');
video.preload = "metadata"; v.preload = "metadata";
video.token = token; v.token = token;
var handler = { var handler = {
"ontimeout": function() { "ontimeout": function() {
Log(token, "timed out: ended=" + video.seenEnded + ", suspend=" + video.seenSuspend); Log(token, "timed out: ended=" + v.seenEnded + ", suspend=" + v.seenSuspend);
} }
}; };
manager.started(token, handler); manager.started(token, handler);
video.src = test.name; v.src = test.name;
video.name = test.name; v.name = test.name;
var check = function(t, v) { return function() { var check = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #1"); is(test.name, v.name, test.name + ": Name should match #1");
Log(v.token, "removeChild: " + v.name); Log(v.token, "removeChild: " + v.name);
document.body.removeChild(v); document.body.removeChild(v);
var appendAndPlayElement = function() { var appendAndPlayElement = function() {
@ -45,28 +45,28 @@ function startTest(test, token) {
v.play(); v.play();
} }
setTimeout(appendAndPlayElement, 2000); setTimeout(appendAndPlayElement, 2000);
}}(test, video); }}(test, v);
var finish = function() { var finish = function() {
video.finished = true; v.finished = true;
removeNodeAndSource(video); removeNodeAndSource(v);
manager.finished(video.token); manager.finished(v.token);
} }
var checkEnded = function(t, v) { return function() { var checkEnded = function(test, v) { return function() {
is(t.name, v.name, t.name + ": Name should match #2"); is(test.name, v.name, test.name + ": Name should match #2");
checkMetadata(t.name, v, t); checkMetadata(test.name, v, test);
is(v.readyState, v.HAVE_CURRENT_DATA, t.name + " checking readyState"); is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
ok(v.ended, t.name + " checking playback has ended"); ok(v.ended, test.name + " checking playback has ended");
finish(); finish();
}}(test, video); }}(test, v);
video.addEventListener("loadedmetadata", check); v.addEventListener("loadedmetadata", check);
video.addEventListener("ended", checkEnded); v.addEventListener("ended", checkEnded);
document.body.appendChild(video); document.body.appendChild(v);
} }
manager.runTests(gSmallTests, startTest); manager.runTests(gSmallTests, startTest);

View file

@ -32,7 +32,7 @@ function check_full_file_played(element) {
var tests = [ var tests = [
// Without playing, check that player.played.length == 0. // Without playing, check that player.played.length == 0.
{ {
setup(element) { setup : function(element) {
element.addEventListener("loadedmetadata", function() { element.addEventListener("loadedmetadata", function() {
is(element.played.length, 0, element.token + ": initial played.length equals zero"); is(element.played.length, 0, element.token + ": initial played.length equals zero");
finish_test(element); finish_test(element);
@ -42,7 +42,7 @@ var tests = [
}, },
// Play the file, test the range we have. // Play the file, test the range we have.
{ {
setup(element) { setup : function(element) {
check_full_file_played(element); check_full_file_played(element);
element.play(); element.play();
}, },
@ -52,7 +52,7 @@ var tests = [
// Play the second half of the file, pause, play // Play the second half of the file, pause, play
// an check we have only one range. // an check we have only one range.
{ {
setup (element) { setup : function (element) {
element.onended = function (e) { element.onended = function (e) {
var t = e.target; var t = e.target;
t.onended = null; t.onended = null;
@ -72,7 +72,7 @@ var tests = [
// Play the first half of the file, seek back, while // Play the first half of the file, seek back, while
// continuing to play. We shall have only one range. // continuing to play. We shall have only one range.
{ {
setup (element) { setup : function (element) {
let onTimeUpdate = function() { let onTimeUpdate = function() {
if (element.currentTime > element.duration / 2) { if (element.currentTime > element.duration / 2) {
info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration); info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration);
@ -95,7 +95,7 @@ var tests = [
// Play and seek to have two ranges, and check that, as well a // Play and seek to have two ranges, and check that, as well a
// boundaries. // boundaries.
{ {
setup (element) { setup : function (element) {
let seekTarget = 0; let seekTarget = 0;
let onTimeUpdate = function() { let onTimeUpdate = function() {
if (element.currentTime > element.duration / 2) { if (element.currentTime > element.duration / 2) {
@ -132,7 +132,7 @@ var tests = [
// Play to create two ranges, in the reverse order. check that they are sorted. // Play to create two ranges, in the reverse order. check that they are sorted.
{ {
setup (element) { setup : function (element) {
function end() { function end() {
element.pause(); element.pause();
let p = element.played; let p = element.played;
@ -178,7 +178,7 @@ var tests = [
}, },
// Seek repeatedly without playing. No range should appear. // Seek repeatedly without playing. No range should appear.
{ {
setup(element) { setup : function(element) {
let index = 1; let index = 1;
element.addEventListener('seeked', function() { element.addEventListener('seeked', function() {
@ -202,7 +202,7 @@ function createTestArray() {
var A = []; var A = [];
for (var i=0; i<tests.length; i++) { for (var i=0; i<tests.length; i++) {
for (var k=0; k<gPlayedTests.length; k++) { for (var k=0; k<gPlayedTests.length; k++) {
var t = {}; var t = new Object();
t.setup = tests[i].setup; t.setup = tests[i].setup;
t.name = tests[i].name + "-" + gPlayedTests[k].name; t.name = tests[i].name + "-" + gPlayedTests[k].name;
t.type = gPlayedTests[k].type; t.type = gPlayedTests[k].type;

View file

@ -41,7 +41,6 @@ addLoadEvent(function() {gotLoadEvent=true;});
function log(m) { function log(m) {
var l = document.getElementById("log"); var l = document.getElementById("log");
// eslint-disable-next-line no-unsanitized/property
l.innerHTML += m; l.innerHTML += m;
} }
@ -66,7 +65,8 @@ var tests = [
// after receiving a suspend event. Should not receive loaded events until after we call load(). // after receiving a suspend event. Should not receive loaded events until after we call load().
// Note the suspend event is explictly sent by our "stop the load" code, but other tests can't rely // Note the suspend event is explictly sent by our "stop the load" code, but other tests can't rely
// on it for the preload:metadata case, as there can be multiple suspend events when loading metadata. // on it for the preload:metadata case, as there can be multiple suspend events when loading metadata.
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(1) Must get loadstart."); is(v._gotLoadStart, true, "(1) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(1) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(1) Must not get loadedmetadata.");
@ -76,7 +76,8 @@ var tests = [
maybeFinish(v, 1); maybeFinish(v, 1);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -92,7 +93,8 @@ var tests = [
{ {
// 2. Add preload:metadata video with src to document. Should halt with NETWORK_IDLE, HAVE_CURRENT_DATA // 2. Add preload:metadata video with src to document. Should halt with NETWORK_IDLE, HAVE_CURRENT_DATA
// after suspend event and after loadedmetadata. // after suspend event and after loadedmetadata.
loadeddata(e) { loadeddata:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(2) Must get loadstart."); is(v._gotLoadStart, true, "(2) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(2) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(2) Must get loadedmetadata.");
@ -102,7 +104,8 @@ var tests = [
maybeFinish(v, 2); maybeFinish(v, 2);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "metadata"; v.preload = "metadata";
@ -118,14 +121,16 @@ var tests = [
}, },
{ {
// 3. Add preload:auto to document. Should receive canplaythrough eventually. // 3. Add preload:auto to document. Should receive canplaythrough eventually.
canplaythrough(e) { canplaythrough:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(3) Must get loadstart."); is(v._gotLoadStart, true, "(3) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(3) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(3) Must get loadedmetadata.");
maybeFinish(v, 3); maybeFinish(v, 3);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "auto"; v.preload = "auto";
@ -140,7 +145,8 @@ var tests = [
}, },
{ {
// 4. Add preload:none video to document. Call play(), should load then play through. // 4. Add preload:none video to document. Call play(), should load then play through.
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
if (v._gotSuspend) { if (v._gotSuspend) {
return; // We can receive multiple suspend events, like the one after download completes. return; // We can receive multiple suspend events, like the one after download completes.
@ -154,12 +160,14 @@ var tests = [
v.play(); // Should load and play through. v.play(); // Should load and play through.
}, },
ended(e) { ended:
function(e) {
ok(true, "(4) Got playback ended"); ok(true, "(4) Got playback ended");
maybeFinish(e.target, 4); maybeFinish(e.target, 4);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v._gotSuspend = false; v._gotSuspend = false;
@ -177,7 +185,8 @@ var tests = [
{ {
// 5. preload:none video without resource, add to document, will implicitly start a // 5. preload:none video without resource, add to document, will implicitly start a
// preload:none load. Add a src, it shouldn't load. // preload:none load. Add a src, it shouldn't load.
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(5) Must get loadstart."); is(v._gotLoadStart, true, "(5) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(5) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(5) Must not get loadedmetadata.");
@ -187,7 +196,8 @@ var tests = [
maybeFinish(v, 5); maybeFinish(v, 5);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -203,7 +213,8 @@ var tests = [
{ {
// 6. preload:none video without resource, add to document, will implicitly start a // 6. preload:none video without resource, add to document, will implicitly start a
// preload:none load. Add a source, it shouldn't load. // preload:none load. Add a source, it shouldn't load.
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(6) Must get loadstart."); is(v._gotLoadStart, true, "(6) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(6) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(6) Must not get loadedmetadata.");
@ -213,7 +224,8 @@ var tests = [
maybeFinish(v, 6); maybeFinish(v, 6);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -232,7 +244,8 @@ var tests = [
{ {
// 7. create a preload:none document with multiple sources, the first of which is invalid. // 7. create a preload:none document with multiple sources, the first of which is invalid.
// Add to document, then play. It should load and play through the second source. // Add to document, then play. It should load and play through the second source.
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
if (v._gotSuspend) if (v._gotSuspend)
return; // We can receive multiple suspend events, like the one after download completes. return; // We can receive multiple suspend events, like the one after download completes.
@ -245,14 +258,16 @@ var tests = [
v.play(); // Should load and play through. v.play(); // Should load and play through.
}, },
ended(e) { ended:
function(e) {
ok(true, "(7) Got playback ended"); ok(true, "(7) Got playback ended");
var v = e.target; var v = e.target;
is(v._gotErrorEvent, true, "(7) Should get error event from first source load failure"); is(v._gotErrorEvent, true, "(7) Should get error event from first source load failure");
maybeFinish(v, 7); maybeFinish(v, 7);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -277,7 +292,8 @@ var tests = [
}, },
{ {
// 8. Change preload value from none to metadata should cause metadata to be loaded. // 8. Change preload value from none to metadata should cause metadata to be loaded.
loadeddata(e) { loadeddata:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(8) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(8) Must get loadedmetadata.");
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(8) ReadyState must be >= HAVE_CURRENT_DATA on suspend."); ok(v.readyState >= v.HAVE_CURRENT_DATA, "(8) ReadyState must be >= HAVE_CURRENT_DATA on suspend.");
@ -286,7 +302,8 @@ var tests = [
maybeFinish(v, 8); maybeFinish(v, 8);
}, },
setup(v) { setup:
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "metadata";}); v.addEventListener("loadstart", function(e){v.preload = "metadata";});
@ -325,13 +342,15 @@ var tests = [
},*/ },*/
{ {
// 10. Change preload value from none to auto should cause entire media to be loaded. // 10. Change preload value from none to auto should cause entire media to be loaded.
canplaythrough(e) { canplaythrough:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(10) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(10) Must get loadedmetadata.");
maybeFinish(v, 10); maybeFinish(v, 10);
}, },
setup(v) { setup:
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "auto";}); v.addEventListener("loadstart", function(e){v.preload = "auto";});
@ -345,7 +364,8 @@ var tests = [
}, },
{ {
// 11. Change preload value from none to metadata should cause metadata to load. // 11. Change preload value from none to metadata should cause metadata to load.
loadeddata(e) { loadeddata:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadedMetaData, true, "(11) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(11) Must get loadedmetadata.");
ok(v.readyState >= v.HAVE_CURRENT_DATA, "(11) ReadyState must be >= HAVE_CURRENT_DATA."); ok(v.readyState >= v.HAVE_CURRENT_DATA, "(11) ReadyState must be >= HAVE_CURRENT_DATA.");
@ -354,7 +374,8 @@ var tests = [
maybeFinish(v, 11); maybeFinish(v, 11);
}, },
setup(v) { setup:
function(v) {
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
v.addEventListener("loadstart", function(e){v.preload = "metadata";}); v.addEventListener("loadstart", function(e){v.preload = "metadata";});
@ -369,7 +390,8 @@ var tests = [
{ {
// 13. Change preload value from auto to none after specifying a src // 13. Change preload value from auto to none after specifying a src
// should load according to preload none, no buffering should have taken place // should load according to preload none, no buffering should have taken place
suspend(e) { suspend:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(13) Must get loadstart."); is(v._gotLoadStart, true, "(13) Must get loadstart.");
is(v._gotLoadedMetaData, false, "(13) Must not get loadedmetadata."); is(v._gotLoadedMetaData, false, "(13) Must not get loadedmetadata.");
@ -379,7 +401,8 @@ var tests = [
maybeFinish(v, 13); maybeFinish(v, 13);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "auto"; v.preload = "auto";
@ -389,14 +412,15 @@ var tests = [
v.addEventListener("loadstart", function(e){v._gotLoadStart = true;}); v.addEventListener("loadstart", function(e){v._gotLoadStart = true;});
v.addEventListener("suspend", this.suspend); v.addEventListener("suspend", this.suspend);
document.body.appendChild(v); // Causes implicit load, should load according to preload none document.body.appendChild(v); // Causes implicit load, should load according to preload none
document.createElement("source"); var s = document.createElement("source");
}, },
name: "test13", name: "test13",
}, },
{ {
// 14. Add preload:metadata video with src to document. Play(), should play through. // 14. Add preload:metadata video with src to document. Play(), should play through.
loadeddata(e) { loadeddata:
function(e) {
var v = e.target; var v = e.target;
is(v._gotLoadStart, true, "(14) Must get loadstart."); is(v._gotLoadStart, true, "(14) Must get loadstart.");
is(v._gotLoadedMetaData, true, "(14) Must get loadedmetadata."); is(v._gotLoadedMetaData, true, "(14) Must get loadedmetadata.");
@ -406,13 +430,15 @@ var tests = [
v.play(); v.play();
}, },
ended(e) { ended:
function(e) {
ok(true, "(14) Got playback ended"); ok(true, "(14) Got playback ended");
var v = e.target; var v = e.target;
maybeFinish(v, 14); maybeFinish(v, 14);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "metadata"; v.preload = "metadata";
@ -429,13 +455,15 @@ var tests = [
}, },
{ {
// 15. Autoplay should override preload:none. // 15. Autoplay should override preload:none.
ended(e) { ended:
function(e) {
ok(true, "(15) Got playback ended."); ok(true, "(15) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 15); maybeFinish(v, 15);
}, },
setup(v) { setup:
function(v) {
v._gotLoadStart = false; v._gotLoadStart = false;
v._gotLoadedMetaData = false; v._gotLoadedMetaData = false;
v.preload = "none"; v.preload = "none";
@ -451,6 +479,7 @@ var tests = [
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort", "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
"waiting", "pause"]; "waiting", "pause"];
function logEvent(e) { function logEvent(e) {
var v = e.target;
info(e.target.token + ": got " + e.type); info(e.target.token + ": got " + e.type);
} }
events.forEach(function(e) { events.forEach(function(e) {
@ -462,13 +491,15 @@ var tests = [
}, },
{ {
// 16. Autoplay should override preload:metadata. // 16. Autoplay should override preload:metadata.
ended(e) { ended:
function(e) {
ok(true, "(16) Got playback ended."); ok(true, "(16) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 16); maybeFinish(v, 16);
}, },
setup(v) { setup:
function(v) {
v.preload = "metadata"; v.preload = "metadata";
v.autoplay = true; v.autoplay = true;
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
@ -480,13 +511,15 @@ var tests = [
}, },
{ {
// 17. On a preload:none video, adding autoplay should disable preload none, i.e. don't break autoplay! // 17. On a preload:none video, adding autoplay should disable preload none, i.e. don't break autoplay!
ended(e) { ended:
function(e) {
ok(true, "(17) Got playback ended."); ok(true, "(17) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 17); maybeFinish(v, 17);
}, },
setup(v) { setup:
function(v) {
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
v.preload = "none"; v.preload = "none";
document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none. document.body.appendChild(v); // Causes implicit load, which will be halted due to preload:none.
@ -499,13 +532,15 @@ var tests = [
{ {
// 18. On a preload='none' video, call play() before load algorithms's sync // 18. On a preload='none' video, call play() before load algorithms's sync
// has run, the play() call should override preload='none'. // has run, the play() call should override preload='none'.
ended(e) { ended:
function(e) {
ok(true, "(18) Got playback ended."); ok(true, "(18) Got playback ended.");
var v = e.target; var v = e.target;
maybeFinish(v, 18); maybeFinish(v, 18);
}, },
setup(v) { setup:
function(v) {
v.addEventListener("ended", this.ended); v.addEventListener("ended", this.ended);
v.preload = "none"; v.preload = "none";
v.src = test.name; // Schedules async section to continue load algorithm. v.src = test.name; // Schedules async section to continue load algorithm.
@ -518,7 +553,8 @@ var tests = [
{ {
// 19. Set preload='auto' on first video source then switching preload='none' and swapping the video source to another. // 19. Set preload='auto' on first video source then switching preload='none' and swapping the video source to another.
// The second video should not start playing as it's preload state has been changed to 'none' from 'auto' // The second video should not start playing as it's preload state has been changed to 'none' from 'auto'
setup(v) { setup:
function(v) {
v.preload = "auto"; v.preload = "auto";
v.src = test.name; v.src = test.name;
// add a listener for when the video has loaded, so we know preload auto has worked // add a listener for when the video has loaded, so we know preload auto has worked
@ -555,18 +591,18 @@ var tests = [
]; ];
var iterationCount = 0; var iterationCount = 0;
function startTest(t, token) { function startTest(test, token) {
if (t == tests[0]) { if (test == tests[0]) {
++iterationCount; ++iterationCount;
info("iterationCount=" + iterationCount); info("iterationCount=" + iterationCount);
} }
if (iterationCount == 2) { if (iterationCount == 2) {
// Do this series of tests on logically different resources // Do this series of tests on logically different resources
t.name = baseName + "?" + Math.floor(Math.random()*100000); test.name = baseName + "?" + Math.floor(Math.random()*100000);
} }
var v = document.createElement("video"); var v = document.createElement("video");
v.token = token; v.token = token;
t.setup(v); test.setup(v);
manager.started(token); manager.started(token);
} }

View file

@ -29,7 +29,7 @@ var tests = [
name: 'v1', name: 'v1',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend(evt) { onsuspend: function(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.preload = 'auto'; evt.target.preload = 'auto';
@ -53,7 +53,7 @@ var tests = [
name: 'v4', name: 'v4',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend(evt) { onsuspend: function(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.play(); evt.target.play();
@ -76,7 +76,7 @@ var tests = [
name: 'v6', name: 'v6',
preload: 'none', preload: 'none',
expectedSuspendCount: 2, expectedSuspendCount: 2,
onsuspend(evt) { onsuspend: function(evt) {
checkSuspendCount(evt); checkSuspendCount(evt);
if (evt.target.suspendCount == 1) { if (evt.target.suspendCount == 1) {
evt.target.autoplay = true; evt.target.autoplay = true;

View file

@ -31,7 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=975270
is(a._emptied, 0, "Should not have received 'emptied' before 'loadedmetadata"); is(a._emptied, 0, "Should not have received 'emptied' before 'loadedmetadata");
a.addEventListener("loadstart", a.addEventListener("loadstart",
function() { function(e) {
is(a._abort, 1, "Should have received 'abort' before 'loadstart"); is(a._abort, 1, "Should have received 'abort' before 'loadstart");
is(a._emptied, 1, "Should have received 'emptied' before 'loadstart"); is(a._emptied, 1, "Should have received 'emptied' before 'loadstart");
SimpleTest.finish(); SimpleTest.finish();

View file

@ -35,7 +35,7 @@ function onLoadedData_Audio(e) {
var c = document.getElementsByTagName("canvas")[0].getContext("2d"); var c = document.getElementsByTagName("canvas")[0].getContext("2d");
try { try {
c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth); c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
} catch (ex) { } catch (e) {
ok(true, t.name + ": Trying to draw to a canvas should throw, since we don't have a frame anymore"); ok(true, t.name + ": Trying to draw to a canvas should throw, since we don't have a frame anymore");
finish(t); finish(t);
return; return;
@ -56,7 +56,6 @@ function onTimeUpdate_Video(e) {
ok(t.mozFrameDelay >= 0, t.name + ": mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + "."); ok(t.mozFrameDelay >= 0, t.name + ": mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
if (t._firstTime) { if (t._firstTime) {
// eslint-disable-next-line no-self-assign
t.src = t.src; t.src = t.src;
t._firstTime = false; t._firstTime = false;
} else { } else {

Some files were not shown because too many files have changed in this diff Show more