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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-mutable-fragment.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 fragment 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="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <style>
7 p, div { display: none; }
8 </style>
9 <video>
10 <track src="captions-webvtt/captions-html.vtt" kind="captions" default >
11 </video>
12 <p>Fragment 1</p>
13 <div></div>
5 14
6 <script src=../media-file.js></script> 15 <p>Fragment 2</p>
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 16 <div></div>
8 (Please avoid writing new tests using video-test.js) --> 17 <script>
9 <script src=../video-test.js></script> 18 async_test(function(t) {
10 <script src=../media-controls.js></script> 19 var video = document.querySelector("video");
20 var testTrack = document.querySelector("track");
11 21
12 <script> 22 video.oncanplaythrough = t.step_func(testMutability);
23 testTrack.onload = t.step_func(testMutability);
13 24
14 var testTrack; 25 var fragment;
15 var testCue; 26 var eventCount = 0;
16 var fragment; 27 function testMutability() {
28 eventCount++;
29 if (eventCount != 2)
30 return;
17 31
18 function createExpectedFragment(rootNode) 32 var testCue = testTrack.track.cues[0];
19 {
20 fragment = rootNode;
21 fragment.appendChild(document.createTextNode("Lorem "));
22 33
23 var bold = document.createElement("b"); 34 // Test initial cue contents.
24 bold.appendChild(document.createTextNode("ipsum")); 35 assert_equals(testCue.text, "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit< /i> amet,");
25 fragment.appendChild(bold);
26 36
27 fragment.appendChild(document.createTextNode(" ")); 37 // Cue getCueAsHTML() should return a correct fragment.
38 createExpectedFragment(document.createDocumentFragment());
39 assert_true(fragment.isEqualNode(testCue.getCueAsHTML()));
28 40
29 var underline = document.createElement("u"); 41 // Appending getCuesAsHTML() twice to the DOM should be succesful.
30 underline.appendChild(document.createTextNode("dolor")); 42 document.getElementsByTagName("div")[0].appendChild(testCue.getCueAsHTML ());
31 fragment.appendChild(underline); 43 document.getElementsByTagName("div")[1].appendChild(testCue.getCueAsHTML ());
32 44
33 fragment.appendChild(document.createTextNode(" ")); 45 createExpectedFragment(document.createElement("div"));
46 assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[0] ));
47 assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[1] ));
34 48
35 var italics = document.createElement("i"); 49 // The fragment returned by getCuesAsHTML() should be independently muta ble.
36 italics.className = "sit"; 50 document.getElementsByTagName("div")[0].firstChild.textContent = "Differ ent text ";
37 italics.appendChild(document.createTextNode("sit")); 51 assert_false(fragment.isEqualNode(document.getElementsByTagName("div")[0 ]));
38 fragment.appendChild(italics); 52 assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[1] ));
39 53
40 fragment.appendChild(document.createTextNode(" amet,")); 54 // Calling twice getCueAsHTML() should not return the same fragment.
41 } 55 assert_not_equals(testCue.getCueAsHTML(), testCue.getCueAsHTML());
42 56
43 function testMutability() 57 t.done();
44 { 58 }
45 run("testCue = testTrack.track.cues[0]");
46 59
47 consoleWrite("<br>** Test initial cue contents"); 60 function createExpectedFragment(rootNode) {
48 testExpected("testCue.text", "Lorem <b>ipsum</b> <u>dolor</u> <i.sit >sit</i> amet,"); 61 fragment = rootNode;
62 fragment.appendChild(document.createTextNode("Lorem "));
49 63
50 consoleWrite("<br>** Cue getCueAsHTML() should return a correct frag ment"); 64 var bold = document.createElement("b");
51 createExpectedFragment(document.createDocumentFragment()); 65 bold.appendChild(document.createTextNode("ipsum"));
52 testExpected("fragment.isEqualNode(testCue.getCueAsHTML())", true); 66 fragment.appendChild(bold);
53 67
54 consoleWrite("<br>** Appending getCuesAsHTML() twice to the DOM shou ld be succesful"); 68 fragment.appendChild(document.createTextNode(" "));
55 run("document.getElementsByTagName('div')[0].appendChild(testCue.get CueAsHTML())");
56 run("document.getElementsByTagName('div')[1].appendChild(testCue.get CueAsHTML())");
57 69
58 createExpectedFragment(document.createElement('div')); 70 var underline = document.createElement("u");
59 testExpected("fragment.isEqualNode(document.getElementsByTagName('di v')[0])", true); 71 underline.appendChild(document.createTextNode("dolor"));
60 testExpected("fragment.isEqualNode(document.getElementsByTagName('di v')[1])", true); 72 fragment.appendChild(underline);
61 73
62 consoleWrite("<br>** The fragment returned by getCuesAsHTML() should be independently mutable"); 74 fragment.appendChild(document.createTextNode(" "));
63 run("document.getElementsByTagName('div')[0].firstChild.textContent = 'Different text '");
64 testExpected("fragment.isEqualNode(document.getElementsByTagName('di v')[0])", false);
65 testExpected("fragment.isEqualNode(document.getElementsByTagName('di v')[1])", true);
66 75
67 consoleWrite("<br>** Calling twice getCueAsHTML() should not return the same fragment"); 76 var italics = document.createElement("i");
68 testExpected("testCue.getCueAsHTML() == testCue.getCueAsHTML()", fal se); 77 italics.className = "sit";
78 italics.appendChild(document.createTextNode("sit"));
79 fragment.appendChild(italics);
69 80
70 consoleWrite(""); 81 fragment.appendChild(document.createTextNode(" amet,"));
71 endTest(); 82 }
72 }
73 83
74 function loaded() 84 video.src = findMediaFile("video", "../content/counting");
75 { 85 });
76 findMediaElement(); 86 </script>
77 testTrack = document.querySelector('track');
78
79 waitForEventsAndCall([[video, 'canplaythrough'], [testTrack, 'load'] ], testMutability);
80
81 video.src = findMediaFile('video', '../content/counting');
82 }
83
84 </script>
85 </head>
86 <body onload="loaded()">
87 <video controls >
88 <track src="captions-webvtt/captions-html.vtt" kind="captions" defau lt >
89 </video>
90 <p>Test that cue text is mutable.</p>
91
92 <p>Fragment 1</p>
93 <div></div>
94
95 <p>Fragment 2</p>
96 <div></div>
97 </body>
98 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698