Unreviewed gardening; update LayoutTests/media-source to the most recent version...
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / media-source / interfaces.html
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>Media Source Extensions IDL tests</title>
4 <div id=log></div>
5 <script src=/resources/testharness.js></script>
6 <script src=/resources/testharnessreport.js></script>
7 <script src=/resources/WebIDLParser.js></script>
8 <script src=/resources/idlharness.js></script>
9 <script type=text/plain class=untested>
10 interface EventTarget {
11   void addEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
12   void removeEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
13   boolean dispatchEvent(Event event);
14 };
15 interface URL {};
16 interface HTMLVideoElement {};
17 interface AudioTrack {};
18 interface AudioTrackList {};
19 interface VideoTrack {};
20 interface VideoTrackList {};
21 interface TextTrack {};
22 interface TextTrackList {};
23 interface TimeRanges {};
24 typedef double DOMHighResTimeStamp;
25 </script>
26 <script type=text/plain>
27 [Constructor]
28 interface MediaSource : EventTarget {
29     readonly attribute SourceBufferList    sourceBuffers;
30     readonly attribute SourceBufferList    activeSourceBuffers;
31     readonly attribute ReadyState          readyState;
32              attribute unrestricted double duration;
33              attribute EventHandler        onsourceopen;
34              attribute EventHandler        onsourceended;
35              attribute EventHandler        onsourceclose;
36     SourceBuffer addSourceBuffer(DOMString type);
37     void         removeSourceBuffer(SourceBuffer sourceBuffer);
38     void         endOfStream(optional EndOfStreamError error);
39     void         setLiveSeekableRange(double start, double end);
40     void         clearLiveSeekableRange();
41     static boolean isTypeSupported(DOMString type);
42 };
43
44 interface SourceBuffer : EventTarget {
45              attribute AppendMode          mode;
46     readonly attribute boolean             updating;
47     readonly attribute TimeRanges          buffered;
48              attribute double              timestampOffset;
49     readonly attribute AudioTrackList      audioTracks;
50     readonly attribute VideoTrackList      videoTracks;
51     readonly attribute TextTrackList       textTracks;
52              attribute double              appendWindowStart;
53              attribute unrestricted double appendWindowEnd;
54              attribute EventHandler        onupdatestart;
55              attribute EventHandler        onupdate;
56              attribute EventHandler        onupdateend;
57              attribute EventHandler        onerror;
58              attribute EventHandler        onabort;
59     void appendBuffer(BufferSource data);
60     void abort();
61     void remove(double start, unrestricted double end);
62 };
63
64 interface SourceBufferList : EventTarget {
65     readonly attribute unsigned long length;
66              attribute EventHandler  onaddsourcebuffer;
67              attribute EventHandler  onremovesourcebuffer;
68     getter SourceBuffer (unsigned long index);
69 };
70
71 [Exposed=Window,DedicatedWorker,SharedWorker]
72 partial interface URL {
73     static DOMString createObjectURL(MediaSource mediaSource);
74 };
75
76 partial interface AudioTrack {
77     readonly attribute SourceBuffer? sourceBuffer;
78 };
79
80 partial interface VideoTrack {
81     readonly attribute SourceBuffer? sourceBuffer;
82 };
83
84 partial interface TextTrack {
85     readonly attribute SourceBuffer? sourceBuffer;
86 };
87
88 enum EndOfStreamError {
89     "network",
90     "decode"
91 };
92
93 enum AppendMode {
94     "segments",
95     "sequence"
96 };
97
98 enum ReadyState {
99     "closed",
100     "open",
101     "ended"
102 };
103 </script>
104 <script>
105 "use strict";
106 setup({ explicit_done: true });
107 var mediaSource;
108 var sourceBuffer;
109 var video = document.createElement("video");
110 var idlCheck = function() {
111   var idlArray = new IdlArray();
112   [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
113     if (node.className == "untested") {
114       idlArray.add_untested_idls(node.textContent);
115     } else {
116       idlArray.add_idls(node.textContent);
117     }
118   });
119   idlArray.add_objects({
120     MediaSource: ['mediaSource'],
121     SourceBuffer: ['sourceBuffer'],
122     SourceBufferList: ['mediaSource.sourceBuffers']
123   });
124   idlArray.test();
125   done();
126 }
127 mediaSource = new MediaSource();
128 video.src = URL.createObjectURL(mediaSource);
129 mediaSource.addEventListener("sourceopen", function () {
130   var defaultType ='video/webm;codecs="vp8,vorbis"';
131   if (video.canPlayType(defaultType)) {
132     sourceBuffer = mediaSource.addSourceBuffer(defaultType);
133   } else {
134     sourceBuffer = mediaSource.addSourceBuffer('video/mp4');
135   }
136   sourceBuffer.addEventListener("updateend", function (e) {
137     mediaSource.endOfStream();
138     idlCheck();
139   });
140   sourceBuffer.appendBuffer(new ArrayBuffer());
141 });
142 </script>