зеркало из https://github.com/mozilla/gecko-dev.git
Bug 795104 - Sources with a custom charset can't be lazily loaded. r=bz
This commit is contained in:
Родитель
645c634f59
Коммит
2726941d91
|
@ -119,8 +119,7 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *target_ob
|
|||
|
||||
JS::CompileOptions options(cx);
|
||||
options.setPrincipals(nsJSPrincipals::get(principal))
|
||||
.setFileAndLine(uriStr, 1)
|
||||
.setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
|
||||
.setFileAndLine(uriStr, 1);
|
||||
js::RootedObject target_obj_root(cx, target_obj);
|
||||
if (!charset.IsVoid()) {
|
||||
nsString script;
|
||||
|
@ -134,6 +133,9 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *target_ob
|
|||
*scriptp = JS::Compile(cx, target_obj_root, options,
|
||||
reinterpret_cast<const jschar*>(script.get()), script.Length());
|
||||
} else {
|
||||
// We only use LAZY_SOURCE when no special encoding is specified because
|
||||
// the lazy source loader doesn't know the encoding.
|
||||
options.setSourcePolicy(JS::CompileOptions::LAZY_SOURCE);
|
||||
*scriptp = JS::Compile(cx, target_obj_root, options, buf.get(), len);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ MOCHITEST_CHROME_FILES = \
|
|||
test_chrometoSource.xul \
|
||||
outoflinexulscript.js \
|
||||
subscript.js \
|
||||
utf8_subscript.js \
|
||||
test_cows.xul \
|
||||
test_documentdomain.xul \
|
||||
test_doublewrappedcompartments.xul \
|
||||
|
|
|
@ -42,9 +42,15 @@ isnot(src.indexOf("return"), -1, "subscript should have source");
|
|||
var base = /.*\//.exec(window.location.href)[0];
|
||||
var reg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
|
||||
var resolvedBase = reg.convertChromeURL(NetUtil.newURI(base)).spec;
|
||||
|
||||
ns = {};
|
||||
Services.scriptloader.loadSubScript(resolvedBase + "subscript.js", ns);
|
||||
src = ns.NetUtil.asyncFetch.toSource();
|
||||
isnot(src.indexOf("return"), -1, "subscript of a subscript should have source");
|
||||
|
||||
ns = {};
|
||||
Services.scriptloader.loadSubScript(resolvedBase + "utf8_subscript.js", ns, "UTF-8");
|
||||
src = ns.f.toSource();
|
||||
isnot(src.indexOf("return 42;"), -1, "encoded subscript should have correct source");
|
||||
]]></script>
|
||||
</window>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
var str = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢";
|
||||
function f() { return 42; }
|
Загрузка…
Ссылка в новой задаче