зеркало из https://github.com/mozilla/gecko-dev.git
50 строки
1.4 KiB
HTML
50 строки
1.4 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Bug 1086999 - Wildcard should not match blob:, data:</title>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
|
|
var base64data =
|
|
"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" +
|
|
"P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
|
|
|
|
|
// construct an image element using *data:*
|
|
var data_src = "data:image/png;base64," + base64data;
|
|
var data_img = document.createElement('img');
|
|
data_img.onload = function() {
|
|
window.parent.postMessage({scheme: "data", result: "allowed"}, "*");
|
|
}
|
|
data_img.onerror = function() {
|
|
window.parent.postMessage({scheme: "data", result: "blocked"}, "*");
|
|
}
|
|
data_img.src = data_src;
|
|
document.body.appendChild(data_img);
|
|
|
|
|
|
// construct an image element using *blob:*
|
|
var byteCharacters = atob(base64data);
|
|
var byteNumbers = new Array(byteCharacters.length);
|
|
for (var i = 0; i < byteCharacters.length; i++) {
|
|
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
}
|
|
var byteArray = new Uint8Array(byteNumbers);
|
|
var blob = new Blob([byteArray], {type: "image/png"});
|
|
var imageUrl = URL.createObjectURL( blob );
|
|
|
|
var blob_img = document.createElement('img');
|
|
blob_img.onload = function() {
|
|
window.parent.postMessage({scheme: "blob", result: "allowed"}, "*");
|
|
}
|
|
blob_img.onerror = function() {
|
|
window.parent.postMessage({scheme: "blob", result: "blocked"}, "*");
|
|
}
|
|
blob_img.src = imageUrl;
|
|
document.body.appendChild(blob_img);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|