Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-kind.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-kind.html b/third_party/WebKit/LayoutTests/media/track/track-kind.html |
| index 8a223601af5585273b4caf18158c2f5f35f8ed4f..fa83f2d18dba80a12621bc5cb6231d85b8cf22d9 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-kind.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-kind.html |
| @@ -1,89 +1,85 @@ |
| <!DOCTYPE html> |
| -<html> |
| - <head> |
| +<title>Tests that the "kind" attribute is set properly and that cues are only visible when "kind" is set to "captions" or "subtitles".</title> |
| +<video> |
| + <track src="captions-webvtt/metadata.vtt" default> |
| +</video> |
| +<script src="../media-file.js"></script> |
| +<script src="../media-controls.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script> |
| +async_test(function(t) { |
| + var video = document.querySelector("video"); |
| + var trackElement = document.querySelector("track"); |
| - <script src=../media-file.js></script> |
| - <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| - (Please avoid writing new tests using video-test.js) --> |
| - <script src=../video-test.js></script> |
| - <script src=../media-controls.js></script> |
| - <script> |
| + video.oncanplaythrough = t.step_func(testKind); |
| + trackElement.onload = t.step_func(testKind); |
| + |
| + video.src = findMediaFile("video", "../content/counting"); |
| - var trackElement; |
| - function setKind(value) |
| - { |
| - consoleWrite("<b>++ '" + value + "'</b>"); |
| - consoleWrite("<b> set via DOM</b>"); |
| - run("trackElement.removeAttribute('kind')"); |
| - run("trackElement.kind = '" + value + "'"); |
| - testExpected("trackElement.getAttribute('kind')", value); |
| - testExpected("trackElement.kind", value); |
| - testExpected("trackElement.track.kind", value); |
| - consoleWrite("<b> and via attribute</b>"); |
| - run("trackElement.removeAttribute('kind')"); |
| - run("trackElement.setAttribute('kind', '" + value + "')"); |
| - testExpected("trackElement.kind", value); |
| - testExpected("trackElement.track.kind", value); |
| - testExpected("trackElement.getAttribute('kind')", value); |
| - testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem ipsum dolor sit amet, "); |
| - consoleWrite(""); |
| + var eventCount = 0; |
| + function testKind() { |
| + eventCount++; |
| + if (eventCount != 2) |
| + return; |
| - } |
| + // Test default attribute value. |
| + assert_equals(trackElement.getAttribute("kind"), null); |
| + assert_equals(trackElement.kind, "subtitles"); |
| + assert_equals(video.textTracks[0].kind, "subtitles"); |
| - function testKind() |
| - { |
| - consoleWrite("<b>++ Test default attribute value</b>"); |
| - testExpected("trackElement.getAttribute('kind')", null); |
| - testExpected("trackElement.kind", "subtitles"); |
| - testExpected("video.textTracks[0].kind", "subtitles"); |
| - consoleWrite(""); |
| + // Set to bogus value, should return default. |
| + |
| + // Set via DOM. |
| + var value = "english-metadata" |
| + trackElement.removeAttribute("kind"); |
| + trackElement.kind = value; |
| + assert_equals(trackElement.getAttribute("kind"), value); |
| + assert_equals(trackElement.kind, "subtitles"); |
| + assert_equals(trackElement.track.kind, "subtitles"); |
| + |
| + // Set via attribute. |
| + trackElement.removeAttribute("kind"); |
| + trackElement.setAttribute("kind", value); |
| + assert_equals(trackElement.kind, "subtitles"); |
| + assert_equals(trackElement.track.kind, "subtitles"); |
| + assert_equals(trackElement.getAttribute("kind"), value); |
| - consoleWrite("<b>*** Set to bogus value, should return default</b>"); |
| - consoleWrite("<b> set via DOM</b>"); |
| - var value = "english-metadata" |
| - run("trackElement.removeAttribute('kind')"); |
| - run("trackElement.kind = '" + value + "'"); |
| - testExpected("trackElement.getAttribute('kind')", value); |
| - testExpected("trackElement.kind", "subtitles"); |
| - testExpected("trackElement.track.kind", "subtitles"); |
| - consoleWrite("<b> and via attribute</b>"); |
| - run("trackElement.removeAttribute('kind')"); |
| - run("trackElement.setAttribute('kind', '" + value + "')"); |
| - testExpected("trackElement.kind", "subtitles"); |
| - testExpected("trackElement.track.kind", "subtitles"); |
| - testExpected("trackElement.getAttribute('kind')", value); |
| - consoleWrite(""); |
| + // Set to known values. |
| + setKind("subtitles", true); |
| - consoleWrite("<b>*** Set to known values</b>"); |
| - setKind("subtitles"); |
| + setKind("captions", true); |
| - setKind("captions"); |
| + setKind("descriptions", false); |
| - setKind("descriptions"); |
| + setKind("chapters", false); |
| - setKind("chapters"); |
| + setKind("metadata", false); |
| - setKind("metadata"); |
| + t.done(); |
| + } |
| - endTest(); |
| - } |
| + function setKind(value, cueIsVisible) { |
|
mlamouri (slow - plz ping)
2016/05/04 13:59:58
Can you call thisk "setKindAndCheck()"
|
| + // set via DOM. |
| + trackElement.removeAttribute("kind"); |
| + trackElement.kind = value; |
| + assert_equals(trackElement.getAttribute("kind"), value); |
| + assert_equals(trackElement.kind, value); |
| + assert_equals(trackElement.track.kind, value); |
| + // Set via attribute. |
| + trackElement.removeAttribute("kind"); |
| + trackElement.setAttribute("kind", value); |
| + assert_equals(trackElement.kind, value); |
| + assert_equals(trackElement.track.kind, value); |
| + assert_equals(trackElement.getAttribute("kind"), value); |
| - function loaded() |
| - { |
| - findMediaElement(); |
| - trackElement = document.getElementById('track_1'); |
| - |
| - waitForEventsAndCall([[video, 'canplaythrough'], [trackElement, 'load']], testKind); |
| - |
| - video.src = findMediaFile('video', '../content/counting'); |
| - } |
| - |
| - </script> |
| - </head> |
| - <body onload="loaded()"> |
| - <p>Tests that the 'kind' attribute is set properly and that cues are only visible when 'kind' is set to 'captions' or 'subtitles'.</p> |
| - <video> |
| - <track id=track_1 src="captions-webvtt/metadata.vtt" default> |
| - </video> |
| - </body> |
| -</html> |
| + if (cueIsVisible) { |
| + assert_equals(textTrackDisplayElement(video, "display").innerText, "Lorem ipsum dolor sit amet, "); |
| + } else { |
| + assert_throws(null, function() { |
| + textTrackDisplayElement(video, "display"); |
| + }); |
| + } |
| + } |
| +}); |
| +</script> |