зеркало из https://github.com/mozilla/gecko-dev.git
62 строки
1.9 KiB
HTML
62 строки
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<meta http-equiv="Content-Security-Policy" content="connect-src 'self'">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
async_test(t => {
|
|
var errorEvent = false;
|
|
var cspEvent = false;
|
|
|
|
var es = new EventSource("http://{{domains[www]}}:{{ports[http][0]}}/common/text-plain.txt");
|
|
es.onerror = t.step_func(e => {
|
|
assert_equals(es.readyState, EventSource.CLOSED);
|
|
|
|
assert_false(errorEvent);
|
|
errorEvent = true;
|
|
if (cspEvent)
|
|
t.done();
|
|
});
|
|
|
|
document.addEventListener("securitypolicyviolation", t.step_func(e => {
|
|
if (e.blockedURI != "http://{{domains[www]}}:{{ports[http][0]}}/common/text-plain.txt")
|
|
return;
|
|
|
|
assert_equals(es.readyState, EventSource.CLOSED);
|
|
assert_equals(e.violatedDirective, "connect-src");
|
|
|
|
assert_false(cspEvent);
|
|
cspEvent = true;
|
|
if (errorEvent)
|
|
t.done();
|
|
}));
|
|
}, "EventSource should fire onerror.");
|
|
|
|
async_test(t => {
|
|
var errorEvent = false;
|
|
var cspEvent = false;
|
|
|
|
var es = new EventSource("http://{{domains[www]}}:{{ports[http][0]}}/common/text-plain.txt");
|
|
es.onerror = t.step_func(e => {
|
|
assert_equals(es.readyState, EventSource.CLOSED);
|
|
|
|
assert_false(errorEvent);
|
|
errorEvent = true;
|
|
if (cspEvent)
|
|
t.done();
|
|
});
|
|
|
|
document.addEventListener("securitypolicyviolation", t.step_func(e => {
|
|
if (e.blockedURI != "http://{{domains[www]}}:{{ports[http][0]}}/common/text-plain.txt")
|
|
return;
|
|
|
|
assert_equals(es.readyState, EventSource.CLOSED);
|
|
assert_equals(e.violatedDirective, "connect-src");
|
|
|
|
assert_false(cspEvent);
|
|
cspEvent = true;
|
|
if (errorEvent)
|
|
t.done();
|
|
}));
|
|
}, "EventSource should fire onerror.");
|
|
|