зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492090
- Part 9: Use UTF-8 in module ThrowResolutionError. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D151453
This commit is contained in:
Родитель
c16595d70c
Коммит
4f180f0ed1
|
@ -165,6 +165,20 @@ function getLcovInfoScriptName(fileName) {
|
|||
return scriptFiles[0].substring(3);
|
||||
}
|
||||
|
||||
// Return the file name from the error during module import.
|
||||
function moduleResolutionError(fileName) {
|
||||
const a = parseModule(`import { x } from "b";`, fileName);
|
||||
const ma = registerModule("a", a);
|
||||
const b = parseModule(`export var y = 10;`);
|
||||
const mb = registerModule("b", b);
|
||||
|
||||
try {
|
||||
moduleLink(ma);
|
||||
} catch (e) {
|
||||
return e.fileName;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the file name from the profiler stack.
|
||||
function geckoInterpProfilingStack(fileName) {
|
||||
enableGeckoProfilingWithSlowAssertions();
|
||||
|
@ -191,6 +205,7 @@ const testFunctions = [
|
|||
fromErrorStackAsmJS,
|
||||
fromErrorStackStreamingWasm,
|
||||
getBacktraceScriptName,
|
||||
moduleResolutionError,
|
||||
];
|
||||
|
||||
if (isLcovEnabled()) {
|
||||
|
|
|
@ -885,7 +885,12 @@ static void ThrowResolutionError(JSContext* cx, Handle<ModuleObject*> module,
|
|||
}
|
||||
|
||||
RootedString filename(cx);
|
||||
filename = JS_NewStringCopyZ(cx, module->script()->filename());
|
||||
if (const char* chars = module->script()->filename()) {
|
||||
filename =
|
||||
JS_NewStringCopyUTF8Z(cx, JS::ConstUTF8CharsZ(chars, strlen(chars)));
|
||||
} else {
|
||||
filename = cx->names().empty;
|
||||
}
|
||||
if (!filename) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче