зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492932 - Load JS components and modules as UTF-8, not as Latin-1. r=kmag
--HG-- extra : rebase_source : d09627655e9c72e674356e996f936ec65a80b6f0
This commit is contained in:
Родитель
4ad73b310e
Коммит
e5132ffa4b
|
@ -212,7 +212,7 @@ add_task(async function test_hiddenNonShippingFieldsPreservedUponEdit() {
|
|||
|
||||
Object.assign(expected, PTU.Addresses.TimBR, {
|
||||
"given-name": "Timothy-edit",
|
||||
"name": "Timothy-edit João Berners-Lee",
|
||||
"name": "Timothy-edit Jo\u{00E3}o Berners-Lee",
|
||||
});
|
||||
let actual = await formAutofillStorage.addresses.get(prefilledGuids.address1GUID);
|
||||
isnot(actual.email, "", "Check email isn't empty");
|
||||
|
@ -335,7 +335,7 @@ add_task(async function test_hiddenNonBillingAddressFieldsPreservedUponEdit() {
|
|||
|
||||
Object.assign(expected, PTU.Addresses.TimBR, {
|
||||
"given-name": "Timothy-edit",
|
||||
"name": "Timothy-edit João Berners-Lee",
|
||||
"name": "Timothy-edit Jo\u{00E3}o Berners-Lee",
|
||||
});
|
||||
let actual = await formAutofillStorage.addresses.get(prefilledGuids.address1GUID);
|
||||
// timeLastModified changes and isn't relevant
|
||||
|
|
|
@ -277,6 +277,15 @@ extern JS_PUBLIC_API bool CompileLatin1ForNonSyntacticScope(
|
|||
JSContext* cx, const ReadOnlyCompileOptions& options, const char* bytes,
|
||||
size_t length, MutableHandle<JSScript*> script);
|
||||
|
||||
/**
|
||||
* Compile the given UTF-8 data for non-syntactic scope.
|
||||
*
|
||||
* An exception is thrown if the data isn't valid UTF-8.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool CompileUtf8ForNonSyntacticScope(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options, const char* bytes,
|
||||
size_t length, MutableHandle<JSScript*> script);
|
||||
|
||||
/**
|
||||
* Compile a function with envChain plus the global as its scope chain.
|
||||
* envChain must contain objects in the current compartment of cx. The actual
|
||||
|
|
|
@ -195,6 +195,15 @@ bool JS::CompileForNonSyntacticScope(JSContext* cx,
|
|||
return CompileSourceBuffer(cx, options, srcBuf, script);
|
||||
}
|
||||
|
||||
bool JS::CompileUtf8ForNonSyntacticScope(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& optionsArg, const char* bytes,
|
||||
size_t length, JS::MutableHandleScript script) {
|
||||
CompileOptions options(cx, optionsArg);
|
||||
options.setNonSyntacticScope(true);
|
||||
|
||||
return ::CompileUtf8(cx, options, bytes, length, script);
|
||||
}
|
||||
|
||||
bool JS::CompileLatin1ForNonSyntacticScope(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& optionsArg, const char* bytes,
|
||||
size_t length, JS::MutableHandleScript script) {
|
||||
|
|
|
@ -847,20 +847,20 @@ nsresult mozJSComponentLoader::ObjectForLocation(
|
|||
// don't early return for them here.
|
||||
auto buf = map.get<char>();
|
||||
if (reuseGlobal) {
|
||||
CompileLatin1ForNonSyntacticScope(cx, options, buf.get(), map.size(),
|
||||
&script);
|
||||
CompileUtf8ForNonSyntacticScope(cx, options, buf.get(), map.size(),
|
||||
&script);
|
||||
} else {
|
||||
CompileLatin1(cx, options, buf.get(), map.size(), &script);
|
||||
CompileUtf8(cx, options, buf.get(), map.size(), &script);
|
||||
}
|
||||
} else {
|
||||
nsCString str;
|
||||
MOZ_TRY_VAR(str, ReadScript(aInfo));
|
||||
|
||||
if (reuseGlobal) {
|
||||
CompileLatin1ForNonSyntacticScope(cx, options, str.get(), str.Length(),
|
||||
&script);
|
||||
CompileUtf8ForNonSyntacticScope(cx, options, str.get(), str.Length(),
|
||||
&script);
|
||||
} else {
|
||||
CompileLatin1(cx, options, str.get(), str.Length(), &script);
|
||||
CompileUtf8(cx, options, str.get(), str.Length(), &script);
|
||||
}
|
||||
}
|
||||
// Propagate the exception, if one exists. Also, don't leave the stale
|
||||
|
|
Загрузка…
Ссылка в новой задаче