Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/connect-src-allow.sub.js

Issue 2765443003: CSP: Upstream worker tests to WPT repository. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/connect-src-allow.sub.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/connect-src-allow.sub.js b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/connect-src-allow.sub.js
new file mode 100644
index 0000000000000000000000000000000000000000..97a32179e591c3a57d50442d947948ec246e1790
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/connect-src-allow.sub.js
@@ -0,0 +1,59 @@
+importScripts("{{location[server]}}/resources/testharness.js");
+importScripts("{{location[server]}}/content-security-policy/support/testharness-helper.js");
+
+// Same-origin
+async_test(t => {
+ var url = "{{location[server]}}/content-security-policy/support/resource.py?same-origin-fetch";
+ assert_no_csp_event_for_url(t, url);
+
+ fetch(url)
+ .then(t.step_func_done(r => assert_equals(r.status, 200)));
+}, "Same-origin 'fetch()' in " + self.location.protocol + self.location.search);
+
+async_test(t => {
+ var url = "{{location[server]}}/content-security-policy/support/resource.py?same-origin-xhr";
+ assert_no_csp_event_for_url(t, url);
+
+ var xhr = new XMLHttpRequest();
+ try {
+ xhr.open("GET", url);
+ t.done();
+ } catch (e) {
+ assert_unreached();
+ }
+ xhr.send();
+}, "Same-origin XHR in " + self.location.protocol + self.location.search);
+
+// Cross-origin
+async_test(t => {
+ var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/resource.py?cross-origin-fetch";
+ assert_no_csp_event_for_url(t, url);
+
+ fetch(url)
+ .then(t.step_func_done(r => assert_equals(r.status, 200)));
+}, "Cross-origin 'fetch()' in " + self.location.protocol + self.location.search);
+
+async_test(t => {
+ var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/resource.py?cross-origin-xhr";
+ assert_no_csp_event_for_url(t, url);
+
+ var xhr = new XMLHttpRequest();
+ try {
+ xhr.open("GET", url);
+ t.done();
+ } catch (e) {
+ assert_unreached();
+ }
+ xhr.send();
+}, "Cross-origin XHR in " + self.location.protocol + self.location.search);
+
+// Same-origin redirecting to cross-origin
+async_test(t => {
+ var url = "{{location[server]}}/common/redirect-opt-in.py?status=307&location=http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/resource.py?cross-origin-fetch";
+ assert_no_csp_event_for_url(t, url);
+
+ fetch(url)
+ .then(t.step_func_done(r => assert_equals(r.status, 200)));
+}, "Same-origin => cross-origin 'fetch()' in " + self.location.protocol + self.location.search);
+
+done();

Powered by Google App Engine
This is Rietveld 408576698