Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: LayoutTests/imported/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/imported/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html
diff --git a/LayoutTests/media/track/opera/interfaces/TextTrack/cues.html b/LayoutTests/imported/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html
similarity index 54%
copy from LayoutTests/media/track/opera/interfaces/TextTrack/cues.html
copy to LayoutTests/imported/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html
index c89316a28da21481c3362daac1ac6fdd33866ca2..c9d98db127a33b720e74bb0decddafdebd13d8ba 100644
--- a/LayoutTests/media/track/opera/interfaces/TextTrack/cues.html
+++ b/LayoutTests/imported/web-platform-tests/html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html
@@ -1,39 +1,45 @@
<!doctype html>
<title>TextTrack.cues</title>
-<script src=../../../../../resources/testharness.js></script>
-<script src=../../../../../resources/testharnessreport.js></script>
+<script src=../../../../../../../../resources/testharness.js></script>
+<script src=../../../../../../../../resources/testharnessreport.js></script>
<div id=log></div>
<script>
-setup(function(){
- window.video = document.createElement('video');
- window.t1 = video.addTextTrack('subtitles');
- window.track = document.createElement('track');
- track['default'] = true;
- video.appendChild(track); // queues a task to "honor user preferences...", media element event task source
- window.t2 = track.track;
- window.t1_cues = t1.cues
- window.t2_cues = t2.cues
-});
test(function(){
- assert_equals(t1.cues, t1_cues, 't1.cues should return same object');
+ var video = document.createElement('video');
+ var t1 = video.addTextTrack('subtitles');
+ assert_equals(t1.cues, t1.cues, 't1.cues should return same object');
assert_not_equals(t1.cues, null, 't1.cues should not be null');
- assert_equals(t1.cues.length, 0, 't1.cues should have length 0');
+ assert_true(t1.cues instanceof TextTrackCueList, 't1.cues instanceof TextTrackCueList');
+ assert_equals(t1.cues.length, 0, 't1.cues.length');
}, document.title+', empty list');
+
+function addCue(texttrack, start, end, text, id) {
+ var c = new VTTCue(start, end, text);
+ c.id = id;
+ texttrack.addCue(c);
+ return c;
+}
+
test(function(){
- var c = new VTTCue(0, 1, "text");
- c.id = "id";
- t1.addCue(c);
+ var video = document.createElement('video');
+ var t1 = video.addTextTrack('subtitles');
+ var t1_cues = t1.cues;
+ var c = addCue(t1, 0, 1, 'text', 'id');
assert_equals(t1.cues, t1_cues, "t1.cues should return same object");
assert_equals(t1.cues.length, 1, "t1.cues.length");
- var c2 = new VTTCue(1, 2, "text2");
- c2.id = "id2";
- t1.addCue(c2);
+ var c2 = addCue(t1, 1, 2, 'text2', 'id2');
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after adding a second cue");
assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue");
assert_equals(t1.cues[0].id, "id");
assert_equals(t1.cues[1].id, "id2");
}, document.title+', after addCue()');
+
test(function(){
+ var video = document.createElement('video');
+ var t1 = video.addTextTrack('subtitles');
+ var t1_cues = t1.cues;
+ var c = addCue(t1, 0, 1, 'text', 'id');
+ var c2 = addCue(t1, 1, 2, 'text2', 'id2');
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'showing'");
t1.mode = 'hidden';
@@ -53,7 +59,13 @@ test(function(){
t1.mode = 'showing';
assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after setting mode to 'disabled' and then 'showing'");
}, document.title+', different modes');
+
test(function(){
+ var video = document.createElement('video');
+ var t1 = video.addTextTrack('subtitles');
+ var t1_cues = t1.cues;
+ var c = addCue(t1, 0, 1, 'text', 'id');
+ var c2 = addCue(t1, 1, 2, 'text2', 'id2');
t1.mode = 'showing';
t1.cues[1].startTime = 0; // this should change the text track cue order
assert_equals(t1.cues[0].id, 'id2');
@@ -62,17 +74,27 @@ test(function(){
assert_equals(t1.cues[0].id, 'id');
assert_equals(t1.cues[1].id, 'id2');
}, document.title+', changing order');
-// FIXME: disabled because it requires a newer testharness.js
-//async_test(function(){
-// t1.mode = 'showing';
-// assert_equals(t2.cues, null, 't2.cues should be null');
-// video.onplay = this.step_func(function(){
-// assert_equals(t2.cues, t2_cues, 't2.cues should return same object');
-// assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be different objects');
-// assert_not_equals(t2.cues, null, 't2.cues should not be null');
-// assert_equals(t2.cues.length, 0, 't2.cues should have length 0');
-// this.done();
-// });
-// video.play(); // queues a task to fire 'play', media element event task source
-//}, document.title+', default attribute');
+
+async_test(function(){
+ var video = document.createElement('video');
+ var t1 = video.addTextTrack('subtitles');
+ var t1_cues = t1.cues;
+ t1.mode = 'showing';
+ var track = document.createElement('track');
+ track['default'] = true;
+ video.appendChild(track); // queues a task to "honor user preferences...", media element event task source
+ var t2 = track.track;
+ assert_equals(t2.cues, null, 't2.cues should be null');
+ // We need to wait until the "honor user preferences..." steps have run so we invoke play()
+ // which queues an event with the same task source.
+ video.onplay = this.step_func(function(){
+ assert_equals(t2.cues, t2.cues, 't2.cues should return same object');
+ assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be different objects');
+ assert_not_equals(t2.cues, null, 't2.cues should not be null');
+ assert_true(t2.cues instanceof TextTrackCueList, 't2.cues instanceof TextTrackCueList');
+ assert_equals(t2.cues.length, 0, 't2.cues should have length 0');
+ this.done();
+ });
+ video.play(); // queues a task to fire 'play', media element event task source
+}, document.title+', default attribute');
</script>

Powered by Google App Engine
This is Rietveld 408576698