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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-css-user-settings-override-author-settings.html

Issue 1882583002: 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 review comments 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 <script src=../media-file.js></script> 2 <title>Test that WebVTT objects are being styled correctly based on user setting s that should override author settings.</title>
3 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 3 <script src="../media-file.js"></script>
4 (Please avoid writing new tests using video-test.js) --> 4 <script src="../media-controls.js"></script>
5 <script src=../video-test.js></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src=../media-controls.js></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <style> 7 <style>
8 /* Author settings for the cues */ 8 /* Author settings for the cues */
9 video::cue(c) { 9 video::cue(c) {
10 color: red; 10 color: red;
11 background-color: green; 11 background-color: green;
12 text-shadow: 3px 3px #00ff00; 12 text-shadow: 3px 3px #00ff00;
13 font-size: 20px; 13 font-size: 20px;
14 font-family: arial; 14 font-family: arial;
15 font-style: normal; 15 font-style: normal;
16 font-variant: normal; 16 font-variant: normal;
17 } 17 }
18 </style> 18 </style>
19 <script>
20
21 function applyUserOverrideSettings() {
22 if (window.internals) {
23 internals.settings.setTextTrackTextColor("cyan");
24 internals.settings.setTextTrackBackgroundColor("green");
25 internals.settings.setTextTrackTextShadow("2px 2px #ff0000")
26 internals.settings.setTextTrackTextSize("14px");
27 internals.settings.setTextTrackFontFamily("fantasy");
28 internals.settings.setTextTrackFontStyle("italic");
29 internals.settings.setTextTrackFontVariant("small-caps");
30 }
31 }
32
33 function verifyAuthorSettings() {
34 consoleWrite("");
35 cue = textTrackDisplayElement(video, 'cue').firstElementChild;
36 testExpected("getComputedStyle(cue).color", "rgb(255, 0, 0)");
37 testExpected("getComputedStyle(cue).backgroundColor", "rgb(0, 128, 0)");
38 testExpected("getComputedStyle(cue).textShadow", "rgb(0, 255, 0) 3px 3px 0px");
39 testExpected("getComputedStyle(cue).fontSize", "20px");
40 testExpected("getComputedStyle(cue).fontFamily", "arial");
41 testExpected("getComputedStyle(cue).fontStyle", "normal");
42 testExpected("getComputedStyle(cue).fontVariant", "normal");
43 // Apply user settings and verify they override author-specified setting s
44 applyUserOverrideSettings();
45 run("video.currentTime = 0.3");
46 verifyUserOverrideSettings();
47 }
48
49 function verifyUserOverrideSettings() {
50 consoleWrite("");
51 cue = textTrackDisplayElement(video, 'cue').firstElementChild;
52 testExpected("getComputedStyle(cue).color", "rgb(0, 255, 255)");
53 testExpected("getComputedStyle(cue).backgroundColor", "rgb(0, 128, 0)");
54 testExpected("getComputedStyle(cue).textShadow", "rgb(255, 0, 0) 2px 2px 0px");
55 testExpected("getComputedStyle(cue).fontSize", "14px");
56 testExpected("getComputedStyle(cue).fontFamily", "fantasy");
57 testExpected("getComputedStyle(cue).fontStyle", "italic");
58 testExpected("getComputedStyle(cue).fontVariant", "small-caps");
59 endTest();
60 }
61
62 window.onload = function() {
63 consoleWrite("Test that WebVTT objects are being styled correctly based on user settings that should override author settings.");
64 findMediaElement();
65 video.src = findMediaFile('video', '../content/test');
66 video.currentTime = 0.1;
67 waitForEvent('canplaythrough', verifyAuthorSettings);
68 }
69
70 </script>
71 <video> 19 <video>
72 <track src="captions-webvtt/styling.vtt" kind="captions" default> 20 <track src="captions-webvtt/styling.vtt" kind="captions" default>
73 </video> 21 </video>
22 <script>
23 async_test(function(t) {
24 var video = document.querySelector("video");
25 video.src = findMediaFile("video", "../content/test");
26
27 video.oncanplaythrough = t.step_func_done(function() {
28 var cue = textTrackDisplayElement(video, "cue").firstElementChild;
29 var cueStyle = getComputedStyle(cue);
30 assert_equals(cueStyle.color, "rgb(255, 0, 0)");
31 assert_equals(cueStyle.backgroundColor, "rgb(0, 128, 0)");
32 assert_equals(cueStyle.textShadow, "rgb(0, 255, 0) 3px 3px 0px");
33 assert_equals(cueStyle.fontSize, "20px");
34 assert_equals(cueStyle.fontFamily, "arial");
35 assert_equals(cueStyle.fontStyle, "normal");
36 assert_equals(cueStyle.fontVariant, "normal");
37
38 // Apply user settings and verify they override author-specified setting s
39 internals.settings.setTextTrackTextColor("cyan");
40 internals.settings.setTextTrackBackgroundColor("green");
41 internals.settings.setTextTrackTextShadow("2px 2px #ff0000")
42 internals.settings.setTextTrackTextSize("14px");
43 internals.settings.setTextTrackFontFamily("fantasy");
44 internals.settings.setTextTrackFontStyle("italic");
45 internals.settings.setTextTrackFontVariant("small-caps");
46
47 video.currentTime = 0.3;
48
49 cue = textTrackDisplayElement(video, "cue").firstElementChild;
50 cueStyle = getComputedStyle(cue);
51 assert_equals(cueStyle.color, "rgb(0, 255, 255)");
52 assert_equals(cueStyle.backgroundColor, "rgb(0, 128, 0)");
53 assert_equals(cueStyle.textShadow, "rgb(255, 0, 0) 2px 2px 0px");
54 assert_equals(cueStyle.fontSize, "14px");
55 assert_equals(cueStyle.fontFamily, "fantasy");
56 assert_equals(cueStyle.fontStyle, "italic");
57 assert_equals(cueStyle.fontVariant, "small-caps");
58 });
59 });
60 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698