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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-service-worker-fetch-event.html

Issue 2343053002: Service worker bypass for resource requests from suborigins (Closed)
Patch Set: Nits from falken@ Created 4 years, 3 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/http/tests/security/suborigins/suborigin-service-worker-fetch-event.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-service-worker-fetch-event.html b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-service-worker-fetch-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..f7d062497e97c2c49e401ffa294c2b4aeb747c8c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-service-worker-fetch-event.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Service Worker cannot access fetch events from a suborigin</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+
+<body>
+<script>
+
+var t_nonsuborigin = async_test('Service worker can access fetch events from a non-suborigin on the origin');
+var t_suborigin = async_test('Service worker cannot access fetch events from a suborigin on the origin');
+window.addEventListener('message', function(e) {
+ if (e.data.id == 'suborigin') {
+ t_suborigin.step(function() {
+ assert_equals(e.data.type, 'response');
+ t_suborigin.done();
+ });
+ } else if (e.data.id == 'nonsuborigin') {
+ t_nonsuborigin.step(function() {
+ assert_equals(e.data.type, 'error');
+ t_nonsuborigin.done();
+ });
+ } else {
+ assert_unreached('id must be one of \'suborigin\' or \'nonsuborigin\'');
+ }
+});
+
+navigator.serviceWorker.register('/security/suborigins/resources/sw-reject-all-with-error.js')
+.then(function(swr) {
+ var tests_started = false;
+
+ swr.installing.onstatechange = function() {
+ if (tests_started)
+ return;
+
+ tests_started = true;
+
+ var iframe1 = document.createElement('iframe');
+ iframe1.src = 'resources/fetch-resource.php?suborigin=foobar&resource=/resources/dummy.txt&id=suborigin&bypass';
+ document.body.appendChild(iframe1);
+
+ var iframe2 = document.createElement('iframe');
+ iframe2.src = 'resources/fetch-resource.php?resource=/resources/dummy.txt&id=nonsuborigin&bypass';
+ document.body.appendChild(iframe2);
+ }
falken 2016/09/20 04:52:52 nit: add semicolon
jww 2016/09/20 17:52:26 Done.
+});
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698