mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
143 lines
4.6 KiB
HTML
143 lines
4.6 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<title>Media Source Extensions IDL tests</title>
|
|
<div id=log></div>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<script src=/resources/WebIDLParser.js></script>
|
|
<script src=/resources/idlharness.js></script>
|
|
<script type=text/plain class=untested>
|
|
interface EventTarget {
|
|
void addEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
|
|
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
|
|
boolean dispatchEvent(Event event);
|
|
};
|
|
interface EventHandler {};
|
|
interface URL {};
|
|
interface HTMLVideoElement {};
|
|
interface AudioTrack {};
|
|
interface AudioTrackList {};
|
|
interface VideoTrack {};
|
|
interface VideoTrackList {};
|
|
interface TextTrack {};
|
|
interface TextTrackList {};
|
|
interface TimeRanges {};
|
|
typedef double DOMHighResTimeStamp;
|
|
</script>
|
|
<script type=text/plain>
|
|
[Constructor]
|
|
interface MediaSource : EventTarget {
|
|
readonly attribute SourceBufferList sourceBuffers;
|
|
readonly attribute SourceBufferList activeSourceBuffers;
|
|
readonly attribute ReadyState readyState;
|
|
attribute unrestricted double duration;
|
|
attribute EventHandler onsourceopen;
|
|
attribute EventHandler onsourceended;
|
|
attribute EventHandler onsourceclose;
|
|
SourceBuffer addSourceBuffer(DOMString type);
|
|
void removeSourceBuffer(SourceBuffer sourceBuffer);
|
|
void endOfStream(optional EndOfStreamError error);
|
|
void setLiveSeekableRange(double start, double end);
|
|
void clearLiveSeekableRange();
|
|
static boolean isTypeSupported(DOMString type);
|
|
};
|
|
|
|
interface SourceBuffer : EventTarget {
|
|
attribute AppendMode mode;
|
|
readonly attribute boolean updating;
|
|
readonly attribute TimeRanges buffered;
|
|
attribute double timestampOffset;
|
|
readonly attribute AudioTrackList audioTracks;
|
|
readonly attribute VideoTrackList videoTracks;
|
|
readonly attribute TextTrackList textTracks;
|
|
attribute double appendWindowStart;
|
|
attribute unrestricted double appendWindowEnd;
|
|
attribute EventHandler onupdatestart;
|
|
attribute EventHandler onupdate;
|
|
attribute EventHandler onupdateend;
|
|
attribute EventHandler onerror;
|
|
attribute EventHandler onabort;
|
|
void appendBuffer(BufferSource data);
|
|
void abort();
|
|
void remove(double start, unrestricted double end);
|
|
};
|
|
|
|
interface SourceBufferList : EventTarget {
|
|
readonly attribute unsigned long length;
|
|
attribute EventHandler onaddsourcebuffer;
|
|
attribute EventHandler onremovesourcebuffer;
|
|
getter SourceBuffer (unsigned long index);
|
|
};
|
|
|
|
[Exposed=Window,DedicatedWorker,SharedWorker]
|
|
partial interface URL {
|
|
static DOMString createObjectURL(MediaSource mediaSource);
|
|
};
|
|
|
|
partial interface AudioTrack {
|
|
readonly attribute SourceBuffer? sourceBuffer;
|
|
};
|
|
|
|
partial interface VideoTrack {
|
|
readonly attribute SourceBuffer? sourceBuffer;
|
|
};
|
|
|
|
partial interface TextTrack {
|
|
readonly attribute SourceBuffer? sourceBuffer;
|
|
};
|
|
|
|
enum EndOfStreamError {
|
|
"network",
|
|
"decode"
|
|
};
|
|
|
|
enum AppendMode {
|
|
"segments",
|
|
"sequence"
|
|
};
|
|
|
|
enum ReadyState {
|
|
"closed",
|
|
"open",
|
|
"ended"
|
|
};
|
|
</script>
|
|
<script>
|
|
"use strict";
|
|
setup({ explicit_done: true });
|
|
var mediaSource;
|
|
var sourceBuffer;
|
|
var video = document.createElement("video");
|
|
var idlCheck = function() {
|
|
var idlArray = new IdlArray();
|
|
[].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
|
|
if (node.className == "untested") {
|
|
idlArray.add_untested_idls(node.textContent);
|
|
} else {
|
|
idlArray.add_idls(node.textContent);
|
|
}
|
|
});
|
|
idlArray.add_objects({
|
|
MediaSource: ['mediaSource'],
|
|
SourceBuffer: ['sourceBuffer'],
|
|
SourceBufferList: ['mediaSource.sourceBuffers']
|
|
});
|
|
idlArray.test();
|
|
done();
|
|
}
|
|
mediaSource = new MediaSource();
|
|
video.src = URL.createObjectURL(mediaSource);
|
|
mediaSource.addEventListener("sourceopen", function () {
|
|
var defaultType ='video/webm;codecs="vp8,vorbis"';
|
|
if (MediaSource.isTypeSupported(defaultType)) {
|
|
sourceBuffer = mediaSource.addSourceBuffer(defaultType);
|
|
} else {
|
|
sourceBuffer = mediaSource.addSourceBuffer('video/mp4');
|
|
}
|
|
sourceBuffer.addEventListener("updateend", function (e) {
|
|
mediaSource.endOfStream();
|
|
idlCheck();
|
|
});
|
|
sourceBuffer.appendBuffer(new ArrayBuffer());
|
|
});
|
|
</script>
|