-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use origin of final HTTP response as document origin.
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 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
22 changes: 22 additions & 0 deletions
22
tests/wpt/mozilla/tests/mozilla/document_origin_redirect.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,22 @@ | ||
<html> | ||
<head> | ||
<title>A document's origin should match the origin of the final HTTP response</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<body> | ||
<script> | ||
async_test(function(t) { | ||
var path = new URL("document_origin_redirect_subpage.html", document.location).pathname; | ||
var CROSS_ORIGIN_URL = new URL(path, get_host_info().HTTP_REMOTE_ORIGIN); | ||
var SAME_ORIGIN_URL = "/common/redirect.py?location=" + CROSS_ORIGIN_URL; | ||
console.log(SAME_ORIGIN_URL); | ||
var iframe = document.createElement('iframe'); | ||
iframe.src = SAME_ORIGIN_URL; | ||
document.body.appendChild(iframe); | ||
onmessage = t.step_func_done(function(e) { | ||
assert_true(e.data[0]); | ||
assert_true(e.data[1]); | ||
}); | ||
}); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
tests/wpt/mozilla/tests/mozilla/document_origin_redirect_subpage.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,32 @@ | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<canvas></canvas> | ||
<canvas></canvas> | ||
<img src="2x2.png" onload="dotest()"> | ||
<script> | ||
function dotest() { | ||
var c = document.querySelector('canvas'); | ||
var ctx = c.getContext('2d'); | ||
|
||
var i = document.querySelector('img'); | ||
ctx.drawImage(i, 0, 0); | ||
var sameorigin2d = false; | ||
try { | ||
c.toDataURL(); | ||
sameorigin2d = true; | ||
} catch (x) { | ||
} | ||
|
||
var c = document.querySelectorAll('canvas')[1]; | ||
var gl = c.getContext('webgl'); | ||
const texture = gl.createTexture(); | ||
gl.bindTexture(gl.TEXTURE_2D, texture); | ||
var sameorigin3d = false; | ||
try { | ||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, i); | ||
sameorigin3d = true; | ||
} catch(x) { | ||
} | ||
|
||
parent.postMessage([sameorigin2d, sameorigin3d], '*'); | ||
} | ||
</script> |