summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/object-src
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/object-src')
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html18
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html.sub.headers2
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-blocked.html21
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html24
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html.sub.headers2
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-blocked.html46
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html25
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html.sub.headers2
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-blocked.html22
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html18
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html.sub.headers2
-rw-r--r--testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub.html21
12 files changed, 203 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html
new file mode 100644
index 0000000000..faa963cb35
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <!-- Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}} -->
+</head>
+
+<body>
+ <object type="application/x-webkit-test-netscape"></object>
+
+ <!-- we rely on the report because we can't rely on the onload event for
+ "allowed" tests as it is not fired for object and embed -->
+ <script async defer src='../support/checkReport.sub.js?reportExists=false'></script>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html.sub.headers b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html.sub.headers
new file mode 100644
index 0000000000..071eb96fc0
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-allowed.html.sub.headers
@@ -0,0 +1,2 @@
+Set-Cookie: object-src-no-url-allowed={{$id:uuid()}}; Path=/content-security-policy/object-src/
+Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-blocked.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-blocked.html
new file mode 100644
index 0000000000..cb7292976a
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-no-url-blocked.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-inline';">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ var t = async_test("Should block the object and fire a spv");
+ window.addEventListener('securitypolicyviolation', t.step_func_done(function(e) {
+ assert_equals(e.violatedDirective, "object-src");
+ }));
+ </script>
+
+ <object type="application/x-webkit-test-netscape"></object>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html
new file mode 100644
index 0000000000..07c53ceb1b
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <!--
+ Content-Security-Policy:
+ object-src 'self';
+ script-src 'self' 'unsafe-inline';
+ report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
+ -->
+</head>
+
+<body>
+ <object type="image/png" data="/content-security-policy/support/pass.png"></object>
+ <!--
+ We rely on the report because we can't rely on the onload event for
+ "allowed" tests as it is not fired for object and embed
+ -->
+ <script src='../support/checkReport.sub.js?reportExists=false'></script>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html.sub.headers b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html.sub.headers
new file mode 100644
index 0000000000..58ddd21445
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-allowed.html.sub.headers
@@ -0,0 +1,2 @@
+Set-Cookie: object-src-url-allowed={{$id:uuid()}}; Path=/content-security-policy/object-src/
+Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-blocked.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-blocked.html
new file mode 100644
index 0000000000..25ddb5eec9
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-blocked.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta http-equiv="Content-Security-Policy"
+ content="object-src 'none'; script-src 'self' 'unsafe-inline';">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ const t = async_test("Should block the object and fire a spv");
+ const expected = 3;
+ let count = 0;
+ window.addEventListener('securitypolicyviolation', t.step_func(e => {
+ count++;
+ assert_equals(e.violatedDirective, "object-src");
+ if (count == expected) {
+ t.done();
+ }
+ }));
+
+ function unexpectedObjectLoaded() {
+ t.step(() => {
+ assert_unreached('CSP should block this object from loading');
+ })
+ }
+
+ </script>
+
+ <object data="/content-security-policy/support/fail.png"
+ onload="unexpectedObjectLoaded()"
+ type="image/png">
+ </object>
+
+ <object data="/content-security-policy/support/fail.png"
+ onload="unexpectedObjectLoaded()">
+ </object>
+
+ <object data="application/x-webkit-test-netscape"
+ onload="unexpectedObjectLoaded()">
+ </object>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html
new file mode 100644
index 0000000000..a7cdbc9e9f
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <!--
+ Content-Security-Policy:
+ object-src 'self';
+ script-src 'self' 'unsafe-inline';
+ report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
+ -->
+</head>
+
+<body>
+ <embed height="40" width="40" type="image/png"
+ src="/content-security-policy/support/pass.png"></embed>
+ <!--
+ We rely on the report because we can't rely on the onload event for
+ "allowed" tests as it is not fired for object and embed
+ -->
+ <script src='../support/checkReport.sub.js?reportExists=false'></script>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html.sub.headers b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html.sub.headers
new file mode 100644
index 0000000000..29a3987e30
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-allowed.html.sub.headers
@@ -0,0 +1,2 @@
+Set-Cookie: object-src-url-embed-allowed={{$id:uuid()}}; Path=/content-security-policy/object-src/
+Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-blocked.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-blocked.html
new file mode 100644
index 0000000000..e3f6b2f7ce
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-embed-blocked.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-inline';">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ var t = async_test("Should block the object and fire a spv");
+ window.addEventListener('securitypolicyviolation', t.step_func_done(function(e) {
+ assert_equals(e.violatedDirective, "object-src");
+ }));
+ </script>
+
+ <embed height="40" width="40" type="image/png"
+ src="/content-security-policy/support/fail.png"></embed>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html
new file mode 100644
index 0000000000..18d796b0e9
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <!-- Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}} -->
+</head>
+
+<body>
+ <object type="image/png" data="/common-redirect.py?location=/content-security-policy/support/pass.png"></object>
+
+ <!-- we rely on the report because we can't rely on the onload event for
+ "allowed" tests as it is not fired for object and embed -->
+ <script async defer src='../support/checkReport.sub.js?reportExists=false'></script>
+</body>
+
+</html>
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html.sub.headers b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html.sub.headers
new file mode 100644
index 0000000000..10b5543c02
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-allowed.html.sub.headers
@@ -0,0 +1,2 @@
+Set-Cookie: object-src-url-redirect-allowed={{$id:uuid()}}; Path=/content-security-policy/object-src/
+Content-Security-Policy: object-src 'self'; script-src 'self' 'unsafe-inline'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
diff --git a/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub.html b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub.html
new file mode 100644
index 0000000000..2a8eefee29
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta http-equiv="Content-Security-Policy" content="object-src 'self'; script-src 'self' 'unsafe-inline';">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+ <script>
+ var t = async_test("Should block the object and fire a spv");
+ window.addEventListener('securitypolicyviolation', t.step_func_done(function(e) {
+ assert_equals(e.violatedDirective, "object-src");
+ }));
+ </script>
+
+ <object type="image/png" data="/common/redirect.py?location=http://{{domains[www1]}}/content-security-policy/support/fail.png"></object>
+</body>
+
+</html>