Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /content-security-policy/media-src/media-src-7_3_2.sub.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<html>
<head>
<title>Video track src attribute must match src list - negative test</title>
<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline'; media-src 'self';">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Video track src attribute must match src list - negative test</h1>
<div id='log'></div>
<script>
var source_test =
async_test("Disallowed track element onerror handler fires.");
var trackURL = location.protocol + "//{{domains[www]}}:{{ports[http][0]}}/media/foo.vtt";
var t_spv = async_test("Test that securitypolicyviolation events are fired");
var test_count = 1;
window.addEventListener("securitypolicyviolation", t_spv.step_func(function(e) {
assert_equals(e.violatedDirective, "media-src");
assert_equals(e.blockedURI, trackURL);
if (--test_count <= 0) {
t_spv.done();
}
}));
function media_loaded(t) {
t.step( function () {
assert_unreached("Disllowed track source loaded.");
});
t.done();
}
function media_error_handler(t) {
t.done();
}
</script>
<video id="videoObject" width="320" height="240" controls
onerror="media_error_handler(source_test)"
crossorigin>
<source id="audioSourceObject"
type="video/webm"
src="/media/A4.webm">
<track default
id="trackObject"
kind="subtitles"
srclang="en"
label="English"
onerror="media_error_handler(source_test)"
onload="media_loaded(source_test)"
onloadeddata="media_loaded(source_test)">
</video>
<script>
document.getElementById("trackObject").src = trackURL;
source_test.step(function() {
source_test.set_status(source_test.FAIL);
});
setTimeout(function() {
if(source_test.phase != source_test.phases.COMPLETE) {
source_test.step( function () { assert_unreached("Onerror event never fired for track element."); });
source_test.done();
}
}, 2 * 1000);
</script>
</body>
</html>