Bug 1562353 - add CORS test. r=jya

This test is used to ensure that we shouldn't load CORS resource if server doesn't respond with correct CORS header.

In this situation, loading should be expected to fail.

Differential Revision: https://phabricator.services.mozilla.com/D36513

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-07-01 23:54:49 +00:00
parent c204891751
commit 01bd4dbcc7
2 changed files with 45 additions and 0 deletions

View file

@ -1222,6 +1222,10 @@ tags = webvtt
support-files =
../../canvas/test/crossorigin/video.sjs
tags = webvtt
[test_testtrack_cors_no_response.html]
support-files =
../../canvas/test/crossorigin/video.sjs
tags = webvtt
[test_texttrackcue.html]
skip-if = android_version == '17' || android_version == '22' # android(bug 1368010, bug 1372457)
tags = webvtt

View file

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Should not load CORS vtt file when server doesn't respond with correct CORS header</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="manifest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video preload="none" crossorigin="anonymous">
<track src="http://example.com/tests/dom/media/test/video.sjs?name=tests/dom/media/test/basic.vtt&type=text/vtt" kind="subtitles" id="default" default>
</video>
<script type="text/javascript">
/**
* This test is used to ensure that we shouldn't load CORS resource if server
* doesn't respond with correct CORS header. In this situation, loading should
* be expected to fail.
*/
async function runTest() {
await waitUntiTrackLoadError();
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
runTest();
/**
* The following are test helper functions.
*/
async function waitUntiTrackLoadError() {
const trackElement = document.getElementById("default");
if (trackElement.readyState != 3) {
info(`wait until receiving error event`);
await once(trackElement, "error");
}
is(trackElement.readyState, 3, "Track::ReadyState should be set to ERROR.");
is(trackElement.track.cues.length, 0, "Cue list length should be 0.");
}
</script>
</body>
</html>