mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
c7317b404d
--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
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
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();
|
|
}
|