mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
Bug 1160892 - Url.createObjectURL(blob) should support punycode origins, r=smaug
This commit is contained in:
parent
28c02e1e6d
commit
3da49355e2
@ -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('/');
|
||||
}
|
||||
|
||||
|
24
dom/base/test/file_nonascii_blob_url.html
Normal file
24
dom/base/test/file_nonascii_blob_url.html
Normal 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>
|
@ -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]
|
||||
|
30
dom/base/test/test_nonascii_blob_url.html
Normal file
30
dom/base/test/test_nonascii_blob_url.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user