gecko-dev/testing/web-platform/tests/content-security-policy/style-src/style-src-inline-style-nonce-blocked.html
Andy Paicu 96c97d4aa0 Bug 1487661 [wpt PR 12776] - Implement script and style attr/elem CSP directives, a=testonly
Automatic update from web-platform-testsImplement script and style attr/elem CSP directives

The functionality is behind the
ContentSecurityPolicyExperimentalFeaturesEnabled flag

I2IS: Coming Soon

Spec:
https://w3c.github.io/webappsec-csp/#directive-script-src-elem
https://w3c.github.io/webappsec-csp/#directive-script-src-attr
https://w3c.github.io/webappsec-csp/#directive-style-src-elem
https://w3c.github.io/webappsec-csp/#directive-style-src-attr

Change-Id: Ic1638cac15c7ec488fcc7a4c9f6261b97502090a
Reviewed-on: https://chromium-review.googlesource.com/1181050
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588534}

--

wpt-commits: 412054bbdecd4ba26ae93ae83b2bfe3c66852948
wpt-pr: 12776
2018-09-10 10:12:09 +00:00

38 lines
1.1 KiB
HTML

<!doctype html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="style-src 'self' 'nonce-nonceynonce'">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test("Should not load inline style element with invalid nonce");
var t_spv = async_test("Should fire a securitypolicyviolation event");
document.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) {
assert_equals("style-src-elem", e.violatedDirective);
}));
</script>
<style nonce="not-nonceynonce">
#content {
margin-left: 2px;
}
</style>
</head>
<body>
<div id='log'></div>
<div id="content">Lorem ipsum</div>
<script>
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
t.done();
});
</script>
</body>
</html>