-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not dispatch an opaque response for a mode: "cors" request
When a service worker is involved, it's possible to get an opaque filtered response for a mode: "cors" request. We peviously checked it in ResourceFetcher but it's insufficient when the resource is shared before the response arrives. This CL instead make a CORS error when we see such response in DocumentThreadableLoader. Bug: 731669, 625575 Change-Id: I65334dbe21c0e2e8aaedd6d5dd5fae762c7cb72c Reviewed-on: https://chromium-review.googlesource.com/527768 Commit-Queue: Yutaka Hirano <yhirano@chromium.org> Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org> Cr-Commit-Position: refs/heads/master@{#481863} WPT-Export-Revision: 6d70c3eabfdab9acd9a84e1f94bdf78783bef459
- Loading branch information
1 parent
cb34f0c
commit e8cbae9
Showing
5 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
service-workers/service-worker/resources/opaque-response-being-preloaded-xhr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<body></body> | ||
<script> | ||
const URL = 'opaque-response?from=opaque-response-being-preloaded-xhr.html'; | ||
function runTest() { | ||
var l = document.createElement('link'); | ||
// Use link rel=preload to try to get the browser to cache the opaque | ||
// response. | ||
l.setAttribute('rel', 'preload'); | ||
l.setAttribute('href', URL); | ||
l.setAttribute('as', 'fetch'); | ||
l.onerror = function() { | ||
parent.done('FAIL: preload failed unexpectedly'); | ||
}; | ||
document.body.appendChild(l); | ||
xhr = new XMLHttpRequest; | ||
xhr.withCredentials = true; | ||
xhr.open('GET', URL); | ||
// opaque-response returns an opaque response from serviceworker and thus | ||
// the XHR must fail because it is not no-cors request. | ||
// Particularly, the XHR must not reuse the opaque response from the | ||
// preload request. | ||
xhr.onerror = function() { | ||
parent.done('PASS'); | ||
}; | ||
xhr.onload = function() { | ||
parent.done('FAIL: ' + xhr.responseText); | ||
}; | ||
xhr.send(); | ||
} | ||
</script> | ||
<body onload="setTimeout(runTest, 100)"></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters