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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-rendering-rtl.html

Issue 1913423002: 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, 7 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 directionality is set correctly on cues.</title>
3 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../media-file.js"></script>
5 <script src="../media-controls.js"></script>
6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script>
8 <video>
9 <track src="captions-webvtt/captions-rtl.vtt" kind="captions" default>
10 </video>
11 <script>
12 async_test(function(t) {
13 var testTrack = document.querySelector("track");
14 var video = document.querySelector("video");
15 video.src = findMediaFile("video", "../content/test");
5 16
6 <script src=../media-file.js></script> 17 var seekedCount = 0;
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 18 var info = ["تجربة",
8 (Please avoid writing new tests using video-test.js) --> 19 "\t1234",
9 <script src=../video-test.js></script> 20 "تجربة\nLTR new line, but cue should be RTL",
10 <script src=../media-controls.js></script> 21 "LTR cue تجربة",
22 ";1234تجربة",
23 "\t०१२३४५६७८९ \t",
24 "𐡘 (Imperial Aramaic number one, U+10858) strong RTL, non-BMP",
25 "𝅘𝅥 (Musical symbol quarter note, U+1D15F) strong LTR, non-BMP",
26 "<ruby><rt>𝅘𝅥</rt>تجربة</ruby>",
27 "<ruby>1234<rt>تجربة</rt></ruby>"];
11 28
12 <script> 29 // RTL cues alternate with LTR cues.
30 video.onseeked = t.step_func(function() {
31 var testCueDisplayBox = textTrackDisplayElement(video, "display");
13 32
14 var testTrack; 33 // Jump to next cue.
15 var testCueDisplayBox; 34 assert_equals(video.currentTime, (seekedCount / 2) + 0.25);
16 var seekedCount = 0; 35 assert_equals(testTrack.track.activeCues.length, 1);
17 var direction; 36 assert_equals(testTrack.track.activeCues[0].text, info[seekedCount]);
37 assert_equals(testCueDisplayBox.innerText, info[seekedCount].replace(/<[ ^>]+>/g, ""));
18 38
19 var info = ["تجربة", 39 var direction = seekedCount % 2 ? "ltr" : "rtl";
20 "\t1234",
21 "تجربة\nLTR new line, but cue should be RTL",
22 "LTR cue تجربة",
23 ";1234تجربة",
24 "\t०१२३४५६७८९ \t",
25 "𐡘 (Imperial Aramaic number one, U+10858) strong RTL, non-BM P",
26 "𝅘𝅥 (Musical symbol quarter note, U+1D15F) strong LTR, non-BM P",
27 "<ruby><rt>𝅘𝅥</rt>تجربة</ruby>",
28 "<ruby>1234<rt>تجربة</rt></ruby>"];
29 40
30 function testCueStyle() 41 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC ueDisplayBox.offsetWidth);
31 {
32 endTest();
33 }
34 42
35 function seeked() 43 assert_equals(getComputedStyle(testCueDisplayBox).direction, direction);
36 {
37 testCueDisplayBox = textTrackDisplayElement(video, 'display');
38 44
39 consoleWrite(""); 45 if (++seekedCount == info.length)
40 consoleWrite("** Jump to next cue **"); 46 t.done();
41 testExpected("video.currentTime", (seekedCount / 2) + .25); 47 else
42 testExpected("testTrack.track.activeCues.length", 1); 48 video.currentTime += 0.5;
43 testExpected("testTrack.track.activeCues[0].text", info[seekedCount] ); 49 });
44 testExpected("testCueDisplayBox.innerText", info[seekedCount].replac e(/<[^>]+>/g, ""));
45 50
46 direction = seekedCount % 2 ? "ltr" : "rtl"; 51 video.currentTime = 0.25;
47 52 });
48 consoleWrite(""); 53 </script>
49 consoleWrite("** The position should be default and CSS direction se t to " + direction + " **");
50 testExpected("2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth", true);
51
52 testExpected("getComputedStyle(testCueDisplayBox).direction", direct ion);
53
54 if (++seekedCount == info.length)
55 endTest();
56 else {
57 consoleWrite("");
58 run("video.currentTime = " + (video.currentTime + .5));
59 return;
60 }
61 }
62
63 function loaded()
64 {
65 consoleWrite("Test that directionality is set correctly on cues.");
66 testTrack = document.querySelector('track');
67
68 findMediaElement();
69 video.src = findMediaFile('video', '../content/test');
70
71 consoleWrite("");
72 consoleWrite("** RTL cues alternate with LTR cues **");
73 waitForEvent('seeked', seeked);
74 waitForEventOnce('canplaythrough', function() { video.currentTime = .25; });
75 }
76 </script>
77 </head>
78 <body onload="loaded()">
79 <video controls >
80 <track src="captions-webvtt/captions-rtl.vtt" kind="captions" defaul t>
81 </video>
82 </body>
83 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698