forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can not read blobs in sandboxed iframes
https://bugs.webkit.org/show_bug.cgi?id=170075 <rdar://problem/31282427> Reviewed by Alex Christensen. Source/WebCore: In case of blob with an opaque origin, get the document that created the blob and use the document for mixed content check. Further refactoring should be done once specs are updated to clarify this. See w3c/webappsec-mixed-content#41 for more information. Tests: http/wpt/fetch/blob-of-opaque-origin-iframe.html http/wpt/fetch/blob-of-opaque-origin-worker.html * loader/MixedContentChecker.cpp: (WebCore::MixedContentChecker::isMixedContent): LayoutTests: * http/wpt/fetch/blob-of-opaque-origin-iframe-expected.txt: Added. * http/wpt/fetch/blob-of-opaque-origin-iframe.html: Added. * http/wpt/fetch/blob-of-opaque-origin-worker-expected.txt: Added. * http/wpt/fetch/blob-of-opaque-origin-worker.html: Added. * platform/win/TestExpectations: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@273879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
youenn@apple.com
committed
Mar 4, 2021
1 parent
c58e62b
commit f7acb91
Showing
8 changed files
with
132 additions
and
0 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
4 changes: 4 additions & 0 deletions
4
LayoutTests/http/wpt/fetch/blob-of-opaque-origin-iframe-expected.txt
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,4 @@ | ||
|
||
PASS Load opaque origin blobs for iframe | ||
PASS Check iframe secure context from a blob created in opaque origin but secure context | ||
|
38 changes: 38 additions & 0 deletions
38
LayoutTests/http/wpt/fetch/blob-of-opaque-origin-iframe.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,38 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Blobs and opaque origins, iframe</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
function with_iframe(url) { | ||
return new Promise(function(resolve) { | ||
var frame = document.createElement('iframe'); | ||
frame.srcdoc = url; | ||
frame.onload = function() { resolve(frame); }; | ||
document.body.appendChild(frame); | ||
}); | ||
} | ||
|
||
promise_test(async (t) => { | ||
const frame = await with_iframe('<'+ 'script>' + | ||
'onload = () => {' + | ||
' const blob = new Blob(["<" + "script>parent.postMessage(self.isSecureContext)</" + "script>"], { type : "text/html" });' + | ||
' const frame = document.createElement("iframe");' + | ||
' frame.src = URL.createObjectURL(blob);' + | ||
' document.body.appendChild(frame);' + | ||
' onmessage = (e) => parent.postMessage(e.data);' + | ||
'}' + | ||
'</' + 'script>'); | ||
const result = await new Promise(resolve => window.onmessage = (e) => resolve(e.data)); | ||
frame.remove(); | ||
test(() => { | ||
assert_true(result); | ||
}, "Check iframe secure context from a blob created in opaque origin but secure context"); | ||
}, "Load opaque origin blobs for iframe"); | ||
</script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
LayoutTests/http/wpt/fetch/blob-of-opaque-origin-worker-expected.txt
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,4 @@ | ||
|
||
PASS Load opaque origin blobs for worker | ||
PASS Check worker secure context from a blob created in opaque origin but secure context | ||
|
36 changes: 36 additions & 0 deletions
36
LayoutTests/http/wpt/fetch/blob-of-opaque-origin-worker.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,36 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Blobs and opaque origins, worker</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
function with_iframe(url) { | ||
return new Promise(function(resolve) { | ||
var frame = document.createElement('iframe'); | ||
frame.srcdoc = url; | ||
frame.onload = function() { resolve(frame); }; | ||
document.body.appendChild(frame); | ||
}); | ||
} | ||
|
||
promise_test(async (t) => { | ||
const frame = await with_iframe('<'+ 'script>' + | ||
'onload = () => {' + | ||
' const blob = new Blob(["self.postMessage(self.isSecureContext)"]);' + | ||
' const worker = new Worker(URL.createObjectURL(blob));' + | ||
' worker.onmessage = (e) => parent.postMessage(e.data);' + | ||
'}' + | ||
'</' + 'script>'); | ||
const result = await new Promise(resolve => window.onmessage = (e) => resolve(e.data)); | ||
frame.remove(); | ||
test(() => { | ||
assert_true(result); | ||
}, "Check worker secure context from a blob created in opaque origin but secure context"); | ||
}, "Load opaque origin blobs for worker"); | ||
</script> | ||
</body> | ||
</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
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