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>
<script src="../../resources/js-test.js"></script>
<body>
<title>TextTrackCue exceptions are properly messaged to developers</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></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.");
function testInfinityAndNaN(property) {
shouldThrow("cue." + property + " = Number.NaN;");
shouldThrow("cue." + property + " = Number.POSITIVE_INFINITY;");
shouldThrow("cue." + property + " = Number.NEGATIVE_INFINITY;");
function testProperty(property) {
var expected_exception_msg = getExceptionMsg(property);
test(function() {
var testValues = [Number.NaN, Number.POSITIVE_INFINITY, 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);
}
testInfinityAndNaN("startTime");
testInfinityAndNaN("endTime");
testProperty("startTime");
testProperty("endTime");
</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>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<title>Adding and removing track node</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
var video = document.createElement('video');
var tracka = document.createElement('track');
video.appendChild(tracka);
var trackb = document.createElement('track');
video.appendChild(trackb);
debug("Adding tracks outside the DOM tree:");
shouldBe("video.textTracks.length", "2");
shouldBe("video.textTracks[0]", "tracka.track");
shouldBe("video.textTracks[1]", "trackb.track");
debug("Inserting the parent video element into the document.");
document.body.appendChild(video);
shouldBe("video.textTracks.length", "2");
shouldBe("video.textTracks[0]", "tracka.track");
shouldBe("video.textTracks[1]", "trackb.track");
debug("Inserting and removing another track in the document.");
var trackc = document.createElement('track');
video.appendChild(trackc);
shouldBe("video.textTracks.length", "3");
shouldBe("video.textTracks[2]", "trackc.track");
trackb.parentNode.removeChild(trackb);
shouldBe("video.textTracks.length", "2");
shouldBe("video.textTracks[0]", "tracka.track");
shouldBe("video.textTracks[1]", "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");
test(function() {
var video = document.createElement('video');
var tracka = document.createElement('track');
video.appendChild(tracka);
var trackb = document.createElement('track');
video.appendChild(trackb);
// Adding tracks outside the DOM tree.
assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
// Inserting the parent video element into the document.
document.body.appendChild(video);
assert_array_equals(video.textTracks, [tracka.track, trackb.track]);
// Inserting and removing another track in the document.
var trackc = document.createElement('track');
video.appendChild(trackc);
assert_array_equals(video.textTracks, [tracka.track, trackb.track, trackc.track]);
trackb.parentNode.removeChild(trackb);
assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
// Removing the video from the document.
document.body.removeChild(video);
assert_array_equals(video.textTracks, [tracka.track, trackc.track]);
tracka.parentNode.removeChild(tracka);
assert_array_equals(video.textTracks, [trackc.track]);
});
</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>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Verify that VTTCue exceptions are properly messaged to developers.");
var cue = new VTTCue(0, 0, "Test.");
function testPercentage(property) {
shouldThrow("cue." + property + " = -1;");
shouldThrow("cue." + property + " = 101;");
<title>VTTCue exceptions are properly messaged to developers</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function getExceptionMsg(property, value) {
return "Failed to set the '" + property
+ "' property on 'VTTCue': The value provided ("
+ value + ") is outside the range [0, 100].";
}
var cue = new VTTCue(0, 0, "Test.");
function testProperty(property, value) {
var expected_exception_msg = getExceptionMsg(property, value);
test(function() {
try {
cue[property] = value;
assert_unreached("should throw");
} catch (e) {
assert_equals(e.name, "IndexSizeError");
assert_equals(e.message, expected_exception_msg);
}
testPercentage("position");
testPercentage("size");
</script>
</body>
</html>
}, expected_exception_msg);
}
testProperty("position", -1);
testProperty("position", 101);
testProperty("size", -1);
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