зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1021794 - Fix and re-enable test_played.html. r=cpearce
This commit is contained in:
Родитель
e47c829183
Коммит
ffcd9af8d5
|
@ -446,7 +446,6 @@ skip-if = (toolkit == 'android' && processor == 'x86') #bug 845162
|
||||||
[test_playback_rate_playpause.html]
|
[test_playback_rate_playpause.html]
|
||||||
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
|
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
|
||||||
[test_played.html]
|
[test_played.html]
|
||||||
skip-if = true # bug 1021794
|
|
||||||
[test_preload_actions.html]
|
[test_preload_actions.html]
|
||||||
[test_preload_attribute.html]
|
[test_preload_attribute.html]
|
||||||
[test_preload_suspend.html]
|
[test_preload_suspend.html]
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
<body>
|
<body>
|
||||||
<pre id='test'>
|
<pre id='test'>
|
||||||
<script class="testbody" type='application/javascript;version=1.8'>
|
<script class="testbody" type='application/javascript;version=1.8'>
|
||||||
|
//longer timeout for sometimes B2G emulator runs very slowly
|
||||||
|
if (SpecialPowers.Services.appinfo.name == "B2G") {
|
||||||
|
SimpleTest.requestLongerTimeout(3);
|
||||||
|
}
|
||||||
|
|
||||||
let manager = new MediaTestManager;
|
let manager = new MediaTestManager;
|
||||||
|
|
||||||
SimpleTest.expectAssertions(0, 2);
|
|
||||||
|
|
||||||
function finish_test(element) {
|
function finish_test(element) {
|
||||||
if (element.parentNode)
|
removeNodeAndSource(element);
|
||||||
element.parentNode.removeChild(element);
|
|
||||||
element.src="";
|
|
||||||
manager.finished(element.token);
|
manager.finished(element.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ function finish_test(element) {
|
||||||
function check_full_file_played(element) {
|
function check_full_file_played(element) {
|
||||||
element.addEventListener('ended', (function(e) {
|
element.addEventListener('ended', (function(e) {
|
||||||
let interval_count = e.target.played.length;
|
let interval_count = e.target.played.length;
|
||||||
is(interval_count, 1, "normal play : a.played.length must be 1");
|
is(interval_count, 1, element.token + ": played.length must be 1");
|
||||||
is(element.played.start(0), 0, "start time shall be 0");
|
is(element.played.start(0), 0, element.token + ": start time shall be 0");
|
||||||
is(element.played.end(0), e.target.duration, "end time shall be duration");
|
is(element.played.end(0), e.target.duration, element.token + ": end time shall be duration");
|
||||||
finish_test(e.target);
|
finish_test(e.target);
|
||||||
}), false);
|
}), false);
|
||||||
}
|
}
|
||||||
|
@ -38,35 +38,39 @@ var tests = [
|
||||||
{
|
{
|
||||||
setup : function(element) {
|
setup : function(element) {
|
||||||
element.addEventListener("loadedmetadata", function() {
|
element.addEventListener("loadedmetadata", function() {
|
||||||
is(element.played.length, 0, "audio : initial played.length equals zero");
|
is(element.played.length, 0, element.token + ": initial played.length equals zero");
|
||||||
finish_test(element);
|
finish_test(element);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
name: "test1"
|
||||||
},
|
},
|
||||||
// Play the file, test the range we have.
|
// Play the file, test the range we have.
|
||||||
{
|
{
|
||||||
setup : function(element) {
|
setup : function(element) {
|
||||||
check_full_file_played(element);
|
check_full_file_played(element);
|
||||||
element.play();
|
element.play();
|
||||||
}
|
},
|
||||||
|
name: "test2"
|
||||||
},
|
},
|
||||||
|
|
||||||
// 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 : function (element) {
|
setup : function (element) {
|
||||||
element.addEventListener("ended", function (e) {
|
element.onended = function (e) {
|
||||||
var t = e.target;
|
var t = e.target;
|
||||||
|
t.onended = null;
|
||||||
check_full_file_played(t);
|
check_full_file_played(t);
|
||||||
t.pause();
|
t.pause();
|
||||||
t.currentTime = 0;
|
t.currentTime = 0;
|
||||||
t.play();
|
t.play();
|
||||||
}, false);
|
};
|
||||||
element.addEventListener("loadedmetadata", function() {
|
element.addEventListener("loadedmetadata", function() {
|
||||||
element.currentTime = element.duration / 2;
|
element.currentTime = element.duration / 2;
|
||||||
element.play();
|
element.play();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
},
|
||||||
|
name: "test3"
|
||||||
},
|
},
|
||||||
|
|
||||||
// Play the first half of the file, seek back, while
|
// Play the first half of the file, seek back, while
|
||||||
|
@ -74,31 +78,36 @@ var tests = [
|
||||||
{
|
{
|
||||||
setup : function (element) {
|
setup : function (element) {
|
||||||
let onTimeUpdate = function() {
|
let onTimeUpdate = function() {
|
||||||
if (element.currentTime > element.duration/2) {
|
if (element.currentTime > element.duration / 2) {
|
||||||
element.removeEventListener("timeupdate", onTimeUpdate, false);
|
element.removeEventListener("timeupdate", onTimeUpdate, false);
|
||||||
element.pause();
|
element.pause();
|
||||||
var oldEndRange = element.played.end(0);
|
var oldEndRange = element.played.end(0);
|
||||||
element.currentTime = element.duration / 4;
|
element.currentTime = element.duration / 4;
|
||||||
is(element.played.end(0), oldEndRange,
|
is(element.played.end(0), oldEndRange,
|
||||||
"When seeking back, |played| should not be changed");
|
element.token + ": When seeking back, |played| should not be changed");
|
||||||
element.play();
|
element.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.addEventListener("timeupdate", onTimeUpdate, false);
|
element.addEventListener("timeupdate", onTimeUpdate, false);
|
||||||
check_full_file_played(element);
|
check_full_file_played(element);
|
||||||
element.play();
|
element.play();
|
||||||
}
|
},
|
||||||
|
name: "test4"
|
||||||
},
|
},
|
||||||
|
|
||||||
// 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 : function (element) {
|
setup : function (element) {
|
||||||
|
let seekTarget = 0;
|
||||||
let onTimeUpdate = function() {
|
let onTimeUpdate = function() {
|
||||||
if (element.currentTime > element.duration / 2) {
|
if (element.currentTime > element.duration / 2) {
|
||||||
element.removeEventListener("timeupdate", onTimeUpdate, false);
|
element.removeEventListener("timeupdate", onTimeUpdate, false);
|
||||||
element.pause();
|
element.pause();
|
||||||
element.currentTime += element.duration/10;
|
// Remember seek target for later comparison since duration may change
|
||||||
|
// during playback.
|
||||||
|
seekTarget = element.currentTime = element.duration / 10;
|
||||||
|
element.currentTime = seekTarget;
|
||||||
element.play();
|
element.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,17 +119,17 @@ var tests = [
|
||||||
|
|
||||||
element.addEventListener("ended", (function() {
|
element.addEventListener("ended", (function() {
|
||||||
if(element.played.length > 1) {
|
if(element.played.length > 1) {
|
||||||
is(element.played.length, 2, "element.played.length == 2");
|
is(element.played.length, 2, element.token + ": element.played.length == 2");
|
||||||
var guess = element.played.end(0) + element.duration/10.0;
|
is(element.played.start(1), seekTarget, element.token + ": we should have seeked forward by one tenth of the duration");
|
||||||
ok(rangeCheck(element.played.start(1), guess), "we should have seeked forward by one tenth of the duration");
|
is(element.played.end(1), element.duration, element.token + ": end of second range shall be the total duration");
|
||||||
is(element.played.end(1), element.duration, "end of second range shall be the total duration");
|
|
||||||
}
|
}
|
||||||
is(element.played.start(0), 0, "start of first range shall be 0");
|
is(element.played.start(0), 0, element.token + ": start of first range shall be 0");
|
||||||
finish_test(element);
|
finish_test(element);
|
||||||
}), false);
|
}), false);
|
||||||
|
|
||||||
element.play();
|
element.play();
|
||||||
}
|
},
|
||||||
|
name: "test5"
|
||||||
},
|
},
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -129,20 +138,24 @@ var tests = [
|
||||||
function end() {
|
function end() {
|
||||||
element.pause();
|
element.pause();
|
||||||
let p = element.played;
|
let p = element.played;
|
||||||
ok(p.length >= 1, "There should be at least one range");
|
ok(p.length >= 1, element.token + ": There should be at least one range=" + p.length);
|
||||||
is(p.start(0), element.duration/6, "Start of first range should be the sixth of the duration");
|
is(p.start(0), seekTarget, element.token + ": Start of first range should be the sixth of the duration");
|
||||||
ok(p.end(p.length - 1) > 5*element.duration/6, "End of last range should be greater that five times the sixth of the duration");
|
ok(p.end(p.length - 1) > 5 * element.duration / 6, element.token + ": End of last range should be greater that five times the sixth of the duration");
|
||||||
finish_test(element);
|
finish_test(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let seekTarget = 0;
|
||||||
function pauseseekrestart() {
|
function pauseseekrestart() {
|
||||||
element.pause();
|
element.pause();
|
||||||
element.currentTime = element.duration/6;
|
// Remember seek target for later comparison since duration may change
|
||||||
|
// during playback.
|
||||||
|
seekTarget = element.duration / 6;
|
||||||
|
element.currentTime = seekTarget;
|
||||||
element.play();
|
element.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTimeUpdate_pauseseekrestart() {
|
function onTimeUpdate_pauseseekrestart() {
|
||||||
if (element.currentTime > 5*element.duration/6) {
|
if (element.currentTime > 5 * element.duration / 6) {
|
||||||
element.removeEventListener("timeupdate", onTimeUpdate_pauseseekrestart, false);
|
element.removeEventListener("timeupdate", onTimeUpdate_pauseseekrestart, false);
|
||||||
pauseseekrestart();
|
pauseseekrestart();
|
||||||
element.addEventListener("timeupdate", onTimeUpdate_end, false);
|
element.addEventListener("timeupdate", onTimeUpdate_end, false);
|
||||||
|
@ -150,7 +163,7 @@ var tests = [
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTimeUpdate_end() {
|
function onTimeUpdate_end() {
|
||||||
if (element.currentTime > 3 * element.duration/6) {
|
if (element.currentTime > 3 * element.duration / 6) {
|
||||||
element.removeEventListener("timeupdate", onTimeUpdate_end, false);
|
element.removeEventListener("timeupdate", onTimeUpdate_end, false);
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
|
@ -159,10 +172,11 @@ var tests = [
|
||||||
element.addEventListener("timeupdate", onTimeUpdate_pauseseekrestart, false);
|
element.addEventListener("timeupdate", onTimeUpdate_pauseseekrestart, false);
|
||||||
|
|
||||||
element.addEventListener('loadedmetadata', function() {
|
element.addEventListener('loadedmetadata', function() {
|
||||||
element.currentTime = 4 * element.duration/6;
|
element.currentTime = 4 * element.duration / 6;
|
||||||
element.play();
|
element.play();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
},
|
||||||
|
name: "test6"
|
||||||
},
|
},
|
||||||
// Seek repeatedly without playing. No range should appear.
|
// Seek repeatedly without playing. No range should appear.
|
||||||
{
|
{
|
||||||
|
@ -172,7 +186,7 @@ var tests = [
|
||||||
element.addEventListener('seeked', function() {
|
element.addEventListener('seeked', function() {
|
||||||
index++;
|
index++;
|
||||||
element.currentTime = index * element.duration / 5;
|
element.currentTime = index * element.duration / 5;
|
||||||
is(element.played.length, 0, "element.played.length should be 0");
|
is(element.played.length, 0, element.token + ": played.length should be 0");
|
||||||
if (index == 5) {
|
if (index == 5) {
|
||||||
finish_test(element);
|
finish_test(element);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +195,8 @@ var tests = [
|
||||||
element.addEventListener('loadedmetadata', function() {
|
element.addEventListener('loadedmetadata', function() {
|
||||||
element.currentTime = element.duration / 5;
|
element.currentTime = element.duration / 5;
|
||||||
}, false);
|
}, false);
|
||||||
}
|
},
|
||||||
|
name: "test7"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -200,8 +215,9 @@ function createTestArray() {
|
||||||
for (var k=0; k<gPlayedTests.length; k++) {
|
for (var k=0; k<gPlayedTests.length; k++) {
|
||||||
var t = new Object();
|
var t = new Object();
|
||||||
t.setup = tests[i].setup;
|
t.setup = tests[i].setup;
|
||||||
t.name = gPlayedTests[k].name;
|
t.name = tests[i].name + "-" + gPlayedTests[k].name;
|
||||||
t.type = gPlayedTests[k].type;
|
t.type = gPlayedTests[k].type;
|
||||||
|
t.src = gPlayedTests[k].name;
|
||||||
A.push(t);
|
A.push(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,9 +227,9 @@ function createTestArray() {
|
||||||
function startTest(test, token) {
|
function startTest(test, token) {
|
||||||
var elemType = getMajorMimeType(test.type);
|
var elemType = getMajorMimeType(test.type);
|
||||||
var element = document.createElement(elemType);
|
var element = document.createElement(elemType);
|
||||||
element.src = test.name;
|
element.src = test.src;
|
||||||
element.token = token;
|
element.token = token;
|
||||||
element.volume = 0;
|
element.preload = "metadata";
|
||||||
test.setup(element);
|
test.setup(element);
|
||||||
manager.started(token);
|
manager.started(token);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче