diff options
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/style-src')
11 files changed, 151 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/style-src/3_3.css b/testing/web-platform/tests/content-security-policy/style-src/3_3.css new file mode 100644 index 000000000..8086244b2 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/3_3.css @@ -0,0 +1 @@ +#content {margin-left: 2px;}
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html new file mode 100644 index 000000000..6c4c1a320 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html @@ -0,0 +1,33 @@ +<!doctype html> +<html> +<head> + <title></title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <style> + /* none of this should be applied */ + #log { + margin-left: 200px; + } + </style> +</head> +<body> + <h1> + Inline style should not be applied + without unsafe-inline directive + </h1> + <div id='log'></div> + + <script> + test(function() { + var logEl = document.getElementById("log"); + var marginLeftVal = getComputedStyle(logEl).getPropertyValue('margin-left'); + assert_false(marginLeftVal == "200px")}, + "Inline style should not be applied" + ); + </script> + + <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=style-src%20%27self%27'></script> +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html.sub.headers b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html.sub.headers new file mode 100644 index 000000000..c550a46c2 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_1.html.sub.headers @@ -0,0 +1,6 @@ +Expires: Mon, 26 Jul 1997 05:00:00 GMT +Cache-Control: no-store, no-cache, must-revalidate +Cache-Control: post-check=0, pre-check=0, false +Pragma: no-cache +Set-Cookie: style-src-3_1={{$id:uuid()}}; Path=/content-security-policy/style-src/ +Content-Security-Policy: style-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html new file mode 100644 index 000000000..ce904d96b --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html @@ -0,0 +1,25 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Inline style attributes should not be applied without 'unsafe-inline' style-src directive.</title> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + <script> + onload = function() { + test(function() { + var text = document.getElementById("content"); + assert_true(getComputedStyle(text).marginLeft != "2px", "Inline style attribute should not be applied to text"); + }); + } + </script> +</head> +<body> + <h1>Inline style attributes should not be applied without 'unsafe-inline' style-src directive.</h1> + <div id='log'></div> + + <div id="content" style="margin-left: 2px">This text should not have a margin-left of 2</div> + + <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=style-src%20%27self%27'></script> + +</body> +</html> diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html.sub.headers b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html.sub.headers new file mode 100644 index 000000000..3343ccee9 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_2.html.sub.headers @@ -0,0 +1,6 @@ +Expires: Mon, 26 Jul 1997 05:00:00 GMT +Cache-Control: no-store, no-cache, must-revalidate +Cache-Control: post-check=0, pre-check=0, false +Pragma: no-cache +Set-Cookie: style-src-3_2={{$id:uuid()}}; Path=/content-security-policy/style-src/ +Content-Security-Policy: script-src 'self' 'unsafe-inline'; style-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html new file mode 100644 index 000000000..d836b351c --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>href of link with rel=stylesheet must be in src list</title> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + <script> + var head = document.getElementsByTagName('head')[0]; + var link = document.createElement('link'); + link.setAttribute('rel', 'stylesheet'); + link.setAttribute('type', 'text/css'); + link.setAttribute('href', location.protocol + + '//www1.' + + location.hostname + + ':' + + location.port + + '/content-security-policy/style-src/3_3.css'); + head.appendChild(link); + + onload = function doTest() { + test(function() { + var text = document.getElementById("content"); + assert_true(getComputedStyle(text).marginLeft != "2px", "Style sheet loaded from origin not in style-src directive should be blocked"); + }); + } + </script> +</head> +<body> + <h1>href of link with rel=stylesheet must be in src list</h1> + <div id='log'></div> + + <div id="content">This text should not have a margin-left of 2</div> + + <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=style-src%20%27self%27'></script> + +</body> +</html>
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html.sub.headers b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html.sub.headers new file mode 100644 index 000000000..ca1adc553 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_3.html.sub.headers @@ -0,0 +1,6 @@ +Expires: Mon, 26 Jul 1997 05:00:00 GMT +Cache-Control: no-store, no-cache, must-revalidate +Cache-Control: post-check=0, pre-check=0, false +Pragma: no-cache +Set-Cookie: style-src-3_3={{$id:uuid()}}; Path=/content-security-policy/style-src/ +Content-Security-Policy: script-src 'self' 'unsafe-inline'; style-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}
\ No newline at end of file diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4-import.css b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4-import.css new file mode 100644 index 000000000..8ef865fdc --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4-import.css @@ -0,0 +1,3 @@ +#log { + margin-left: 200px; +} diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.css b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.css new file mode 100644 index 000000000..11729ce7a --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.css @@ -0,0 +1 @@ +@import "http://{{host}}:{{ports[http][1]}}/content-security-policy/style-src/style-src-3_4-import.css"; diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html new file mode 100644 index 000000000..92553dd67 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html @@ -0,0 +1,27 @@ +<!doctype html> +<html> +<head> + <title></title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <link href="style-src-3_4.css?pipe=sub" rel=stylesheet type=text/css> +</head> +<body> + <h1> + @import stylesheet should not be loaded + if its URL doesn't match style-src. + </h1> + <div id='log'></div> + + <script> + test(function() { + var logEl = document.getElementById("log"); + var marginLeftVal = getComputedStyle(logEl).getPropertyValue('margin-left'); + assert_false(marginLeftVal == "200px")}, + "@import stylesheet should not be applied" + ); + </script> + + <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=style-src%20%27self%27'></script> +</body> +</html> diff --git a/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html.sub.headers b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html.sub.headers new file mode 100644 index 000000000..9a9e1a288 --- /dev/null +++ b/testing/web-platform/tests/content-security-policy/style-src/style-src-3_4.html.sub.headers @@ -0,0 +1,6 @@ +Expires: Mon, 26 Jul 1997 05:00:00 GMT +Cache-Control: no-store, no-cache, must-revalidate +Cache-Control: post-check=0, pre-check=0, false +Pragma: no-cache +Set-Cookie: style-src-3_4={{$id:uuid()}}; Path=/content-security-policy/style-src/ +Content-Security-Policy: style-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}
\ No newline at end of file |