Bug 1160892 - Url.createObjectURL(blob) should support punycode origins, r=smaug

This commit is contained in:
Andrea Marchesini 2015-05-07 19:20:33 +01:00
parent e81f5e76ce
commit 992af18d7c
4 changed files with 59 additions and 3 deletions

View File

@ -391,13 +391,13 @@ nsHostObjectProtocolHandler::GenerateURIString(const nsACString &aScheme,
aUri.Append(':');
if (aPrincipal) {
nsAutoString origin;
rv = nsContentUtils::GetUTFOrigin(aPrincipal, origin);
nsAutoCString origin;
rv = nsContentUtils::GetASCIIOrigin(aPrincipal, origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
AppendUTF16toUTF8(origin, aUri);
aUri.Append(origin);
aUri.Append('/');
}

View File

@ -0,0 +1,24 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test blob URL for non-ascii domain</title>
</head>
<body>
<p id="result"></p>
<script type="application/javascript">
window.onmessage = function(e) {
var blob = new Blob([e.data]);
var url = URL.createObjectURL(blob);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
parent.postMessage(xhr.responseText, '*');
}
</script>
</body>
</html>

View File

@ -241,6 +241,7 @@ support-files =
viewport_helpers.js
w3element_traversal.svg
wholeTexty-helper.xml
file_nonascii_blob_url.html
[test_anonymousContent_api.html]
[test_anonymousContent_append_after_reflow.html]
@ -782,3 +783,4 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g'
[test_integer_attr_with_leading_zero.html]
[test_script_loader_crossorigin_data_url.html]
[test_file_negative_date.html]
[test_nonascii_blob_url.html]

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test blob URL for non-ascii domain</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="fileutils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="content"></div>
<script class="testbody" type="text/javascript;version=1.7">
var iframe = document.createElement('iframe');
iframe.src = 'http://xn--exmple-cua.test/tests/dom/base/test/file_nonascii_blob_url.html';
iframe.onload = function() {
iframe.contentWindow.postMessage('hello world', '*');
onmessage = function(e) {
is(e.data, 'hello world', "Blob URL for non-ascii domain works");
SimpleTest.finish();
}
}
document.getElementById('content').appendChild(iframe);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>