Commit c2009a32 authored by Sriram's avatar Sriram Committed by Commit Bot

Convert track tests to testharness based.

Convert track tests that are using js-test.js to use testharness.js
instead. This will enable to upstream these tests to wpt tests.

Bug: 782555
Change-Id: I6f1541cbe756cda8966ce47b3a93152e14d7e722
Reviewed-on: https://chromium-review.googlesource.com/806254Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
Cr-Commit-Position: refs/heads/master@{#521376}
parent 0f71661c
Verify that TextTrackCue exceptions are properly messaged to developers.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS cue.startTime = Number.NaN; threw exception TypeError: Failed to set the 'startTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS cue.startTime = Number.POSITIVE_INFINITY; threw exception TypeError: Failed to set the 'startTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS cue.startTime = Number.NEGATIVE_INFINITY; threw exception TypeError: Failed to set the 'startTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS cue.endTime = Number.NaN; threw exception TypeError: Failed to set the 'endTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS cue.endTime = Number.POSITIVE_INFINITY; threw exception TypeError: Failed to set the 'endTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS cue.endTime = Number.NEGATIVE_INFINITY; threw exception TypeError: Failed to set the 'endTime' property on 'TextTrackCue': The provided double value is non-finite..
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../resources/js-test.js"></script> <title>TextTrackCue exceptions are properly messaged to developers</title>
<body> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script> <script>
description("Verify that TextTrackCue exceptions are properly messaged to developers."); function getExceptionMsg(property) {
return "Failed to set the '" + property
+ "' property on 'TextTrackCue': The provided double value is non-finite.";
}
var cue = new VTTCue(0, 0, "Test."); var cue = new VTTCue(0, 0, "Test.");
function testProperty(property) {
function testInfinityAndNaN(property) { var expected_exception_msg = getExceptionMsg(property);
shouldThrow("cue." + property + " = Number.NaN;"); test(function() {
shouldThrow("cue." + property + " = Number.POSITIVE_INFINITY;"); var testValues = [Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
shouldThrow("cue." + property + " = Number.NEGATIVE_INFINITY;"); testValues.forEach(function(value) {
try {
cue[property] = value;
assert_unreached("should throw");
} catch (e) {
assert_equals(e.name, "TypeError");
assert_equals(e.message, expected_exception_msg);
}
});
}, expected_exception_msg);
} }
testProperty("startTime");
testInfinityAndNaN("startTime"); testProperty("endTime");
testInfinityAndNaN("endTime");
</script> </script>
Adding tracks outside the DOM tree:
PASS video.textTracks.length is 2
PASS video.textTracks[0] is tracka.track
PASS video.textTracks[1] is trackb.track
Inserting the parent video element into the document.
PASS video.textTracks.length is 2
PASS video.textTracks[0] is tracka.track
PASS video.textTracks[1] is trackb.track
Inserting and removing another track in the document.
PASS video.textTracks.length is 3
PASS video.textTracks[2] is trackc.track
PASS video.textTracks.length is 2
PASS video.textTracks[0] is tracka.track
PASS video.textTracks[1] is trackc.track
Removing the video from the document.
PASS video.textTracks.length is 2
PASS video.textTracks[0] is tracka.track
PASS video.textTracks[1] is trackc.track
PASS video.textTracks.length is 1
PASS video.textTracks[0] is trackc.track
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html> <!DOCTYPE html>
<html> <title>Adding and removing track node</title>
<head> <script src="../../resources/testharness.js"></script>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharnessreport.js"></script>
</head>
<body> <body>
<script> <script>
var video = document.createElement('video'); test(function() {
var video = document.createElement('video');
var tracka = document.createElement('track'); var tracka = document.createElement('track');
video.appendChild(tracka); video.appendChild(tracka);
var trackb = document.createElement('track'); var trackb = document.createElement('track');
video.appendChild(trackb); video.appendChild(trackb);
debug("Adding tracks outside the DOM tree:"); // Adding tracks outside the DOM tree.
shouldBe("video.textTracks.length", "2"); assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
shouldBe("video.textTracks[0]", "tracka.track");
shouldBe("video.textTracks[1]", "trackb.track"); // Inserting the parent video element into the document.
document.body.appendChild(video);
debug("Inserting the parent video element into the document."); assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
document.body.appendChild(video);
shouldBe("video.textTracks.length", "2"); // Inserting and removing another track in the document.
shouldBe("video.textTracks[0]", "tracka.track"); var trackc = document.createElement('track');
shouldBe("video.textTracks[1]", "trackb.track"); video.appendChild(trackc);
assert_array_equals(video.textTracks, [tracka.track, trackb.track, trackc.track]);
debug("Inserting and removing another track in the document.");
var trackc = document.createElement('track'); trackb.parentNode.removeChild(trackb);
video.appendChild(trackc); assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
shouldBe("video.textTracks.length", "3");
shouldBe("video.textTracks[2]", "trackc.track"); // Removing the video from the document.
document.body.removeChild(video);
trackb.parentNode.removeChild(trackb); assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
shouldBe("video.textTracks.length", "2");
shouldBe("video.textTracks[0]", "tracka.track"); tracka.parentNode.removeChild(tracka);
shouldBe("video.textTracks[1]", "trackc.track"); assert_array_equals(video.textTracks, [trackc.track]);
});
debug("Removing the video from the document.");
document.body.removeChild(video);
shouldBe("video.textTracks.length", "2");
shouldBe("video.textTracks[0]", "tracka.track");
shouldBe("video.textTracks[1]", "trackc.track");
tracka.parentNode.removeChild(tracka);
shouldBe("video.textTracks.length", "1");
shouldBe("video.textTracks[0]", "trackc.track");
</script> </script>
</body>
</html>
Verify that VTTCue exceptions are properly messaged to developers.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS cue.position = -1; threw exception IndexSizeError: Failed to set the 'position' property on 'VTTCue': The value provided (-1) is outside the range [0, 100]..
PASS cue.position = 101; threw exception IndexSizeError: Failed to set the 'position' property on 'VTTCue': The value provided (101) is outside the range [0, 100]..
PASS cue.size = -1; threw exception IndexSizeError: Failed to set the 'size' property on 'VTTCue': The value provided (-1) is outside the range [0, 100]..
PASS cue.size = 101; threw exception IndexSizeError: Failed to set the 'size' property on 'VTTCue': The value provided (101) is outside the range [0, 100]..
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html> <!DOCTYPE html>
<html> <title>VTTCue exceptions are properly messaged to developers</title>
<head> <script src="../../resources/testharness.js"></script>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharnessreport.js"></script>
</head> <script>
<body> function getExceptionMsg(property, value) {
<script> return "Failed to set the '" + property
description("Verify that VTTCue exceptions are properly messaged to developers."); + "' property on 'VTTCue': The value provided ("
+ value + ") is outside the range [0, 100].";
var cue = new VTTCue(0, 0, "Test."); }
var cue = new VTTCue(0, 0, "Test.");
function testPercentage(property) { function testProperty(property, value) {
shouldThrow("cue." + property + " = -1;"); var expected_exception_msg = getExceptionMsg(property, value);
shouldThrow("cue." + property + " = 101;"); test(function() {
try {
cue[property] = value;
assert_unreached("should throw");
} catch (e) {
assert_equals(e.name, "IndexSizeError");
assert_equals(e.message, expected_exception_msg);
} }
}, expected_exception_msg);
testPercentage("position"); }
testPercentage("size"); testProperty("position", -1);
</script> testProperty("position", 101);
</body> testProperty("size", -1);
</html> testProperty("size", 101);
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment