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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.html

Issue 1879353002: Convert track tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test that cue text is mutable.</title>
3 <head> 3 <script src="../media-file.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../media-controls.js"></script>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <video>
8 <track src="captions-webvtt/captions-gaps.vtt" kind="captions" default >
9 </video>
10 <script>
11 async_test(function(t) {
12 var video = document.querySelector("video");
13 var testTrack = document.querySelector("track");
5 14
6 <script src=../media-file.js></script> 15 video.oncanplaythrough = t.step_func(testMutability);
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 16 testTrack.onload = t.step_func(testMutability);
8 (Please avoid writing new tests using video-test.js) -->
9 <script src=../video-test.js></script>
10 <script src=../media-controls.js></script>
11 17
12 <script> 18 var eventCount = 0;
19 function testMutability() {
20 eventCount++;
21 if (eventCount != 2)
22 return;
13 23
14 var testTrack; 24 // Test initial cue info.
15 var fragment; 25 assert_equals(testTrack.track.activeCues.length, 0);
16 26
17 function testMutability() 27 assert_equals(testTrack.track.cues[0].startTime, 1.0);
18 { 28 assert_equals(testTrack.track.cues[1].startTime, 3.0);
19 consoleWrite("<br>** Test initial cue info");
20 29
21 testExpected("testTrack.track.activeCues.length", 0); 30 assert_equals(testTrack.track.cues[0].text, "Lorem ipsum dolor sit amet, ");
22 testExpected("textTrackDisplayElement(video, 'display').innerText", ""); 31 var fragment = document.createDocumentFragment();
32 fragment.appendChild(document.createTextNode("Lorem ipsum dolor sit amet ,"));
33 assert_true(fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()) );
23 34
24 testExpected("testTrack.track.cues[0].startTime", 1.0); 35 // Change the start time of cue #1, it should become visible.
25 testExpected("testTrack.track.cues[1].startTime", 3.0); 36 testTrack.track.cues[0].startTime = 0;
37 assert_equals(testTrack.track.cues[0].startTime, 0);
38 assert_equals(textTrackDisplayElement(video, "display").innerText, "Lore m ipsum dolor sit amet,");
26 39
27 testExpected("testTrack.track.cues[0].text", "Lorem ipsum dolor sit amet,"); 40 // Change the cue text, getCueAsHTML() should return a new, correct frag ment.
28 fragment = document.createDocumentFragment(); 41 testTrack.track.cues[0].text = "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>s it</i> amet,";
29 fragment.appendChild(document.createTextNode("Lorem ipsum dolor sit amet,")); 42 assert_equals(testTrack.track.cues[0].text, "Lorem <b>ipsum</b> <u>dolor </u> <i.sit>sit</i> amet,");
30 testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsH TML())", true);
31 43
32 consoleWrite("<br>** Change the start time of cue #1, it should beco me visible."); 44 fragment = document.createDocumentFragment();
33 run("testTrack.track.cues[0].startTime = 0"); 45 fragment.appendChild(document.createTextNode("Lorem "));
34 testExpected("testTrack.track.cues[0].startTime", 0);
35 testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem ipsum dolor sit amet,");
36 46
37 consoleWrite("<br>** Change the cue text, getCueAsHTML() should retu rn a new, correct fragment."); 47 var bold = document.createElement("b");
38 run("testTrack.track.cues[0].text = 'Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,'"); 48 bold.appendChild(document.createTextNode("ipsum"));
39 testExpected("testTrack.track.cues[0].text", "Lorem <b>ipsum</b> <u> dolor</u> <i.sit>sit</i> amet,"); 49 fragment.appendChild(bold);
40 50
41 fragment = document.createDocumentFragment(); 51 fragment.appendChild(document.createTextNode(" "));
42 fragment.appendChild(document.createTextNode("Lorem "));
43 52
44 var bold = document.createElement("b"); 53 var underline = document.createElement("u");
45 bold.appendChild(document.createTextNode("ipsum")); 54 underline.appendChild(document.createTextNode("dolor"));
46 fragment.appendChild(bold); 55 fragment.appendChild(underline);
47 56
48 fragment.appendChild(document.createTextNode(" ")); 57 fragment.appendChild(document.createTextNode(" "));
49 58
50 var underline = document.createElement("u"); 59 var italics = document.createElement("i");
51 underline.appendChild(document.createTextNode("dolor")); 60 italics.className = "sit";
52 fragment.appendChild(underline); 61 italics.appendChild(document.createTextNode("sit"));
62 fragment.appendChild(italics);
53 63
54 fragment.appendChild(document.createTextNode(" ")); 64 fragment.appendChild(document.createTextNode(" amet,"));
55 65
56 var italics = document.createElement("i"); 66 assert_true(fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()) );
57 italics.className = "sit";
58 italics.appendChild(document.createTextNode("sit"));
59 fragment.appendChild(italics);
60 67
61 fragment.appendChild(document.createTextNode(" amet,")); 68 t.done();
69 }
62 70
63 testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsH TML())", true); 71 video.src = findMediaFile("video", "../content/counting");
64 72 });
65 consoleWrite(""); 73 </script>
66 endTest();
67 }
68
69 function loaded()
70 {
71 findMediaElement();
72 testTrack = document.querySelector('track');
73
74 waitForEventsAndCall([[video, 'canplaythrough'], [testTrack, 'load'] ], testMutability);
75
76 video.src = findMediaFile('video', '../content/counting');
77 }
78
79 </script>
80 </head>
81 <body onload="loaded()">
82 <video controls >
83 <track src="captions-webvtt/captions-gaps.vtt" kind="captions" defau lt >
84 </video>
85 <p>Test that cue text is mutable.</p>
86 </body>
87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698