зеркало из https://github.com/mozilla/gecko-dev.git
Bug 564720 - Refactor media tests to be backend independent were possible. r=roc
--HG-- rename : content/media/test/test_play.html => content/media/test/test_play_events.html rename : content/media/test/test_progress2.html => content/media/test/test_progress.html rename : content/media/test/test_onloadedmetadata.html => content/media/test/test_replay_metadata.html rename : content/media/test/test_wav_trunc_seek.html => content/media/test/test_seek_out_of_range.html rename : content/media/test/test_bug495319.html => content/media/test/test_timeupdate_small_files.html rename : content/media/test/test_bug486646.html => content/media/test/test_video_to_canvas.html
This commit is contained in:
Родитель
3b86d6984a
Коммит
a7d0ccd23a
Двоичные данные
content/media/test/320x240.allow-origin.ogv
Двоичные данные
content/media/test/320x240.allow-origin.ogv
Двоичный файл не отображается.
|
@ -1 +0,0 @@
|
|||
Access-Control-Allow-Origin: *
|
|
@ -67,11 +67,15 @@ include $(topsrcdir)/config/rules.mk
|
|||
# supported, just do ok(true, "Type not supported") and stop the test.
|
||||
|
||||
_TEST_FILES = \
|
||||
allowed.sjs \
|
||||
can_play_type_ogg.js \
|
||||
can_play_type_wave.js \
|
||||
cancellable_request.sjs \
|
||||
dynamic_redirect.sjs \
|
||||
file_access_controls.html \
|
||||
manifest.js \
|
||||
reactivate_helper.html \
|
||||
redirect.sjs \
|
||||
seek1.js \
|
||||
seek2.js \
|
||||
seek3.js \
|
||||
|
@ -82,43 +86,81 @@ _TEST_FILES = \
|
|||
seek8.js \
|
||||
seek9.js \
|
||||
seek10.js \
|
||||
seek11.js \
|
||||
test_access_control.html \
|
||||
test_audio1.html \
|
||||
test_audio2.html \
|
||||
test_autobuffer.html \
|
||||
test_autoplay.html \
|
||||
test_bug448534.html \
|
||||
test_bug463162.xhtml \
|
||||
test_bug465498.html \
|
||||
test_bug493187.html \
|
||||
test_bug495145.html \
|
||||
test_bug495300.html \
|
||||
test_can_play_type.html \
|
||||
test_closing_connections.html \
|
||||
test_constants.html \
|
||||
test_controls.html \
|
||||
test_currentTime.html \
|
||||
test_decode_error.html \
|
||||
test_decoder_disable.html \
|
||||
test_delay_load.html \
|
||||
test_error_on_404.html \
|
||||
test_info_leak.html \
|
||||
test_load.html \
|
||||
test_load_candidates.html \
|
||||
test_media_selection.html \
|
||||
test_mixed_principals.html \
|
||||
test_mozLoadFrom.html \
|
||||
test_networkState.html \
|
||||
test_new_audio.html \
|
||||
test_paused.html \
|
||||
test_paused_after_ended.html \
|
||||
test_play_events.html \
|
||||
test_play_twice.html \
|
||||
test_playback.html \
|
||||
test_playback_errors.html \
|
||||
test_progress.html \
|
||||
test_reactivate.html \
|
||||
test_readyState.html \
|
||||
test_replay_metadata.html \
|
||||
test_seek.html \
|
||||
test_seek2.html \
|
||||
test_seek_out_of_range.html \
|
||||
test_source.html \
|
||||
test_source_write.html \
|
||||
test_standalone.html \
|
||||
test_timeupdate_small_files.html \
|
||||
test_volume.html \
|
||||
test_video_to_canvas.html \
|
||||
use_large_cache.js \
|
||||
$(NULL)
|
||||
|
||||
# Disabled due to flakiness
|
||||
# These tests are disabled until we figure out random failures.
|
||||
# When these tests are fixed, we should also make them backend-independent.
|
||||
# test_resume.html \
|
||||
#
|
||||
# Bug 492821:
|
||||
# test_videoDocumentTitle.html
|
||||
# Bug 493692:
|
||||
# test_autobuffer2.html
|
||||
# Disabled since we don't play Wave files standalone, for now
|
||||
# test_audioDocumentTitle.html
|
||||
|
||||
ifdef MOZ_OGG
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
# Disabled on windows until we figure out the random failures.
|
||||
# When this is fixed, make it backend-independent please.
|
||||
# See bug 475369 and bug 526323
|
||||
_TEST_FILES += \
|
||||
test_timeupdate3.html \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Ogg sample files
|
||||
_TEST_FILES += \
|
||||
320x240.ogv \
|
||||
320x240.allow-origin.ogv \
|
||||
320x240.allow-origin.ogv^headers^ \
|
||||
448636.ogv \
|
||||
audio-overhang.ogg \
|
||||
beta-phrasebook.ogg \
|
||||
|
@ -173,20 +215,11 @@ _TEST_FILES += \
|
|||
bogus.duh \
|
||||
$(NULL)
|
||||
|
||||
# These tests need to be converted to be backend-independent. This list
|
||||
# is deprecated, do not add to it.
|
||||
# These tests contain backend-specific tests. Try to write backend
|
||||
# independent tests rather than adding to this list.
|
||||
ifdef MOZ_OGG
|
||||
_TEST_FILES += \
|
||||
dynamic_redirect.sjs \
|
||||
file_access_controls.html \
|
||||
test_access_control.html \
|
||||
test_bug448534.html \
|
||||
test_bug468190.html \
|
||||
test_bug486646.html \
|
||||
test_bug493187.html \
|
||||
test_bug495145.html \
|
||||
test_bug495319.html \
|
||||
test_closing_connections.html \
|
||||
test_can_play_type_ogg.html \
|
||||
test_contentDuration1.html \
|
||||
test_contentDuration2.html \
|
||||
test_contentDuration3.html \
|
||||
|
@ -194,24 +227,6 @@ _TEST_FILES += \
|
|||
test_contentDuration5.html \
|
||||
test_contentDuration6.html \
|
||||
test_contentDuration7.html \
|
||||
test_delay_load.html \
|
||||
test_duration1.html \
|
||||
test_ended1.html \
|
||||
test_ended2.html \
|
||||
test_error_on_404.html \
|
||||
test_info_leak.html \
|
||||
test_onloadedmetadata.html \
|
||||
test_load_candidates.html \
|
||||
test_mixed_principals.html \
|
||||
test_play.html \
|
||||
test_progress1.html \
|
||||
test_progress3.html \
|
||||
test_source.html \
|
||||
test_source_write.html \
|
||||
test_standalone.html \
|
||||
test_timeupdate1.html \
|
||||
test_timeupdate2.html \
|
||||
redirect.sjs \
|
||||
contentDuration1.sjs \
|
||||
contentDuration2.sjs \
|
||||
contentDuration3.sjs \
|
||||
|
@ -220,53 +235,12 @@ _TEST_FILES += \
|
|||
contentDuration6.sjs \
|
||||
contentDuration7.sjs \
|
||||
$(NULL)
|
||||
# These tests disabled until we figure out random failures.
|
||||
# Bug 492821:
|
||||
# test_videoDocumentTitle.html
|
||||
# Bug 493692:
|
||||
# test_autobuffer2.html
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
# These tests are disabled on windows until we
|
||||
# figure out the random failures. See bug 475369 and bug 526323
|
||||
_TEST_FILES += \
|
||||
test_timeupdate3.html \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_OGG
|
||||
_TEST_FILES += \
|
||||
test_can_play_type_ogg.html \
|
||||
$(NULL)
|
||||
else
|
||||
_TEST_FILES += \
|
||||
test_can_play_type_no_ogg.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# These tests need to be converted to be backend-independent. This list
|
||||
# is deprecated, do not add to it.
|
||||
ifdef MOZ_WAVE
|
||||
_TEST_FILES += \
|
||||
test_bug463162.xhtml \
|
||||
test_bug465498.html \
|
||||
test_bug468190_wav.html \
|
||||
test_bug495145_wav.html \
|
||||
test_paused_after_ended.html \
|
||||
test_progress2.html \
|
||||
test_progress4.html \
|
||||
test_wav_ended1.html \
|
||||
test_wav_ended2.html \
|
||||
test_wav_onloadedmetadata.html \
|
||||
test_wav_timeupdate1.html \
|
||||
test_wav_timeupdate2.html \
|
||||
test_wav_trunc_seek.html \
|
||||
$(NULL)
|
||||
# Disabled since we don't play Wave files standalone, for now
|
||||
# test_wav_standalone.html
|
||||
# test_audioDocumentTitle.html
|
||||
endif
|
||||
|
||||
ifdef MOZ_WAVE
|
||||
_TEST_FILES += \
|
||||
test_can_play_type_wave.html \
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
var types = {
|
||||
ogg: "video/ogg",
|
||||
ogv: "video/ogg",
|
||||
oga: "audio/ogg",
|
||||
webm: "video/webm",
|
||||
wav: "audio/x-wav"
|
||||
};
|
||||
|
||||
// Return file with name as per the query string with access control
|
||||
// allow headers.
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var resource = request.queryString;
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
get("CurWorkD", Components.interfaces.nsILocalFile);
|
||||
var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].
|
||||
createInstance(Components.interfaces.nsIFileInputStream);
|
||||
var bis = Components.classes["@mozilla.org/binaryinputstream;1"].
|
||||
createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
var paths = "tests/content/media/test/" + resource;
|
||||
var split = paths.split("/");
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
file.append(split[i]);
|
||||
}
|
||||
fis.init(file, -1, -1, false);
|
||||
dump("file=" + file + "\n");
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setStatusLine(request.httpVersion, 206, "Partial Content");
|
||||
response.setHeader("Content-Range", "bytes 0-" + (bytes.length - 1) + "/" + bytes.length);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
var ext = resource.substring(resource.lastIndexOf(".")+1);
|
||||
response.setHeader("Content-Type", types[ext], false);
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.write(bytes, bytes.length);
|
||||
bis.close();
|
||||
}
|
|
@ -2,17 +2,18 @@
|
|||
// All subsequent requests return a redirect to a different-origin resource.
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var key = request.queryString.match(/^key=(.*)$/);
|
||||
var key = (request.queryString.match(/^key=(.*)&/))[1];
|
||||
var resource = (request.queryString.match(/res=(.*)$/))[1];
|
||||
|
||||
if (getState(key[1]) == "redirect") {
|
||||
if (getState(key) == "redirect") {
|
||||
var origin = request.host == "mochi.test" ? "example.org" : "mochi.test:8888";
|
||||
response.setStatusLine(request.httpVersion, 303, "See Other");
|
||||
response.setHeader("Location", "http://" + origin + "/tests/content/media/test/seek.ogv");
|
||||
response.setHeader("Location", "http://" + origin + "/tests/content/media/test/" + resource);
|
||||
response.setHeader("Content-Type", "text/html");
|
||||
return;
|
||||
}
|
||||
|
||||
setState(key[1], "redirect");
|
||||
setState(key, "redirect");
|
||||
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
|
@ -21,7 +22,7 @@ function handleRequest(request, response)
|
|||
createInstance(Components.interfaces.nsIFileInputStream);
|
||||
var bis = Components.classes["@mozilla.org/binaryinputstream;1"].
|
||||
createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
var paths = "tests/content/media/test/seek.ogv";
|
||||
var paths = "tests/content/media/test/" + resource;
|
||||
var split = paths.split("/");
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
file.append(split[i]);
|
||||
|
|
|
@ -1,70 +1,73 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body onload="setTimeout(load, 0);" onunload="done()">
|
||||
<script>
|
||||
|
||||
// Page URL: http://example.org/tests/content/media/test/file_access_controls.html
|
||||
|
||||
var gResource = getPlayableVideo(gSmallTests).name;
|
||||
|
||||
var gTests = [
|
||||
{
|
||||
// Test 0
|
||||
url: "redirect.sjs?http://example.com/tests/content/media/test/320x240.ogv",
|
||||
url: "redirect.sjs?domain=example.com&file="+ gResource,
|
||||
result: "error",
|
||||
description: "Won't load when redirected to different domain",
|
||||
},{
|
||||
// Test 1
|
||||
url: "redirect.sjs?http://example.com/tests/content/media/test/320x240.allow-origin.ogv",
|
||||
url: "redirect.sjs?domain=example.com&allowed&file=" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load when redirected to different domain with allow-origin",
|
||||
},{
|
||||
// Test 2
|
||||
url: "redirect.sjs?http://test1.example.org/tests/content/media/test/320x240.ogv",
|
||||
url: "redirect.sjs?domain=test1.example.org&file=" + gResource,
|
||||
result: "error",
|
||||
description: "Won't load when redirected to subdomain",
|
||||
},{
|
||||
// Test 3
|
||||
url: "redirect.sjs?http://test1.example.org/tests/content/media/test/320x240.allow-origin.ogv",
|
||||
url: "redirect.sjs?domain=test1.example.org&allowed&file=" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load when redirected to subdomain with allow-origin",
|
||||
},{
|
||||
// Test 4
|
||||
url: "redirect.sjs?http://example.org/tests/content/media/test/320x240.ogv",
|
||||
url: "redirect.sjs?domain=example.org&file=" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load when redirected to same domain",
|
||||
},{
|
||||
// Test 5
|
||||
url: "http://example.org/tests/content/media/test/320x240.ogv",
|
||||
url: "http://example.org/tests/content/media/test/" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load from same domain"
|
||||
},{
|
||||
// Test 6
|
||||
url: "http://example.org:8000/tests/content/media/test/320x240.ogv",
|
||||
url: "http://example.org:8000/tests/content/media/test/" + gResource,
|
||||
result: "error",
|
||||
description: "Won't load from different port on same domain"
|
||||
},{
|
||||
// Test 7
|
||||
url: "http://example.org:8000/tests/content/media/test/320x240.allow-origin.ogv",
|
||||
url: "http://example.org:8000/tests/content/media/test/allowed.sjs?" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load from different port on same domain with allow-origin",
|
||||
},{
|
||||
// Test 8
|
||||
url: "http://example.com/tests/content/media/test/320x240.ogv",
|
||||
url: "http://example.com/tests/content/media/test/" + gResource,
|
||||
result: "error",
|
||||
description: "Won't load cross domain",
|
||||
},{
|
||||
// Test 9
|
||||
url: "http://example.com/tests/content/media/test/320x240.allow-origin.ogv",
|
||||
url: "http://example.com/tests/content/media/test/allowed.sjs?" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load cross domain with allow-origin",
|
||||
},{
|
||||
// Test 10
|
||||
url: "http://test1.example.org/tests/content/media/test/320x240.allow-origin.ogv",
|
||||
url: "http://test1.example.org/tests/content/media/test/allowed.sjs?" + gResource,
|
||||
result: "loadeddata",
|
||||
description: "Can load from subdomain with allow-origin",
|
||||
},{
|
||||
// Test 11
|
||||
url: "http://test1.example.org/tests/content/media/test/320x240.ogv",
|
||||
url: "http://test1.example.org/tests/content/media/test/" + gResource,
|
||||
result: "error",
|
||||
description: "Won't load from subdomain",
|
||||
}
|
||||
|
|
|
@ -6,7 +6,18 @@
|
|||
// really only need one test file per backend here.
|
||||
var gSmallTests = [
|
||||
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
|
||||
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240 },
|
||||
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233 },
|
||||
{ name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
// Used by test_progress to ensure we get the correct progress information
|
||||
// during resource download.
|
||||
var gProgressTests = [
|
||||
{ name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0, size:11069 },
|
||||
{ name:"big.wav", type:"audio/x-wav", duration:9.0, size:102444 },
|
||||
{ name:"seek.ogv", type:"video/ogg", duration:3.966, size:285310 },
|
||||
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.233, size:28942 },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
|
@ -23,6 +34,13 @@ var gReplayTests = gSmallTests.concat([
|
|||
{ name:"bug533822.ogg", type:"audio/ogg" },
|
||||
]);
|
||||
|
||||
// Used by test_paused_after_ended. Need one test file per decoder backend, plus
|
||||
// anything for testing bugs that occur when replying a played file.
|
||||
var gPausedAfterEndedTests = gSmallTests.concat([
|
||||
{ name:"r11025_u8_c1.wav", type:"audio/x-wav", duration:1.0 },
|
||||
{ name:"small-shot.ogg", type:"video/ogg", duration:0.276 }
|
||||
]);
|
||||
|
||||
// These are files that we want to make sure we can play through. We can
|
||||
// also check metadata. Put files of the same type together in this list so if
|
||||
// something crashes we have some idea of which backend is responsible.
|
||||
|
@ -38,18 +56,18 @@ var gPlayTests = [
|
|||
{ name:"r16000_u8_c1_list.wav", type:"audio/x-wav", duration:4.2 },
|
||||
|
||||
// Ogg stream without eof marker
|
||||
{ name:"bug461281.ogg", type:"application/ogg" },
|
||||
{ name:"bug461281.ogg", type:"application/ogg", duration:2.208 },
|
||||
|
||||
// oggz-chop stream
|
||||
{ name:"bug482461.ogv", type:"video/ogg", duration:4.34 },
|
||||
// With first frame a "duplicate" (empty) frame.
|
||||
{ name:"bug500311.ogv", type:"video/ogg", duration:1.96 },
|
||||
// Small audio file
|
||||
{ name:"small-shot.ogg", type:"video/ogg" },
|
||||
{ name:"small-shot.ogg", type:"video/ogg", duration:0.276 },
|
||||
// More audio in file than video.
|
||||
{ name:"short-video.ogv", type:"video/ogg", duration:1.081 },
|
||||
// First Theora data packet is zero bytes.
|
||||
{ name:"bug504613.ogv", type:"video/ogg" },
|
||||
{ name:"bug504613.ogv", type:"video/ogg", duration:Number.NaN },
|
||||
// Multiple audio streams.
|
||||
{ name:"bug516323.ogv", type:"video/ogg", duration:4.208 },
|
||||
|
||||
|
@ -70,17 +88,77 @@ var gPlayTests = [
|
|||
{ name:"chain.ogv", type:"video/ogg", duration:Number.NaN },
|
||||
{ name:"bug523816.ogv", type:"video/ogg", duration:0.533 },
|
||||
{ name:"bug495129.ogv", type:"video/ogg", duration:2.41 },
|
||||
{ name:"bug498380.ogv", type:"video/ogg" },
|
||||
|
||||
{ name:"bug498380.ogv", type:"video/ogg", duration:0.533 },
|
||||
{ name:"bug495794.ogg", type:"audio/ogg", duration:0.3 },
|
||||
{ name:"bug557094.ogv", type:"video/ogg", duration:0.24 },
|
||||
{ name:"audio-overhang.ogg", type:"audio/ogg", duration:2.3 },
|
||||
{ name:"video-overhang.ogg", type:"audio/ogg", duration:3.966 },
|
||||
|
||||
// Test playback/metadata work after a redirect
|
||||
{ name:"redirect.sjs?http://mochi.test:8888/tests/content/media/test/320x240.ogv",
|
||||
{ name:"redirect.sjs?domain=mochi.test:8888&file=320x240.ogv",
|
||||
type:"video/ogg", duration:0.233 },
|
||||
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
{ name:"bogus.duh", type:"bogus/duh", duration:Number.NaN }
|
||||
|
||||
];
|
||||
|
||||
// Converts a path/filename to a file:// URI which we can load from disk.
|
||||
// Optionally checks whether the file actually exists on disk at the location
|
||||
// we've specified.
|
||||
function fileUriToSrc(path, mustExist) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cr = Components.results;
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
var f = dirSvc.get("CurWorkD", Ci.nsILocalFile);
|
||||
var split = path.split("/");
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
f.append(split[i]);
|
||||
}
|
||||
if (mustExist && !f.exists()) {
|
||||
ok(false, "We expected '" + path + "' to exist, but it doesn't!");
|
||||
}
|
||||
return f.path;
|
||||
}
|
||||
|
||||
// These are URIs to files that we use to check that we don't leak any state
|
||||
// or other information such that script can determine stuff about a user's
|
||||
// environment. Used by test_info_leak.
|
||||
var gInfoLeakTests = [
|
||||
{
|
||||
type: 'video/ogg',
|
||||
src: fileUriToSrc("tests/content/media/test/320x240.ogv", true),
|
||||
},{
|
||||
type: 'video/ogg',
|
||||
src: fileUriToSrc("tests/content/media/test/404.ogv", false),
|
||||
}, {
|
||||
type: 'audio/x-wav',
|
||||
src: fileUriToSrc("tests/content/media/test/r11025_s16_c1.wav", true),
|
||||
}, {
|
||||
type: 'audio/x-wav',
|
||||
src: fileUriToSrc("tests/content/media/test/404.wav", false),
|
||||
}, {
|
||||
type: 'audio/ogg',
|
||||
src: fileUriToSrc("tests/content/media/test/bug461281.ogg", true),
|
||||
}, {
|
||||
type: 'audio/ogg',
|
||||
src: fileUriToSrc("tests/content/media/test/404.ogg", false),
|
||||
}, {
|
||||
type: 'video/ogg',
|
||||
src: 'http://localhost/404.ogv',
|
||||
}, {
|
||||
type: 'audio/x-wav',
|
||||
src: 'http://localhost/404.wav',
|
||||
}, {
|
||||
type: 'video/ogg',
|
||||
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
||||
}, {
|
||||
type: 'audio/ogg',
|
||||
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
||||
}
|
||||
];
|
||||
|
||||
// These are files that must fire an error during load or playback, and do not
|
||||
|
@ -113,6 +191,16 @@ var gAudioTests = [
|
|||
{ name:"bogus.duh", type:"bogus/duh", duration:123 }
|
||||
];
|
||||
|
||||
// These files ensure our hanlding of 404 errors is consistent across the
|
||||
// various backends.
|
||||
var g404Tests = [
|
||||
{ name:"404.wav", type:"audio/x-wav" },
|
||||
{ name:"404.ogv", type:"video/ogg" },
|
||||
{ name:"404.oga", type:"audio/ogg" },
|
||||
{ name:"404.webm", type:"video/webm" },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
// These are files suitable for testing various decoder failures that are
|
||||
// expected to fire MEDIA_ERR_DECODE. Used by test_decode_error, which expects
|
||||
// an error and emptied event, and no loadedmetadata or ended event.
|
||||
|
@ -136,6 +224,29 @@ function checkMetadata(msg, e, test) {
|
|||
}
|
||||
if (test.duration) {
|
||||
ok(Math.abs(e.duration - test.duration) < 0.1,
|
||||
msg + " duration should be around " + test.duration);
|
||||
msg + " duration (" + e.duration + ") should be around " + test.duration);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if all members of array 'v' have their _finished field set to true.
|
||||
function AllFinished(v) {
|
||||
if (v.length == 0) {
|
||||
return false;
|
||||
}
|
||||
for (var i=0; i<v.length; ++i) {
|
||||
if (!v[i]._finished) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the first test from candidates array which we can play with the
|
||||
// installed video backends.
|
||||
function getPlayableVideo(candidates) {
|
||||
var v = document.createElement("video");
|
||||
var resources = candidates.filter(function(x){return /^video/.test(x.type) && v.canPlayType(x.type);});
|
||||
if (resources.length > 0)
|
||||
return resources[0];
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
// Return file content for the first request with a given key.
|
||||
// All subsequent requests return a redirect to a different-origin resource.
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
response.setStatusLine(request.httpVersion, 301, "Moved Permanently");
|
||||
response.setHeader("Location", request.queryString, false);
|
||||
var params = request.queryString.split('&');
|
||||
var domain = null;
|
||||
var file = null;
|
||||
var allowed = false;
|
||||
|
||||
for (var i=0; i<params.length; i++) {
|
||||
var kv = params[i].split('=');
|
||||
if (kv.length == 1 && kv[0] == 'allowed') {
|
||||
allowed = true;
|
||||
} else if (kv.length == 2 && kv[0] == 'file') {
|
||||
file = kv[1];
|
||||
} else if (kv.length == 2 && kv[0] == 'domain') {
|
||||
domain = kv[1];
|
||||
}
|
||||
}
|
||||
|
||||
response.setStatusLine(request.httpVersion, 303, "See Other");
|
||||
response.setHeader("Location", "http://" + domain + "/tests/content/media/test/" + (allowed ? "allowed.sjs?" : "") + file);
|
||||
response.setHeader("Content-Type", "text/html");
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
function test_seek11(v, seekTime, is, ok, finish) {
|
||||
|
||||
// Test for bug 476973, multiple seeks to the same position shouldn't cause problems.
|
||||
|
||||
var seekedNonZero = false;
|
||||
var completed = false;
|
||||
var target = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
target = v.duration / 2;
|
||||
v.currentTime = target;
|
||||
v.currentTime = target;
|
||||
return false;
|
||||
}
|
||||
|
||||
function startSeeking() {
|
||||
if (!seekedNonZero) {
|
||||
v.currentTime = target;
|
||||
}
|
||||
}
|
||||
|
||||
function seekEnded() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
if (v.currentTime > 0) {
|
||||
ok(v.currentTime > target - 0.1 && v.currentTime < target + 0.1,
|
||||
"Seek to wrong destination " + v.currentTime);
|
||||
seekedNonZero = true;
|
||||
v.currentTime = 0.0;
|
||||
} else {
|
||||
ok(seekedNonZero, "Successfully seeked to nonzero");
|
||||
ok(true, "Seek back to zero was successful");
|
||||
completed = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
v.addEventListener("loadedmetadata", startTest, false);
|
||||
v.addEventListener("seeking", startSeeking, false);
|
||||
v.addEventListener("seeked", seekEnded, false);
|
||||
|
||||
}
|
|
@ -9,53 +9,67 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=448534
|
|||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=448535">Mozilla Bug 448534</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var played = false;
|
||||
var completed = false;
|
||||
|
||||
function loaded() {
|
||||
if (completed)
|
||||
var videos = [];
|
||||
|
||||
function loaded(event) {
|
||||
var v = event.target;
|
||||
if (v._finished)
|
||||
return false;
|
||||
|
||||
v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function started() {
|
||||
if (completed)
|
||||
function started(event) {
|
||||
var v = event.target;
|
||||
if (v._finished)
|
||||
return false;
|
||||
ok(v, "'v' global should be initialized");
|
||||
ok(!v.paused, "Video should not be paused while playing");
|
||||
v.parentNode.removeChild(v);
|
||||
played = true;
|
||||
v._played = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopped() {
|
||||
if (completed)
|
||||
function stopped(event) {
|
||||
var v = event.target;
|
||||
if (v._finished)
|
||||
return false;
|
||||
|
||||
completed = true;
|
||||
ok(v, "'v' global should be initialized");
|
||||
v._finished = true;
|
||||
ok(v.paused, "Video should be paused after removing from the Document");
|
||||
SimpleTest.finish();
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var v = document.createElement('video');
|
||||
var test = gSmallTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._played = false;
|
||||
v._finished = false;
|
||||
v.addEventListener("loadedmetadata", loaded, false);
|
||||
v.addEventListener("play", started, false);
|
||||
v.addEventListener("pause", stopped, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<!-- Ogg video obtained from Theora test suite: http://v2v.cc/~j/theora_testsuite/ -->
|
||||
<video id='v'
|
||||
src='320x240.ogv'
|
||||
onloadedmetadata='return loaded();'
|
||||
onplay='return started();'
|
||||
onpause='return stopped();'></video>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -10,6 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463162
|
|||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"/>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463162">Mozilla Bug 463162</a>
|
||||
|
@ -43,17 +44,36 @@ function onMetaData(id) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<video id='a1' onerror="onError(event, 'a1');" onloadedmetadata="onMetaData('a1');"><sauce/><source type="bad" src="
|
||||
404"/></video>
|
||||
<video id='a2' onerror="onError(event, 'a2');" onloadedmetadata="onMetaData('a2');"><source/></video>
|
||||
<video id='a3' onerror="onError(event, 'a3');" onloadedmetadata="onMetaData('a3');"><html:source/></video>
|
||||
<video id='a4' onerror="onError(event, 'a4');" onloadedmetadata="onMetaData('a4');"><svg:source/><source type="bad" src="404"/></video>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
<![CDATA[
|
||||
|
||||
function setSource(id, res) {
|
||||
var v = document.getElementById(id);
|
||||
v.firstChild.src = res.name;
|
||||
v.firstChild.type = res.type;
|
||||
}
|
||||
|
||||
var t = getPlayableVideo(gSmallTests);
|
||||
|
||||
setSource('a1', t);
|
||||
setSource('a2', t);
|
||||
setSource('a3', t);
|
||||
setSource('a4', t);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
||||
<audio id='a1' onerror="onError(event, 'a1');" onloadedmetadata="onMetaData('a1');"><sauce type="audio/x-wav" src="r11025_s16_c1.wav"/><source type="bad" src="404"/></audio>
|
||||
<audio id='a2' onerror="onError(event, 'a2');" onloadedmetadata="onMetaData('a2');"><source type="audio/x-wav" src="r11025_s16_c1.wav"/></audio>
|
||||
<audio id='a3' onerror="onError(event, 'a3');" onloadedmetadata="onMetaData('a3');"><html:source type="audio/x-wav" src="r11025_s16_c1.wav"/></audio>
|
||||
<audio id='a4' onerror="onError(event, 'a4');" onloadedmetadata="onMetaData('a4');"><svg:source type="audio/x-wav" src="r11025_s16_c1.wav"/><source type="bad" src="404"/></audio>
|
||||
|
||||
<pre id="test">
|
||||
|
||||
</pre>
|
||||
|
|
|
@ -1,56 +1,78 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: Bug 465498 - Seeking after playback ended</title>
|
||||
<title>Media test: Bug 465498 - Seeking after playback ended</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=465498">Mozilla Bug 465498</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var haveSeeked = false;
|
||||
|
||||
function startTest() {
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
var videos = [];
|
||||
|
||||
function startTest(e) {
|
||||
e.target.play();
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime >= 0.9 && v.currentTime <= 1.1,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
ok(v.ended, "Checking playback has ended");
|
||||
|
||||
function playbackEnded(e) {
|
||||
var v = e.target;
|
||||
if (v._finished)
|
||||
return;
|
||||
ok(v.currentTime >= v.duration - 0.1 && v.currentTime <= v.duration + 0.1,
|
||||
"Checking currentTime at end: " + v.currentTime + " for " + v._name);
|
||||
ok(v.ended, "Checking playback has ended for " + v._name);
|
||||
v.pause();
|
||||
v.currentTime = 0;
|
||||
ok(!v.ended, "Checking ended is no longer true");
|
||||
haveSeeked = true;
|
||||
|
||||
return false;
|
||||
ok(!v.ended, "Checking ended is no longer true for " + v._name);
|
||||
v._seeked = true;
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
if (!haveSeeked)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime == 0, "Checking currentTime after seek: " + v.currentTime);
|
||||
ok(!v.ended, "Checking ended is false");
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
function seekEnded(e) {
|
||||
var v = e.target;
|
||||
if (v._finished)
|
||||
return;
|
||||
ok(v.currentTime == 0, "Checking currentTime after seek: " +
|
||||
v.currentTime + " for " + v._name);
|
||||
ok(!v.ended, "Checking ended is false for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
var type = /^video/.test(test.type) ? "video" : "audio";
|
||||
var v = document.createElement(type);
|
||||
var test = gSmallTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v._name = test.name;
|
||||
|
||||
var s = document.createElement("source");
|
||||
s.type = test.type;
|
||||
s.src = test.name;
|
||||
v.appendChild(s);
|
||||
|
||||
v._seeked = false;
|
||||
v._finished = false;
|
||||
v.addEventListener("loadedmetadata", startTest, false);
|
||||
v.addEventListener("ended", playbackEnded, false);
|
||||
v.addEventListener("seeked", seekEnded, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
onloadedmetadata='return startTest();'
|
||||
onended='return playbackEnded();'
|
||||
onseeked='return endTest();'>
|
||||
<source type='audio/x-wav' src='r11025_s16_c1.wav'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=468190
|
||||
-->
|
||||
<head>
|
||||
<title>Test for bug 468190</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468190">Mozilla Bug 468190</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if video can be replayed after ended.
|
||||
var completed = false;
|
||||
var playingCount = 0;
|
||||
var endCount = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackStarted() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
playingCount++;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
endCount++;
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime >= 3.9 && v.currentTime <= 4.0,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
ok(v.ended, "Checking playback has ended");
|
||||
ok(playingCount > 0, "Expect at least one playing event");
|
||||
playingCount = 0;
|
||||
if (endCount < 2) {
|
||||
v.currentTime = 0;
|
||||
ok(v.seeking, "Checking that seeking is now true");
|
||||
ok(!v.ended, "Checking ended is no longer set as seeking has begun");
|
||||
v.play();
|
||||
} else {
|
||||
ok(endCount == 2, "Check playback after ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'
|
||||
onplaying='return playbackStarted();'
|
||||
onended='return playbackEnded();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,69 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=468190
|
||||
-->
|
||||
<head>
|
||||
<title>Test for bug 468190</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468190">Mozilla Bug 468190</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if video can be replayed after ended.
|
||||
var completed = false;
|
||||
var playingCount = 0;
|
||||
var endCount = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackStarted() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
playingCount++;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
endCount++;
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime >= 0.9 && v.currentTime <= 1.1,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
ok(v.ended, "Checking playback has ended");
|
||||
ok(playingCount > 0, "Expect at least one playing event");
|
||||
playingCount = 0;
|
||||
if (endCount < 2) {
|
||||
v.currentTime = 0;
|
||||
ok(v.seeking, "Checking that seeking is now true");
|
||||
ok(!v.ended, "Checking ended is no longer set as seeking has begun");
|
||||
v.play();
|
||||
} else {
|
||||
ok(endCount == 2, "Check playback after ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
onloadedmetadata='return startTest();'
|
||||
onplaying='return playbackStarted();'
|
||||
onended='return playbackEnded();'><source src='r11025_s16_c1.wav' type='audio/x-wav'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,60 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=476973
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Bug 476973 - multiple seeks to the same position shouldn't cause problems</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=476973">Mozilla Bug 476973</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var completed = false;
|
||||
var seekedNonZero = false;
|
||||
|
||||
/* This test checkes that two seeks to the same position don't break things.
|
||||
So we trigger two seeks to 1.0, trigger another when seeking starts,
|
||||
and when we've seeked successfully to 1.0, we seek back to zero and expect
|
||||
that to eventually happen.
|
||||
*/
|
||||
function start() {
|
||||
v = document.getElementById('v');
|
||||
v.currentTime = 1.0;
|
||||
v.currentTime = 1.0;
|
||||
}
|
||||
|
||||
function startSeeking() {
|
||||
if (!seekedNonZero) {
|
||||
v.currentTime = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
function seeked() {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
if (v.currentTime > 0) {
|
||||
ok(v.currentTime > 0.9 && v.currentTime < 1.1, "Seek to wrong destination " + v.currentTime);
|
||||
seekedNonZero = true;
|
||||
v.currentTime = 0.0;
|
||||
} else {
|
||||
ok(seekedNonZero, "Successfully seeked to nonzero");
|
||||
ok(true, "Seek back to zero was successful");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v' src='seek.ogv' onseeked='seeked()' onseeking='startSeeking()'
|
||||
onloadeddata='start()'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=486646
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Test for Bug 486646</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="use_large_cache.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
function loaded() {
|
||||
var vid = document.getElementById("vid");
|
||||
ok(vid.readyState >= vid.HAVE_CURRENT_DATA, "readyState must be >= HAVE_CURRENT_DATA");
|
||||
|
||||
var ctx = document.getElementById("can").getContext("2d");
|
||||
try {
|
||||
ctx.drawImage(vid, 0, 0);
|
||||
ok(true, "No exception while drawing to canvas from video");
|
||||
} catch (ex) {
|
||||
ok(false, "No exception while drawing to canvas from video");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<!-- Ogg video obtained from Theora test suite: http://v2v.cc/~j/theora_testsuite/ -->
|
||||
<video id="vid"
|
||||
src="320x240.ogv"
|
||||
style="display: none;"
|
||||
autoplay
|
||||
onerror="event.stopPropagation();"
|
||||
onended="loaded();">
|
||||
</video>
|
||||
<canvas id="can"
|
||||
width="320"
|
||||
height="240">
|
||||
</canvas>
|
||||
</body>
|
||||
</html>
|
|
@ -10,36 +10,65 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=493187
|
|||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="use_large_cache.js"></script>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=493187">Mozilla Bug 493187</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var startedSeek = false;
|
||||
var completed = false;
|
||||
|
||||
function start() {
|
||||
v = document.getElementById('v');
|
||||
v.currentTime = 1.0;
|
||||
var videos = [];
|
||||
|
||||
function start(e) {
|
||||
e.target.currentTime = e.target.duration / 4;
|
||||
}
|
||||
|
||||
function startSeeking() {
|
||||
startedSeek = true;
|
||||
function startSeeking(e) {
|
||||
e.target._seeked = true;
|
||||
}
|
||||
|
||||
function canPlayThrough() {
|
||||
if (startedSeek && !completed) {
|
||||
ok(true, "Got canplaythrough after seek");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
function canPlayThrough(e) {
|
||||
var v = e.target;
|
||||
if (v._seeked && !v._finished) {
|
||||
ok(true, "Got canplaythrough after seek for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
for (var i=0; i<gSeekTests.length; ++i) {
|
||||
var test = gSeekTests[i];
|
||||
|
||||
// TODO: Bug 568402, there's a bug in the WAV backend where we sometimes
|
||||
// don't send canplaythrough events after seeking. Once that is fixed,
|
||||
// we should remove this guard below so that we run this test for audio.
|
||||
var isVideo = /^video/.test(test.type) ? true : false;
|
||||
if (!isVideo)
|
||||
continue;
|
||||
|
||||
var v = document.createElement('video');
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._seeked = false;
|
||||
v._finished = false;
|
||||
v.autobuffer = true;
|
||||
v.addEventListener("loadedmetadata", start, false);
|
||||
v.addEventListener("canplaythrough", canPlayThrough, false);
|
||||
v.addEventListener("seeking", startSeeking, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v' src='seek.ogv' oncanplaythrough='canPlayThrough()' onseeking='startSeeking()'
|
||||
autobuffer onloadedmetadata='start()'></video>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -9,63 +9,87 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=495145
|
|||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var completed = false;
|
||||
var testFinishedCount = 0;
|
||||
var ended1Count = 0;
|
||||
|
||||
function finishTest() {
|
||||
++testFinishedCount;
|
||||
if (testFinishedCount == 2) {
|
||||
completed = true;
|
||||
var videos = [];
|
||||
|
||||
function start(e) {
|
||||
e.target.play();
|
||||
}
|
||||
|
||||
function ended1(e) {
|
||||
var v = e.target;
|
||||
if (v._finished)
|
||||
return;
|
||||
|
||||
++v._endCount;
|
||||
if (v._endCount == 2) {
|
||||
ok(true, "Playing after pause while ended works for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
v.pause();
|
||||
v.play();
|
||||
}
|
||||
|
||||
function ended2(e) {
|
||||
var v = e.target;
|
||||
if (v._finished)
|
||||
return;
|
||||
|
||||
v.pause();
|
||||
v.currentTime = 0;
|
||||
}
|
||||
|
||||
function seeked2(e) {
|
||||
var v = e.target;
|
||||
if (v._finished)
|
||||
return;
|
||||
|
||||
ok(v.paused, "Paused after seek after pause while ended for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function start(event) {
|
||||
event.target.play();
|
||||
function createVideo(test, x) {
|
||||
var v = document.createElement('video');
|
||||
if (!v.canPlayType(test.type))
|
||||
return null;
|
||||
v.src = test.name;
|
||||
v._name = test.name + "#" + x;
|
||||
v._endCount = 0;
|
||||
v._finished = false;
|
||||
v.addEventListener("loadedmetadata", start, false);
|
||||
v.addEventListener("ended", x == 1 ? ended1 : ended2, false);
|
||||
if (x == 2)
|
||||
v.addEventListener("seeked", seeked2, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
function ended1(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
++ended1Count;
|
||||
if (ended1Count == 2) {
|
||||
ok(true, "Playing after pause while ended works");
|
||||
finishTest();
|
||||
return;
|
||||
}
|
||||
|
||||
event.target.pause();
|
||||
event.target.play();
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
createVideo(test, 1);
|
||||
createVideo(test, 2);
|
||||
}
|
||||
|
||||
function ended2(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
event.target.pause();
|
||||
event.target.currentTime = 0;
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
function seeked2(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
ok(event.target.paused, "Paused after seek after pause while ended");
|
||||
finishTest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video src='320x240.ogv' onloadeddata='start(event)' onended='ended1(event)'></video>
|
||||
<video src='320x240.ogv' onloadeddata='start(event)' onended='ended2(event)' onseeked="seeked2(event)"></video>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=495145
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Bug 495145 - pausing while ended shouldn't cause problems</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var completed = false;
|
||||
var testFinishedCount = 0;
|
||||
var ended1Count = 0;
|
||||
|
||||
function finishTest() {
|
||||
++testFinishedCount;
|
||||
if (testFinishedCount == 2) {
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function start(event) {
|
||||
event.target.play();
|
||||
}
|
||||
|
||||
function ended1(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
++ended1Count;
|
||||
if (ended1Count == 2) {
|
||||
ok(true, "Playing after pause while ended works");
|
||||
finishTest();
|
||||
return;
|
||||
}
|
||||
|
||||
event.target.pause();
|
||||
event.target.play();
|
||||
}
|
||||
|
||||
function ended2(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
event.target.pause();
|
||||
event.target.currentTime = 0;
|
||||
}
|
||||
|
||||
function seeked2(event) {
|
||||
if (completed)
|
||||
return;
|
||||
|
||||
ok(event.target.paused, "Paused after seek after pause while ended");
|
||||
finishTest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio src='r11025_u8_c1.wav' onloadeddata='start(event)' onended='ended1(event)'></audio>
|
||||
<audio src='r11025_u8_c1.wav' onloadeddata='start(event)' onended='ended2(event)' onseeked="seeked2(event)"></audio>
|
||||
</body>
|
||||
</html>
|
|
@ -1,34 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=495319
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Bug 495319 - playing back small audio files should fire timeupdate</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495319">Mozilla Bug 495319</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v;
|
||||
var timeUpdateCount = 0;
|
||||
|
||||
function timeUpdate(event) {
|
||||
++timeUpdateCount;
|
||||
}
|
||||
|
||||
function done(event) {
|
||||
ok(timeUpdateCount > 0, "Should see at least one timeupdate: " + event.target.currentTime);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio src='small-shot.ogg' ontimeupdate="timeUpdate(event)" onended='done(event)' controls autoplay></video>
|
||||
</body>
|
||||
</html>
|
|
@ -9,6 +9,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479863
|
|||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="use_large_cache.js"></script>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479863">Mozilla Bug 479863</a>
|
||||
|
@ -22,39 +23,31 @@ window.onload = function() {
|
|||
ok(true, "loaded metadata for all videos");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- With normal per-domain connection limits and a naive implementation, we
|
||||
/* With normal per-domain connection limits and a naive implementation, we
|
||||
won't ever be able to load all these videos because the first 15 (or whatever)
|
||||
will each take up one HTTP connection (which will be suspended) and then
|
||||
the others will be blocked by the per-domain HTTP connection limit. We
|
||||
pass this test by closing the connection for non-buffered videos after
|
||||
we've got the first frame. -->
|
||||
we've got the first frame.
|
||||
*/
|
||||
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
<video src="seek.ogv"></video>
|
||||
|
||||
var resource = getPlayableVideo(gSeekTests);
|
||||
if (resource != null) {
|
||||
for (var i=0; i<20; ++i) {
|
||||
var v = document.createElement("video");
|
||||
v.src = resource.name;
|
||||
document.body.appendChild(v);
|
||||
}
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
</script>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -54,7 +54,11 @@ gDecodeErrorTests.forEach(function (test, index) {
|
|||
v1.load();
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
if (testsWaiting > 0) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -8,11 +8,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
|
|||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script>
|
||||
|
||||
var gRegisteredElements = [];
|
||||
var gLog = false;
|
||||
var gTestWindow;
|
||||
var testWindows = [];
|
||||
|
||||
function log(msg) {
|
||||
if (gLog) {
|
||||
|
@ -30,18 +31,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
|
|||
|
||||
for (var i = 0; i < gRegisteredElements.length; ++i) {
|
||||
var v = gRegisteredElements[i];
|
||||
ok(v.readyState >= v.HAVE_CURRENT_DATA, "Video " + v.id + " is not ready before onload fired");
|
||||
ok(v.readyState >= v.HAVE_CURRENT_DATA,
|
||||
v._name + ":" + v.id + " is not ready before onload fired (" + v.readyState + ")");
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
gTestWindow.close();
|
||||
for (i=0; i<testWindows.length; ++i) {
|
||||
testWindows[i].close();
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(loaded);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -52,61 +56,71 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
|
|||
</div>
|
||||
|
||||
|
||||
<video src="320x240.ogv" id="v0"></video>
|
||||
|
||||
|
||||
<div id="log" style="font-size: small;"></div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 479711 **/
|
||||
|
||||
register(document.getElementById('v0'));
|
||||
|
||||
function createVideo(id) {
|
||||
function createVideo(name, type, id) {
|
||||
var v = document.createElement("video");
|
||||
v.id = id;
|
||||
if (gLog) {
|
||||
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata', 'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended', 'ratechange', 'durationchange', 'volumechange' ];
|
||||
function listener(evt) {
|
||||
log('event ' + evt.target.id + " " + evt.type);
|
||||
}
|
||||
|
||||
for (var i=0; i<gEventTypes.length; i++) {
|
||||
var t = gEventTypes[i];
|
||||
v.addEventListener(t, listener, false);
|
||||
}
|
||||
if (!v.canPlayType(type)) {
|
||||
return null;
|
||||
}
|
||||
v.src = "http://mochi.test:8888/tests/content/media/test/320x240.ogv";
|
||||
v.src = name;
|
||||
v._name = name;
|
||||
v.id = id;
|
||||
register(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
// Load, add, then remove.
|
||||
var v1 = createVideo("v1");
|
||||
v1.load();
|
||||
document.body.appendChild(v1);
|
||||
v1.parentNode.removeChild(v1);
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
|
||||
// Load and add.
|
||||
var v2 = createVideo("v2");
|
||||
v2.load();
|
||||
document.body.appendChild(v2);
|
||||
// Straightforward add, causing a load.
|
||||
var v1 = createVideo(test.name, test.type, "1");
|
||||
if (v1 == null) {
|
||||
continue;
|
||||
}
|
||||
document.body.appendChild(v1);
|
||||
|
||||
// Load outside of doc.
|
||||
var v3 = createVideo("v3");
|
||||
v3.load();
|
||||
// Load, add, then remove.
|
||||
var v1 = createVideo(test.name, test.type, "1");
|
||||
if (!v1) {
|
||||
continue;
|
||||
}
|
||||
v1.load();
|
||||
document.body.appendChild(v1);
|
||||
v1.parentNode.removeChild(v1);
|
||||
|
||||
// Load and move to another document.
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var v4 = createVideo("v4");
|
||||
v4.load(); // load started while in this document, this doc's load will block until
|
||||
// the video's finished loading (in the other document).
|
||||
// Opening a new window to do this is a bit annoying, but if we use an iframe here,
|
||||
// delaying of the iframe's load event might interfere with the firing of our load event
|
||||
// in some confusing way. So it's simpler just to open another window.
|
||||
gTestWindow = window.open("", "testWindow", "width=400,height=400");
|
||||
gTestWindow.document.body.appendChild(v4);
|
||||
// Load and add.
|
||||
var v2 = createVideo(test.name, test.type, "2");
|
||||
v2.load();
|
||||
document.body.appendChild(v2);
|
||||
|
||||
// Load outside of doc.
|
||||
var v3 = createVideo(test.name, test.type, "3");
|
||||
v3.load();
|
||||
|
||||
// Load and move to another document.
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var v4 = createVideo(test.name, test.type, "4");
|
||||
v4.load(); // load started while in this document, this doc's load will block until
|
||||
// the video's finished loading (in the other document).
|
||||
// Opening a new window to do this is a bit annoying, but if we use an iframe here,
|
||||
// delaying of the iframe's load event might interfere with the firing of our load event
|
||||
// in some confusing way. So it's simpler just to open another window.
|
||||
var w = window.open("", "testWindow"+i, "width=400,height=400");
|
||||
w.document.body.appendChild(v4);
|
||||
testWindows.push(w);
|
||||
|
||||
}
|
||||
|
||||
if (gRegisteredElements.length > 0) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: seek test 1</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test that getting the duration from a file works
|
||||
var completed = false;
|
||||
var timeout;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
var v = document.getElementById('v');
|
||||
is(Math.round(v.duration*1000), 3999, "Check duration of video: " + v.duration);
|
||||
completed = true;
|
||||
clearTimeout(timeout);
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
timeout = setTimeout(function () {
|
||||
ok(false, "Test timed out");
|
||||
SimpleTest.finish();
|
||||
}, 60000);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: ended</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if the ended event works correctly.
|
||||
var v;
|
||||
var endPassed = false;
|
||||
var completed = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
completed = true;
|
||||
ok(v.currentTime >= 3.9 && v.currentTime <= 4.0,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
ok(v.ended, "Checking playback has ended");
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'
|
||||
onended='return playbackEnded();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,63 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: ended and replaying</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if video can be replayed after ended.
|
||||
var completed = false;
|
||||
var playingCount = 0;
|
||||
var endCount = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackStarted() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
playingCount++;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
endCount++;
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime >= 3.9 && v.currentTime <= 4.0,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
ok(v.ended, "Checking playback has ended");
|
||||
ok(playingCount > 0, "Expect at least one playing event");
|
||||
playingCount = 0;
|
||||
if (endCount < 2) {
|
||||
v.play();
|
||||
} else {
|
||||
ok(endCount == 2, "Check playback after ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'
|
||||
onplaying='return playbackStarted();'
|
||||
onended='return playbackEnded();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=476731
|
|||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=476731">Mozilla Bug </a>
|
||||
|
@ -23,58 +24,71 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=476731
|
|||
|
||||
/** Test for Bug **/
|
||||
|
||||
var gLoadedData = new Object();
|
||||
var gLoadStart = new Object();
|
||||
var gLoadError = new Object();
|
||||
var videos = [];
|
||||
|
||||
gLoadedData['v'] = false;
|
||||
gLoadedData['a'] = false;
|
||||
function FinishedLoads() {
|
||||
if (videos.length == 0)
|
||||
return false;
|
||||
for (var i=0; i<videos.length; ++i) {
|
||||
if (videos[i]._loadedData) {
|
||||
// A video loadeddata, it should have 404'd. Signal the end of the test
|
||||
// so the error will be reported.
|
||||
return true;
|
||||
}
|
||||
if (!videos[i]._loadError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
gLoadStart['v'] = false;
|
||||
gLoadStart['a'] = false;
|
||||
|
||||
gLoadError['v'] = false;
|
||||
gLoadError['a'] = false;
|
||||
|
||||
function loadError(evt, id) {
|
||||
function loadError(evt) {
|
||||
// Prevent mochitest's onerror handler catching the 'error' event on bubble.
|
||||
evt.stopPropagation();
|
||||
is(gLoadError[id], false, "Shouldn't have more than one error for each media element");
|
||||
gLoadError[id] = true;
|
||||
is(gLoadStart[id], true, "Should have started load");
|
||||
is(gLoadedData[id], false, "Shouldn't have finished load.");
|
||||
if (gLoadError['a'] && gLoadError['v'])
|
||||
var v = evt.target;
|
||||
is(v._loadError, false, "Shouldn't receive multiple error events for " + v.src);
|
||||
v._loadError = true;
|
||||
is(v._loadStart, true, "Receive loadstart for " + v.src);
|
||||
is(v._loadedData, false, "Shouldn't receive loadeddata for " + v.src);
|
||||
if (FinishedLoads(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function loadedData(evt, id) {
|
||||
gLoadedData[id] = true;
|
||||
function loadedData(evt) {
|
||||
evt.target._loadedData = true;
|
||||
}
|
||||
|
||||
function loadStart(evt, id) {
|
||||
gLoadStart[id] = true;
|
||||
function loadStart(evt) {
|
||||
evt.target._loadStart = true;
|
||||
}
|
||||
|
||||
// Create all video objects.
|
||||
for (var i=0; i<g404Tests.length; ++i) {
|
||||
var v = document.createElement("video");
|
||||
var test = g404Tests[i];
|
||||
if (!v.canPlayType(test.type)) {
|
||||
continue;
|
||||
}
|
||||
v.src = test.name;
|
||||
v._loadedData = false;
|
||||
v._loadStart = false;
|
||||
v._loadError = false;
|
||||
v.addEventListener("error", loadError, false);
|
||||
v.addEventListener("loadstart", loadStart, false);
|
||||
v.addEventListener("loadedddata", loadedData, false);
|
||||
document.body.appendChild(v); // Will start load.
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
<video id="v"
|
||||
onerror="loadError(event, 'v');"
|
||||
onloadstart="loadStart(event, 'v');"
|
||||
onloadeddata="loadedData(event, 'v');"
|
||||
src="404.ogg">
|
||||
</video>
|
||||
|
||||
|
||||
<audio id="a"
|
||||
onerror="loadError(event, 'a');"
|
||||
onloadstart="loadStart(event, 'a');"
|
||||
onloadeddata="loadedData(event, 'a');"
|
||||
src="404.wav">
|
||||
</audio>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478957
|
|||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478957">Mozilla Bug 478957</a>
|
||||
|
@ -25,60 +26,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478957
|
|||
|
||||
// Tests whether we leak events and state change info when loading stuff from local files from a webserver.
|
||||
|
||||
function fileUriToSrc(path, mustExist) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cr = Components.results;
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
var f = dirSvc.get("CurWorkD", Ci.nsILocalFile);
|
||||
var split = path.split("/");
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
f.append(split[i]);
|
||||
}
|
||||
is(f.exists(), mustExist, 'File ' + path + ' existence mismatch');
|
||||
return f.path;
|
||||
}
|
||||
|
||||
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata', 'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended', 'ratechange', 'durationchange', 'volumechange' ];
|
||||
|
||||
var gMedia = null;
|
||||
|
||||
var gTests = [
|
||||
{
|
||||
tag: 'video',
|
||||
src: fileUriToSrc("tests/content/media/test/320x240.ogv", true),
|
||||
},{
|
||||
tag: 'video',
|
||||
src: fileUriToSrc("tests/content/media/test/404.ogv", false),
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: fileUriToSrc("tests/content/media/test/r11025_s16_c1.wav", true),
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: fileUriToSrc("tests/content/media/test/404.wav", false),
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: fileUriToSrc("tests/content/media/test/bug461281.ogg", true),
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: fileUriToSrc("tests/content/media/test/404.ogg", false),
|
||||
}, {
|
||||
tag: 'video',
|
||||
src: 'http://localhost/404.ogv',
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: 'http://localhost/404.wav',
|
||||
}, {
|
||||
tag: 'video',
|
||||
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
||||
}, {
|
||||
tag: 'audio',
|
||||
src: 'http://example.com/tests/content/media/test/test_info_leak.html'
|
||||
}
|
||||
];
|
||||
|
||||
var gExpectedEvents = ['loadstart', 'error'];
|
||||
var gTestNum = 0;
|
||||
var gEventNum = 0;
|
||||
|
@ -91,7 +42,7 @@ function log(msg) {
|
|||
}
|
||||
|
||||
function nextTest() {
|
||||
if (gTestNum == gTests.length) {
|
||||
if (gTestNum == gInfoLeakTests.length) {
|
||||
gFinished = true;
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
|
@ -100,13 +51,13 @@ function nextTest() {
|
|||
gMedia.parentNode.removeChild(gMedia);
|
||||
gMedia = null;
|
||||
}
|
||||
var t = gTests[gTestNum];
|
||||
var t = gInfoLeakTests[gTestNum];
|
||||
|
||||
log("Testing: " + t.tag + " @ " + t.src);
|
||||
log("Testing: " + t.type + " @ " + t.src);
|
||||
|
||||
gTestNum++;
|
||||
gEventNum = 0;
|
||||
createMedia(t.tag, t.src);
|
||||
createMedia(t.type, t.src);
|
||||
}
|
||||
|
||||
function listener(evt) {
|
||||
|
@ -125,8 +76,14 @@ function listener(evt) {
|
|||
}
|
||||
}
|
||||
|
||||
function createMedia(tag, src) {
|
||||
function createMedia(type, src) {
|
||||
var tag = /^video/.test(type) ? "video" : "audio";
|
||||
gMedia = document.createElement(tag);
|
||||
if (!gMedia.canPlayType(type)) {
|
||||
gMedia = null;
|
||||
setTimeout(nextTest, 0);
|
||||
return;
|
||||
}
|
||||
for (var i=0; i<gEventTypes.length; i++) {
|
||||
gMedia.addEventListener(gEventTypes[i], listener, false);
|
||||
}
|
||||
|
@ -151,24 +108,25 @@ function test_is(a, b, msg) {
|
|||
}
|
||||
|
||||
function checkState() {
|
||||
test_ok(gMedia.networkState <= HTMLMediaElement.NETWORK_LOADING ||
|
||||
gMedia.networkState == HTMLMediaElement.NETWORK_NO_SOURCE,
|
||||
"NetworkState of " + gMedia.networkState + " was leaked.");
|
||||
test_ok(gMedia.readyState == HTMLMediaElement.HAVE_NOTHING,
|
||||
"Ready state of " + gMedia.readyState + " was leaked");
|
||||
test_is(gMedia.seeking, false, "Seeking leaked");
|
||||
test_is(gMedia.currentTime, 0, "Leaked currentTime");
|
||||
test_ok(isNaN(gMedia.duration), "Leaked duration");
|
||||
test_is(gMedia.paused, true, "Paused leaked");
|
||||
test_is(gMedia.ended, false, "Ended leaked");
|
||||
test_is(gMedia.autoplay, false, "Autoplay leaked");
|
||||
test_is(gMedia.controls, false, "Controls leaked");
|
||||
test_is(gMedia.muted, false, "muted leaked");
|
||||
test_ok(gMedia.error==null || gMedia.error.code==HTMLMediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
|
||||
"Error code should not exist or be SRC_NOT_SUPPORTED. gMedia.error=" +
|
||||
(gMedia.error ? gMedia.error.code : "null"));
|
||||
test_is(gMedia.currentSrc, "", "Leaked currentSrc");
|
||||
|
||||
if (gMedia != null) {
|
||||
test_ok(gMedia.networkState <= HTMLMediaElement.NETWORK_LOADING ||
|
||||
gMedia.networkState == HTMLMediaElement.NETWORK_NO_SOURCE,
|
||||
"NetworkState of " + gMedia.networkState + " was leaked.");
|
||||
test_ok(gMedia.readyState == HTMLMediaElement.HAVE_NOTHING,
|
||||
"Ready state of " + gMedia.readyState + " was leaked");
|
||||
test_is(gMedia.seeking, false, "Seeking leaked");
|
||||
test_is(gMedia.currentTime, 0, "Leaked currentTime");
|
||||
test_ok(isNaN(gMedia.duration), "Leaked duration");
|
||||
test_is(gMedia.paused, true, "Paused leaked");
|
||||
test_is(gMedia.ended, false, "Ended leaked");
|
||||
test_is(gMedia.autoplay, false, "Autoplay leaked");
|
||||
test_is(gMedia.controls, false, "Controls leaked");
|
||||
test_is(gMedia.muted, false, "muted leaked");
|
||||
test_ok(gMedia.error==null || gMedia.error.code==HTMLMediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
|
||||
"Error code should not exist or be SRC_NOT_SUPPORTED. gMedia.error=" +
|
||||
(gMedia.error ? gMedia.error.code : "null"));
|
||||
test_is(gMedia.currentSrc, "", "Leaked currentSrc");
|
||||
}
|
||||
if (!gFinished) {
|
||||
setTimeout(checkState, 1);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=465458
|
|||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=465458">Mozilla Bug 465458</a>
|
||||
|
@ -20,29 +21,65 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=465458
|
|||
|
||||
/** Test for Bug 465458 **/
|
||||
|
||||
var gError = false;
|
||||
var videos = [];
|
||||
|
||||
function finish() {
|
||||
is(gError, false, "Shouldn't have thrown an error");
|
||||
SimpleTest.finish();
|
||||
function finish(evt) {
|
||||
is(evt.target._error, false, "Shouldn't have thrown an error - " + evt.target._name);
|
||||
evt.target._finished = true;
|
||||
if (AllFinished(videos)) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function errorHandler(e) {
|
||||
e.stopPropagation();
|
||||
gError = true;
|
||||
finish();
|
||||
function errorHandler(evt) {
|
||||
evt.stopPropagation();
|
||||
evt.target._error = true;
|
||||
finish(evt);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var extenstion = {
|
||||
"audio/wav" : "wav",
|
||||
"audio/x-wav": "wav",
|
||||
"video/ogg" : "ogv",
|
||||
"audio/ogg" : "oga",
|
||||
"video/webm" : "webm"
|
||||
};
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var v = document.createElement('video');
|
||||
var test = gSmallTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v._error = false;
|
||||
v._finished = false;
|
||||
v._name = test.name;
|
||||
|
||||
var s1 = document.createElement("source");
|
||||
s1.type = test.type;
|
||||
s1.src = "404." + extenstion[test.type];
|
||||
v.appendChild(s1);
|
||||
|
||||
var s2 = document.createElement("source");
|
||||
s2.type = test.type;
|
||||
s2.src = test.name;
|
||||
v.appendChild(s2);
|
||||
|
||||
v.addEventListener("error", errorHandler, false);
|
||||
v.addEventListener("loadeddata", finish, false);
|
||||
|
||||
document.body.appendChild(v);
|
||||
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
<video onerror="errorHandler(event)" id="v" onloadeddata="finish();">
|
||||
<source src="404.ogv" type="application/ogg"></source>
|
||||
<source src="320x240.ogv" type="application/ogg"></source>
|
||||
</video>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489415
|
|||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=489415">Mozilla Bug 489415</a>
|
||||
|
@ -23,44 +24,50 @@ SimpleTest.waitForExplicitFinish();
|
|||
var v1 = document.getElementById("v1");
|
||||
var v2 = document.getElementById("v2");
|
||||
|
||||
var count = 0;
|
||||
var resource = getPlayableVideo(gSeekTests);
|
||||
|
||||
function loaded(id) {
|
||||
var c = document.createElement("canvas");
|
||||
var ctx = c.getContext("2d");
|
||||
var v = document.getElementById(id);
|
||||
ctx.drawImage(v, 0, 0);
|
||||
try {
|
||||
c.toDataURL();
|
||||
ok(false, "Failed to throw exception in toDataURL for " + id);
|
||||
} catch (ex) {
|
||||
ok(true, "Threw exception in toDataURL for " + id);
|
||||
}
|
||||
if (++count == 2) {
|
||||
SimpleTest.finish();
|
||||
if (resource != null) {
|
||||
var count = 0;
|
||||
|
||||
function loaded(id) {
|
||||
var c = document.createElement("canvas");
|
||||
var ctx = c.getContext("2d");
|
||||
var v = document.getElementById(id);
|
||||
ctx.drawImage(v, 0, 0);
|
||||
try {
|
||||
c.toDataURL();
|
||||
ok(false, "Failed to throw exception in toDataURL for " + id);
|
||||
} catch (ex) {
|
||||
ok(true, "Threw exception in toDataURL for " + id);
|
||||
}
|
||||
if (++count == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a random key. The first load with that key will return
|
||||
// data, the second and subsequent loads with that key will return a redirect
|
||||
// to a different origin ('localhost:8888' will be redirected to 'example.org',
|
||||
// and 'example.org' will be redirected to 'localhost:8888'). We rely on the
|
||||
// fact that Ogg will do a seek to the end of the resource, triggering a new
|
||||
// load with the same key which will return a same-origin resource.
|
||||
// Loading data from two different origins should be detected by the media
|
||||
// cache and result in a null principal so that the canvas usage above fails.
|
||||
var key = Math.floor(Math.random()*100000000);
|
||||
|
||||
// In v1, try loading from same-origin first and then getting redirected to
|
||||
// another origin.
|
||||
v1.src = "http://mochi.test:8888/tests/content/media/test/dynamic_redirect.sjs?key=v1_" + key + "&res=" + resource.name;
|
||||
v1.load();
|
||||
|
||||
// In v2, try loading cross-origin first and then getting redirected to
|
||||
// our origin.
|
||||
v2.src = "http://example.org/tests/content/media/test/dynamic_redirect.sjs?key=v2_" + key + "&res=" + resource.name;
|
||||
v2.load();
|
||||
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
|
||||
// Generate a random key. The first load with that key will return
|
||||
// data, the second and subsequent loads with that key will return a redirect
|
||||
// to a different origin ('localhost:8888' will be redirected to 'example.org',
|
||||
// and 'example.org' will be redirected to 'localhost:8888'). We rely on the
|
||||
// fact that Ogg will do a seek to the end of the resource, triggering a new
|
||||
// load with the same key which will return a same-origin resource.
|
||||
// Loading data from two different origins should be detected by the media
|
||||
// cache and result in a null principal so that the canvas usage above fails.
|
||||
var key = Math.floor(Math.random()*100000000);
|
||||
|
||||
// In v1, try loading from same-origin first and then getting redirected to
|
||||
// another origin.
|
||||
v1.src = "http://mochi.test:8888/tests/content/media/test/dynamic_redirect.sjs?key=v1_" + key;
|
||||
v1.load();
|
||||
|
||||
// In v2, try loading cross-origin first and then getting redirected to
|
||||
// our origin.
|
||||
v2.src = "http://example.org/tests/content/media/test/dynamic_redirect.sjs?key=v2_" + key;
|
||||
v2.load();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ for (var i=0; i<gAudioTests.length; i++) {
|
|||
|
||||
if (testsStarted != 0) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 467972</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467972">Mozilla Bug 467972</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 467972 **/
|
||||
|
||||
|
||||
var gEnded = false;
|
||||
var gSeekStarted = false;
|
||||
var gSeekEnded = false;
|
||||
var gLoadedDataCount = 0;
|
||||
var gLoadedMetaDataCount = 0;
|
||||
|
||||
function get(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function video() {
|
||||
return get('v');
|
||||
}
|
||||
|
||||
function seekStarted() {
|
||||
gSeekStarted = true;
|
||||
}
|
||||
|
||||
function seekEnded() {
|
||||
gSeekEnded = true;
|
||||
video().play();
|
||||
}
|
||||
|
||||
function loadedData() {
|
||||
gLoadedDataCount++;
|
||||
ok(gLoadedDataCount <= 1, "No more than 1 onloadeddata events");
|
||||
}
|
||||
|
||||
function loadedMetaData() {
|
||||
gLoadedMetaDataCount++;
|
||||
ok(gLoadedMetaDataCount <= 1, "No more than 1 onloadedmetadata events");
|
||||
is(video().videoWidth, 320, "width is available");
|
||||
is(video().videoHeight, 240, "height is available");
|
||||
video().play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (!gEnded) {
|
||||
video().currentTime = 0;
|
||||
gEnded = true;
|
||||
} else {
|
||||
ok(gSeekEnded, "Should have received seekended");
|
||||
ok(gSeekStarted, "Should have received seekstarted");
|
||||
is(gLoadedDataCount, 1, "Should have 1 onloadeddata event");
|
||||
is(gLoadedMetaDataCount, 1, "Should have 1 onloadedmetadata event");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<video id="v"
|
||||
src="320x240.ogv"
|
||||
onloadedmetadata="return loadedMetaData();"
|
||||
onended="playbackEnded();"
|
||||
onloadeddata="return loadedData();"
|
||||
onseeking="seekStarted();"
|
||||
onseeked="seekEnded();"
|
||||
controls></video>
|
||||
</body>
|
||||
</html>
|
|
@ -5,23 +5,45 @@
|
|||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var a = document.createElement('audio');
|
||||
a.src = 'r11025_u8_c1.wav';
|
||||
a.load();
|
||||
is(a.paused, true, "Must be paused at start");
|
||||
a.play();
|
||||
is(a.paused, false, "Must not be paused after play");
|
||||
var videos = [];
|
||||
|
||||
function ended(evt) {
|
||||
var v = evt.target;
|
||||
is(v.paused, false, v._name + " must not be paused after end");
|
||||
if (AllFinished(videos)) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i<gPausedAfterEndedTests.length; ++i) {
|
||||
var v = document.createElement('video');
|
||||
var test = gPausedAfterEndedTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._finished = false;
|
||||
v.load();
|
||||
is(v.paused, true, v._name + " must be paused at start");
|
||||
|
||||
v.play();
|
||||
is(v.paused, false, v._name + " must not be paused after play");
|
||||
|
||||
v.addEventListener("ended", ended, false);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
a.addEventListener("ended", function () {
|
||||
is(a.paused, false, "Must not be paused after end");
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: play() method</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<video id="v" onerror="event.stopPropagation();"></video>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var v = document.getElementById("v");
|
||||
|
||||
var tokens = {
|
||||
0: ["play"],
|
||||
"play": ["canplay"],
|
||||
"canplay": ["playing"],
|
||||
"playing": ["canplay", "canplaythrough"],
|
||||
"canplaythrough": ["canplay", "canplaythrough"]
|
||||
};
|
||||
|
||||
var state = 0;
|
||||
|
||||
function gotPlayEvent(event) {
|
||||
ok(tokens[state].indexOf(event.type) >= 0, "Check expected event got " + event.type + " at " + state);
|
||||
state = event.type;
|
||||
}
|
||||
|
||||
["play", "canplay", "playing", "canplaythrough"].forEach(function (e) {
|
||||
v.addEventListener(e, gotPlayEvent, false);
|
||||
});
|
||||
|
||||
function ended() {
|
||||
is(state, "canplaythrough", "Last event should be canplaythrough");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
v.addEventListener("ended", ended, false);
|
||||
|
||||
v.src = "320x240.ogv";
|
||||
v.load();
|
||||
v.play();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,70 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: play() method</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
||||
<script>
|
||||
var videos = [];
|
||||
|
||||
var tokens = {
|
||||
0: ["play"],
|
||||
"play": ["canplay"],
|
||||
"canplay": ["playing"],
|
||||
"playing": ["canplay", "canplaythrough"],
|
||||
"canplaythrough": ["canplay", "canplaythrough"]
|
||||
};
|
||||
|
||||
function gotPlayEvent(event) {
|
||||
var v = event.target;
|
||||
ok(tokens[v._state].indexOf(event.type) >= 0,
|
||||
"Check expected event got " + event.type + " at " + v._state + " for " + v.src);
|
||||
v._state = event.type;
|
||||
}
|
||||
|
||||
function ended(event) {
|
||||
var v = event.target;
|
||||
v._finished = true;
|
||||
is(v._state, "canplaythrough", "Last event should be canplaythrough for " + v.src);
|
||||
if (AllFinished(videos)) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var v = document.createElement('video');
|
||||
var test = gSmallTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v._state = 0;
|
||||
v._finished = false;
|
||||
|
||||
["play", "canplay", "playing", "canplaythrough"].forEach(function (e) {
|
||||
v.addEventListener(e, gotPlayEvent, false);
|
||||
});
|
||||
|
||||
v.addEventListener("ended", ended, false);
|
||||
|
||||
v.src = test.name;
|
||||
document.body.appendChild(v); // Causes load.
|
||||
v.play();
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -30,6 +30,8 @@ function startTests() {
|
|||
continue;
|
||||
|
||||
v.src = test.name;
|
||||
v.name = test.name;
|
||||
v.playingCount = 0;
|
||||
var check = function(test, v) { return function() {
|
||||
checkMetadata(test.name, v, test);
|
||||
}}(test, v);
|
||||
|
@ -44,6 +46,8 @@ function startTests() {
|
|||
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
|
||||
ok(v.readyState != v.NETWORK_LOADED, test.name + " shouldn't report NETWORK_LOADED");
|
||||
ok(v.ended, test.name + " checking playback has ended");
|
||||
ok(v.playingCount > 0, "Expect at least one playing event");
|
||||
v.playingCount = 0;
|
||||
if (v._playedOnce) {
|
||||
--testsWaiting;
|
||||
if (testsWaiting == 0) {
|
||||
|
@ -65,8 +69,13 @@ function startTests() {
|
|||
setTimeout(startTests, 0);
|
||||
}
|
||||
}}(test, v);
|
||||
var checkPlaying = function(test, v) { return function() {
|
||||
is(test.name, v.name, "Should be testing file we think we're testing...");
|
||||
v.playingCount++;
|
||||
}}(test, v);
|
||||
v.addEventListener("load", noLoad, false);
|
||||
v.addEventListener("loadedmetadata", check, false);
|
||||
v.addEventListener("playing", checkPlaying, false);
|
||||
|
||||
// We should get "ended" and "suspend" events for every resource
|
||||
v.addEventListener("ended", checkEnded, false);
|
||||
|
|
|
@ -67,6 +67,7 @@ function startTests() {
|
|||
v.prevTime = 0;
|
||||
var timeUpdate = function(test, v) { return function() {
|
||||
is(test.name, v.name, "Name should match test.name #4");
|
||||
checkMetadata(test.name, v, test);
|
||||
ok(v.prevTime <= v.currentTime,
|
||||
test.name + " time should run forwards: p=" +
|
||||
v.prevTime + " c=" + v.currentTime);
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: progress events</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="use_large_cache.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var videos = [];
|
||||
|
||||
function do_progress(e) {
|
||||
var v = e.target;
|
||||
ok(!v._finished, "Check no progress events after completed for " + v._name);
|
||||
ok(e.lengthComputable, "Check progress lengthComputable for " + v._name);
|
||||
ok(e.loaded >= v._last_progress_total, "Check progress increasing: " + e.loaded + " for " + v._name);
|
||||
v._last_progress_total = e.loaded;
|
||||
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded + " for " + v._name);
|
||||
is(e.total, v._size, "Check progress total for " + v._name);
|
||||
}
|
||||
|
||||
function do_ended(e) {
|
||||
var v = e.target;
|
||||
ok(!v._finished, "Only one ended event for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
for (var i=0; i<gProgressTests.length; ++i) {
|
||||
var test = gProgressTests[i];
|
||||
var type = /^video/.test(test.type) ? "video" : "audio";
|
||||
var v = document.createElement(type);
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v.autoplay = true;
|
||||
v._name = test.name;
|
||||
v._size = test.size;
|
||||
v._finished = false;
|
||||
v._last_progress_total = 0;
|
||||
v.addEventListener("ended", do_ended, false);
|
||||
v.addEventListener("progress", do_progress, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,62 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: progress events</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="use_large_cache.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
var completed = false;
|
||||
var last_progress_total = 0;
|
||||
|
||||
function on_loadedmetadata() {
|
||||
var v = document.getElementById('v');
|
||||
ok(v, "Found video element after metadata loaded");
|
||||
v.play();
|
||||
dump('test_progress1: on_loadedmetadata exiting\n');
|
||||
}
|
||||
|
||||
function do_progress(e) {
|
||||
dump('test_progress1: do_progress ' + e.loaded + '\n');
|
||||
ok(!completed, "Check for progress event after completed");
|
||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
||||
ok(e.loaded >= last_progress_total, "Check progress increasing: " + e.loaded);
|
||||
last_progress_total = e.loaded;
|
||||
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded);
|
||||
is(e.total, 285310, "Check progress total");
|
||||
}
|
||||
|
||||
function do_ended() {
|
||||
dump('test_progress1: do_ended\n');
|
||||
ok(!completed, "Check for duplicate ended event");
|
||||
completed = true;
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function do_timeupdate() {
|
||||
var v = document.getElementById('v');
|
||||
dump('test_progress1: timeupdate: ' + v.currentTime + "\n");
|
||||
}
|
||||
|
||||
function do_play() {
|
||||
dump('test_progress1: do_play\n');
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='on_loadedmetadata()'
|
||||
onended='do_ended()'
|
||||
ontimeupdate='do_timeupdate()'
|
||||
onplay='do_play()'
|
||||
onprogress='do_progress(event)'>
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: progress events</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="use_large_cache.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test progress events with wav backend
|
||||
var completed = false;
|
||||
var last_progress_total = 0;
|
||||
|
||||
function on_loadedmetadata() {
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
}
|
||||
|
||||
function do_progress(e) {
|
||||
ok(!completed, "Check for progress event after completed");
|
||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
||||
ok(e.loaded >= last_progress_total, "Check progress increasing: " + e.loaded);
|
||||
last_progress_total = e.loaded;
|
||||
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded);
|
||||
is(e.total, 102444, "Check progress total");
|
||||
}
|
||||
|
||||
function do_ended() {
|
||||
ok(!completed, "Check for duplicate ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
src='big.wav'
|
||||
onloadedmetadata='on_loadedmetadata()'
|
||||
onended='do_ended()'
|
||||
onprogress='do_progress(event)'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
|
@ -1,63 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: progress events</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="use_large_cache.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Same as test_progress1 but uses a smaller file to test resource loaded
|
||||
// before metadata loaded is fired.
|
||||
var completed = false;
|
||||
var last_progress_total = 0;
|
||||
|
||||
function on_loadedmetadata() {
|
||||
var v = document.getElementById('v');
|
||||
ok(v, "Found video element after metadata loaded");
|
||||
v.play();
|
||||
dump('test_progress3: on_loadedmetadata exiting\n');
|
||||
}
|
||||
|
||||
function do_progress(e) {
|
||||
dump('test_progress3: do_progress ' + e.loaded + '/' + e.total + '\n');
|
||||
ok(!completed, "Check for progress event after completed");
|
||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
||||
ok(e.loaded >= last_progress_total, "Check progress increasing: " + e.loaded);
|
||||
last_progress_total = e.loaded;
|
||||
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded);
|
||||
is(e.total, 28942, "Check progress total");
|
||||
}
|
||||
|
||||
function do_ended() {
|
||||
dump('test_progress3: do_ended\n');
|
||||
ok(!completed, "Check for duplicate ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function do_timeupdate() {
|
||||
var v = document.getElementById('v');
|
||||
dump('test_progress3: timeupdate: ' + v.currentTime + "\n");
|
||||
}
|
||||
|
||||
function do_play() {
|
||||
dump('test_progress3: do_play\n');
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='320x240.ogv'
|
||||
onloadedmetadata='on_loadedmetadata()'
|
||||
onended='do_ended()'
|
||||
ontimeupdate='do_timeupdate()'
|
||||
onplay='do_play()'
|
||||
onprogress='do_progress(event)'>
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: progress events</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="use_large_cache.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test progress events with wav backend
|
||||
// Same as test_progress2 but uses a smaller file to test resource loaded
|
||||
// before metadata loaded is fired.
|
||||
var completed = false;
|
||||
var last_progress_total = 0;
|
||||
|
||||
function on_loadedmetadata() {
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
}
|
||||
|
||||
function do_progress(e) {
|
||||
ok(!completed, "Check for progress event after completed");
|
||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
||||
ok(e.loaded >= last_progress_total, "Check progress increasing: " + e.loaded);
|
||||
last_progress_total = e.loaded;
|
||||
ok(e.loaded <= e.total, "Check progress in bounds: " + e.loaded);
|
||||
is(e.total, 11069, "Check progress total");
|
||||
}
|
||||
|
||||
function do_ended() {
|
||||
ok(!completed, "Check for duplicate ended event");
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
src='r11025_u8_c1.wav'
|
||||
onloadedmetadata='on_loadedmetadata()'
|
||||
onended='do_ended()'
|
||||
onprogress='do_progress(event)'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,120 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 467972</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467972">Mozilla Bug 467972</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
// Test for Bug 467972. Tests that when we play to end, seek to 0, and play again, that we don't
|
||||
// send/receive multiple loadeddata and loadedmetadata events.
|
||||
|
||||
var videos = [];
|
||||
|
||||
function seekStarted(evt) {
|
||||
var v = evt.target;
|
||||
v._gotSeekStarted = true;
|
||||
}
|
||||
|
||||
function seekEnded(evt) {
|
||||
var v = evt.target;
|
||||
v._gotSeekEnded = true;
|
||||
v.play();
|
||||
}
|
||||
|
||||
function loadedData(evt) {
|
||||
var v = evt.target;
|
||||
v._loadedDataCount++;
|
||||
ok(v._loadedDataCount <= 1, "No more than 1 onloadeddata event for " + v._name);
|
||||
}
|
||||
|
||||
function loadedMetaData(evt) {
|
||||
var v = evt.target;
|
||||
v._loadedMetaDataCount++;
|
||||
ok(v._loadedMetaDataCount <= 1, "No more than 1 onloadedmetadata event for " + v._name);
|
||||
checkMetadata(v._name, v, v._test);
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playing(evt) {
|
||||
evt.target._playingCount++;
|
||||
}
|
||||
|
||||
function playbackEnded(evt) {
|
||||
var v = evt.target;
|
||||
v._endCount++;
|
||||
ok(v.currentTime >= v.duration-0.1 && v.currentTime <= v.duration + 0.1,
|
||||
"CurrentTime (" + v.currentTime + ") should be around " + v.duration
|
||||
+ " for " + v._name);
|
||||
if (!v._playedOnce) {
|
||||
v.currentTime = 0;
|
||||
ok(v.seeking, "seeking should be true for " + v._name);
|
||||
ok(!v.ended, "ended shouldn't be true once seeking has begun for " + v._name);
|
||||
v._playedOnce = true;
|
||||
v.play();
|
||||
} else {
|
||||
ok(v._gotSeekEnded, "Should have received seekended for " + v._name);
|
||||
ok(v._gotSeekStarted, "Should have received seekstarted for " + v._name);
|
||||
is(v._loadedDataCount, 1, "Should have 1 onloadeddata event for " + v._name);
|
||||
is(v._loadedMetaDataCount, 1, "Should have 1 onloadedmetadata event for " + v._name);
|
||||
is(v._endCount, 2, "Should have received two ended events for " + v._name);
|
||||
ok(v._playingCount > 0, "Should have at least one playing event for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos)) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var v = document.createElement('video');
|
||||
var test = gSmallTests[i];
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._playedOnce = false;
|
||||
v._gotSeekEnded = false;
|
||||
v._gotSeekStarted = false;
|
||||
v._loadedDataCount = 0;
|
||||
v._loadedMetaDataCount = 0;
|
||||
v._playingCount = 0;
|
||||
v._endCount = 0;
|
||||
v._test = test;
|
||||
v._finished = false;
|
||||
v.addEventListener("loadedmetadata", loadedMetaData, false);
|
||||
v.addEventListener("ended", playbackEnded, false);
|
||||
v.addEventListener("playing", playing, false);
|
||||
v.addEventListener("loadeddata", loadedData, false);
|
||||
v.addEventListener("seeking", seekStarted, false);
|
||||
v.addEventListener("seeked", seekEnded, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -16,6 +16,7 @@
|
|||
<script type="text/javascript" src="seek8.js"></script>
|
||||
<script type="text/javascript" src="seek9.js"></script>
|
||||
<script type="text/javascript" src="seek10.js"></script>
|
||||
<script type="text/javascript" src="seek11.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
@ -39,7 +40,7 @@ function doNextFile() {
|
|||
return;
|
||||
}
|
||||
|
||||
for (var i = 1; i <= 10; ++i) {
|
||||
for (var i = 1; i <= 11; ++i) {
|
||||
var v = document.createElement('video');
|
||||
v.src = test.name;
|
||||
document.body.appendChild(v);
|
||||
|
@ -60,6 +61,7 @@ function doNextFile() {
|
|||
doNextFile();
|
||||
}
|
||||
};
|
||||
dump("Seek test: " + i + "\n");
|
||||
window['test_seek' + i](v, test.duration/2, localIs, localOk, localFinish);
|
||||
++testsWaiting;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: seeking off the end of a file</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var videos = [];
|
||||
|
||||
// Test if the ended event works correctly.
|
||||
|
||||
function startTest(e) {
|
||||
var v = e.target;
|
||||
checkMetadata(v._name, v, v._test);
|
||||
is(v._loadedMetadata, false, "Should only receive one loadedmetadata event for " + v._name);
|
||||
v._loadedMetadata = true;
|
||||
v.currentTime = 3.0 * v.duration;
|
||||
}
|
||||
|
||||
function playbackEnded(e) {
|
||||
var v = e.target;
|
||||
// We should have dispatched an ended event when we seeked to the end of
|
||||
// media, but we want the ended event which dispatches once playback has
|
||||
// completed after the seek to the beginning.
|
||||
if (!v._played)
|
||||
return;
|
||||
ok(v.ended, "Checking ended set after seeking to EOF and playing for " + v._name);
|
||||
ok(!v._finished, "Should only hit the end once for " + v._name);
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function endSeek(e) {
|
||||
var v = e.target;
|
||||
if (v._seeked)
|
||||
return;
|
||||
v._seeked = true;
|
||||
ok(Math.abs(v.duration - v.currentTime) < 0.1,
|
||||
"Should be at end of media for " + v._name + " t=" + v.currentTime + " d=" + v.duration);
|
||||
v.play();
|
||||
}
|
||||
|
||||
function playing(e) {
|
||||
e.target._played = true;
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
var type = /^video/.test(test.type) ? "video" : "audio";
|
||||
var v = document.createElement(type);
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._finished = false;
|
||||
v._test = test;
|
||||
v._loadedMetadata = false;
|
||||
v._seeked = false;
|
||||
v._played = false;
|
||||
v.addEventListener("loadedmetadata", startTest, false);
|
||||
v.addEventListener("playing", playing, false);
|
||||
v.addEventListener("seeked", endSeek, false);
|
||||
v.addEventListener("ended", playbackEnded, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -5,6 +5,7 @@
|
|||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<video id="v1" onerror="event.stopPropagation();"></video>
|
||||
|
@ -21,21 +22,25 @@ is(a1.currentSrc, "", "currentSrc should be null");
|
|||
is(v1.childNodes.length, 0, "should have no children");
|
||||
is(a1.childNodes.length, 0, "should have no children");
|
||||
|
||||
function newSource() {
|
||||
function newSource(filter) {
|
||||
var test = null;
|
||||
var candidates = gSmallTests.filter(function(x){return filter.test(x.type);});
|
||||
var e = document.createElement("source");
|
||||
e.type = "application/ogg";
|
||||
e.src = "320x240.ogv";
|
||||
e.type = candidates[0].type;
|
||||
e.src = candidates[0].name;
|
||||
return e;
|
||||
}
|
||||
|
||||
var audioLoaded = false;
|
||||
var videoLoaded = false;
|
||||
|
||||
function loaded(media) {
|
||||
function loaded(e) {
|
||||
var media = e.target;
|
||||
ok(media.networkState > 0, "networkState should be > 0");
|
||||
is(media.childNodes.length, 1, "should have 1 child");
|
||||
var sourceFile = media.currentSrc.substring(media.currentSrc.lastIndexOf('/'));
|
||||
is(sourceFile, "/320x240.ogv", "loaded wrong resource");
|
||||
var sourceFile = media.currentSrc.substring(media.currentSrc.lastIndexOf('/')+1);
|
||||
var resource = media.firstChild.src.substring(media.firstChild.src.lastIndexOf('/')+1);
|
||||
is(sourceFile, resource, "loaded wrong resource!");
|
||||
if (media == a1)
|
||||
audioLoaded = true;
|
||||
else if (media == v1)
|
||||
|
@ -45,15 +50,32 @@ function loaded(media) {
|
|||
}
|
||||
}
|
||||
|
||||
v1.addEventListener('loadeddata', function() { loaded(v1); }, false);
|
||||
a1.addEventListener('loadeddata', function() { loaded(a1); }, false);
|
||||
v1.addEventListener('loadeddata', loaded, false);
|
||||
a1.addEventListener('loadeddata', loaded, false);
|
||||
|
||||
v1.appendChild(newSource());
|
||||
v1.load();
|
||||
a1.appendChild(newSource());
|
||||
a1.load();
|
||||
var videoSource = newSource(/^video/);
|
||||
if (videoSource) {
|
||||
v1.appendChild(videoSource);
|
||||
v1.load();
|
||||
} else {
|
||||
// No video backends? Don't test anything.
|
||||
videoLoaded = true;
|
||||
}
|
||||
|
||||
var audioSource = newSource(/^audio/);
|
||||
if (audioSource) {
|
||||
a1.appendChild(audioSource);
|
||||
a1.load();
|
||||
} else {
|
||||
audioLoaded = true;
|
||||
}
|
||||
|
||||
if (!audioLoaded && !videoLoaded) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} else {
|
||||
todo(false, "No types supported");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462455
|
|||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462455">Mozilla Bug 462455</a>
|
||||
|
@ -19,17 +20,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462455
|
|||
</pre>
|
||||
|
||||
<video id="v">
|
||||
<source src="320x240.ogv" type="application/ogg"></source>
|
||||
<script>
|
||||
var loadStarted = false;
|
||||
document.write('Pause parsing!');
|
||||
var v = document.getElementById('v');
|
||||
if (v.networkState != HTMLMediaElement.NETWORK_EMPTY) {
|
||||
loadStarted = true;
|
||||
|
||||
var resource = getPlayableVideo(gSmallTests);
|
||||
if (resource != null) {
|
||||
var s = document.createElement("source");
|
||||
s.src = resource.name;
|
||||
s.type = resource.type;
|
||||
v.appendChild(s);
|
||||
}
|
||||
is(loadStarted, false, "We shouldn't start a load until the video tag is closed.");
|
||||
|
||||
ok(v.networkState == HTMLMediaElement.NETWORK_EMPTY,
|
||||
"We shouldn't start a load until the video tag is closed.");
|
||||
</script>
|
||||
</video>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -5,24 +5,57 @@
|
|||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body onload="doTest()">
|
||||
|
||||
<iframe id="i" src="320x240.ogv"></iframe>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var iframes = [];
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
|
||||
// We can't play WAV files in stand alone documents, so just don't
|
||||
// run the test on non-video content types.
|
||||
var isVideo = /^video/.test(test.type) ? true : false;
|
||||
if (!isVideo || !document.createElement("video").canPlayType(test.type))
|
||||
continue;
|
||||
|
||||
var f = document.createElement("iframe");
|
||||
f.src = test.name;
|
||||
f._test = test;
|
||||
f.id = "frame" + i;
|
||||
iframes.push(f);
|
||||
document.body.appendChild(f);
|
||||
}
|
||||
|
||||
|
||||
function filename(uri) {
|
||||
return uri.substr(uri.lastIndexOf("/")+1);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var elem = document.getElementById("i").contentDocument.body.firstChild;
|
||||
is(elem.tagName.toLowerCase(), "video", "Is video element");
|
||||
is(elem.currentSrc.substring(elem.currentSrc.length - 11), "320x240.ogv", "currentSrc");
|
||||
is(elem.controls, true, "Controls set");
|
||||
is(elem.autoplay, true, "Autoplay set");
|
||||
for (var i=0; i<iframes.length; ++i) {
|
||||
var f = document.getElementById(iframes[i].id);
|
||||
var v = f.contentDocument.body.firstChild;
|
||||
is(v.tagName.toLowerCase(), "video", "Is video element");
|
||||
var src = filename(v.currentSrc);
|
||||
is(src, iframes[i]._test.name, "Name ("+src+") should match ("+iframes[i]._test.name+")");
|
||||
is(v.controls, true, "Controls set (" + src + ")");
|
||||
is(v.autoplay, true, "Autoplay set (" + src + ")");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
if (iframes.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: timeupdate during playback</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if timeupdate is dispatched and the current time during the
|
||||
// update is increasing.
|
||||
var lastTime = 0.0;
|
||||
var completed = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function timeUpdated() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
ok(v.currentTime > lastTime,
|
||||
"currentTime (" + v.currentTime +
|
||||
") should be greater than last time (" + lastTime + ")");
|
||||
lastTime = v.currentTime;
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'
|
||||
onended='return playbackEnded();'
|
||||
ontimeupdate='return timeUpdated();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: timeupdate and size</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if the media size during the first timeupdate is correct.
|
||||
var completed = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function timeUpdated() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
ok(v.videoHeight == 240, "Check video height of " + v.videoHeight + " is 240");
|
||||
ok(v.videoWidth == 320, "Check video width of " + v.videoWidth + " is 320");
|
||||
completed = true;
|
||||
v.pause();
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='seek.ogv'
|
||||
onloadedmetadata='return startTest();'
|
||||
ontimeupdate='return timeUpdated();'></video>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=495319
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Bug 495319 - playing back small audio files should fire timeupdate</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495319">Mozilla Bug 495319</a>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var videos = [];
|
||||
|
||||
function timeupdate(e) {
|
||||
e.target._timeupdateCount++;
|
||||
}
|
||||
|
||||
function ended(e) {
|
||||
var v = e.target;
|
||||
ok(v._timeupdateCount > 0, v._name + " - should see at least one timeupdate: " + v.currentTime);
|
||||
e.target._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
var type = /^video/.test(test.type) ? "video" : "audio";
|
||||
var v = document.createElement(type);
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._timeupdateCount = 0;
|
||||
v._finished = false;
|
||||
v.autoplay = true;
|
||||
v.addEventListener("ended", ended, false);
|
||||
v.addEventListener("timeupdate", timeupdate, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=486646
|
||||
-->
|
||||
|
||||
<head>
|
||||
<title>Test for Bug 486646</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="use_large_cache.js"></script>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var videos = [];
|
||||
|
||||
function loaded(e) {
|
||||
var v = e.target;
|
||||
ok(v.readyState >= v.HAVE_CURRENT_DATA,
|
||||
"readyState must be >= HAVE_CURRENT_DATA for " + v._name);
|
||||
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.width = v.videoWidth;
|
||||
canvas.height = v.videoHeight;
|
||||
document.body.appendChild(canvas);
|
||||
var ctx = canvas.getContext("2d");
|
||||
try {
|
||||
ctx.drawImage(v, 0, 0);
|
||||
ok(true, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
|
||||
} catch (ex) {
|
||||
ok(false, "Shouldn't throw exception while drawing to canvas from video for " + v._name);
|
||||
}
|
||||
|
||||
v._finished = true;
|
||||
if (AllFinished(videos))
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i=0; i<gSmallTests.length; ++i) {
|
||||
var test = gSmallTests[i];
|
||||
var isVideo = /^video/.test(test.type) ? true : false;
|
||||
if (!isVideo)
|
||||
continue;
|
||||
|
||||
var v = document.createElement('video');
|
||||
if (!v.canPlayType(test.type))
|
||||
continue;
|
||||
v.src = test.name;
|
||||
v._name = test.name;
|
||||
v._finished = false;
|
||||
v.autoplay = true;
|
||||
v.style.display = "none";
|
||||
v.addEventListener("ended", loaded, false);
|
||||
document.body.appendChild(v);
|
||||
videos.push(v);
|
||||
}
|
||||
|
||||
if (videos.length == 0) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,87 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
|
||||
-->
|
||||
<head>
|
||||
<title>Wav Test for Bug 467972</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467972">Mozilla Bug 467972</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 467972 **/
|
||||
|
||||
|
||||
var gEnded = false;
|
||||
var gSeekStarted = false;
|
||||
var gSeekEnded = false;
|
||||
var gLoadedDataCount = 0;
|
||||
var gLoadedMetaDataCount = 0;
|
||||
|
||||
function get(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function video() {
|
||||
return get('v');
|
||||
}
|
||||
|
||||
function seekStarted() {
|
||||
gSeekStarted = true;
|
||||
}
|
||||
|
||||
function seekEnded() {
|
||||
gSeekEnded = true;
|
||||
video().play();
|
||||
}
|
||||
|
||||
function loadedData() {
|
||||
gLoadedDataCount++;
|
||||
ok(gLoadedDataCount <= 1, "No more than 1 onloadeddata events");
|
||||
}
|
||||
|
||||
function loadedMetaData() {
|
||||
gLoadedMetaDataCount++;
|
||||
ok(gLoadedMetaDataCount <= 1, "No more than 1 onloadedmetadata events");
|
||||
ok(video().duration > 0.9 && video().duration < 1.1, "Duration should be around 1.0");
|
||||
video().play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (!gEnded) {
|
||||
video().currentTime = 0;
|
||||
gEnded = true;
|
||||
} else {
|
||||
ok(gSeekEnded, "Should have received seekended");
|
||||
ok(gSeekStarted, "Should have received seekstarted");
|
||||
is(gLoadedDataCount, 1, "Should have 1 onloadeddata event");
|
||||
is(gLoadedMetaDataCount, 1, "Should have 1 onloadedmetadata event");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<video id="v"
|
||||
onloadedmetadata="return loadedMetaData();"
|
||||
onended="playbackEnded();"
|
||||
onloadeddata="return loadedData();"
|
||||
onseeking="seekStarted();"
|
||||
onseeked="seekEnded();"
|
||||
src="r11025_s16_c1.wav"
|
||||
controls></video>
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: standalone video documents</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="doTest()">
|
||||
|
||||
<iframe id="i" src="r11025_u8_c1.wav"></iframe>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var gExpectEnded = 2;
|
||||
|
||||
function endTest()
|
||||
{
|
||||
var elem = document.getElementById("i").contentDocument.body.firstChild;
|
||||
gExpectEnded--;
|
||||
if (gExpectEnded == 1) {
|
||||
elem.play();
|
||||
} else {
|
||||
is(gExpectEnded, 0, "not expecting more ended events");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var elem = document.getElementById("i").contentDocument.body.firstChild;
|
||||
is(elem.tagName.toLowerCase(), "video", "Is video element");
|
||||
is(elem.currentSrc.substring(elem.currentSrc.length - 16), "r11025_u8_c1.wav", "currentSrc");
|
||||
is(elem.controls, true, "Controls set");
|
||||
is(elem.autoplay, true, "Autoplay set");
|
||||
|
||||
if (elem.ended) {
|
||||
gExpectEnded = 1;
|
||||
elem.play();
|
||||
}
|
||||
elem.addEventListener("ended", endTest, false);
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,64 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: timeupdate during playback</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if timeupdate is dispatched and the current time during the
|
||||
// update is increasing.
|
||||
var lastTime = 0.0;
|
||||
var completed = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function timeUpdated() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
|
||||
// Check that duration metadata is correct during the first timeupdate.
|
||||
if (lastTime == 0) {
|
||||
ok(v.duration > 0.9 && v.duration < 1.1, "Duration should be around 1.0: " + v.duration);
|
||||
}
|
||||
|
||||
ok(v.currentTime > lastTime,
|
||||
"Check currentTime of " +
|
||||
v.currentTime +
|
||||
" is greater than last time of " +
|
||||
lastTime);
|
||||
lastTime = v.currentTime;
|
||||
return false;
|
||||
}
|
||||
|
||||
function playbackEnded() {
|
||||
if (completed)
|
||||
return false
|
||||
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
src='r11025_u8_c1.wav'
|
||||
onloadedmetadata='return startTest();'
|
||||
onended='return playbackEnded();'
|
||||
ontimeupdate='return timeUpdated();'></audio>
|
||||
</body>
|
||||
</html>
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: timeupdate after seeking</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var completed = false;
|
||||
var seeking = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
v.currentTime = 0.5;
|
||||
return false;
|
||||
}
|
||||
|
||||
function startSeek() {
|
||||
if (completed)
|
||||
return false;
|
||||
|
||||
seeking = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function timeUpdated() {
|
||||
if (completed || !seeking)
|
||||
return false;
|
||||
|
||||
var v = document.getElementById('v');
|
||||
|
||||
// Check that currentTime is within range in first timeupdate after seeking.
|
||||
ok(v.currentTime > 0.4 && v.currentTime < 0.6, "currentTime should be around 0.5: " + v.currentTime);
|
||||
|
||||
completed = true;
|
||||
SimpleTest.finish();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
src='r11025_u8_c1.wav'
|
||||
onloadedmetadata='return startTest();'
|
||||
onseeking='return startSeek();'
|
||||
ontimeupdate='return timeUpdated();'></audio>
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Wave Media test: seeking in truncated file</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Test if the ended event works correctly.
|
||||
var endPassed = false;
|
||||
var completed = false;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
var v = document.getElementById('v');
|
||||
ok(v.duration > 1.7 && v.duration < 1.9, "Duration should be around 1.8: " + v.duration);
|
||||
|
||||
v.currentTime = 3.0;
|
||||
return false;
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
var v = document.getElementById('v');
|
||||
ok(v.ended, "Checking ended set after seeking to EOF and playing");
|
||||
SimpleTest.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
function endSeek() {
|
||||
if (completed)
|
||||
return false
|
||||
var v = document.getElementById('v');
|
||||
completed = true;
|
||||
ok(v.currentTime >= 1.7 && v.currentTime <= 1.9,
|
||||
"Checking currentTime at end: " + v.currentTime);
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<audio id='v'
|
||||
onloadedmetadata='return startTest();'
|
||||
onseeked='return endSeek();'
|
||||
onended='return endTest();'>
|
||||
<source type='audio/x-wav' src='r11025_u8_c1_trunc.wav'>
|
||||
</audio>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче