Commit a830e07d authored by Jon Coppeard's avatar Jon Coppeard
Browse files

Bug 1406452 - Check for errored modules in builtin testing functions r=evilpie

parent 3c1db040
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -4241,10 +4241,8 @@ SetRNGState(JSContext* cx, unsigned argc, Value* vp)
#endif

static ModuleEnvironmentObject*
GetModuleEnvironment(JSContext* cx, HandleValue moduleValue)
GetModuleEnvironment(JSContext* cx, HandleModuleObject module)
{
    RootedModuleObject module(cx, &moduleValue.toObject().as<ModuleObject>());

    // Use the initial environment so that tests can check bindings exists
    // before they have been instantiated.
    RootedModuleEnvironmentObject env(cx, &module->initialEnvironment());
@@ -4268,7 +4266,13 @@ GetModuleEnvironmentNames(JSContext* cx, unsigned argc, Value* vp)
        return false;
    }

    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, args[0]));
    RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>());
    if (module->status() == MODULE_STATUS_ERRORED) {
        JS_ReportErrorASCII(cx, "Module environment unavailable");
        return false;
    }

    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, module));
    Rooted<IdVector> ids(cx, IdVector(cx));
    if (!JS_Enumerate(cx, env, &ids))
        return false;
@@ -4305,7 +4309,13 @@ GetModuleEnvironmentValue(JSContext* cx, unsigned argc, Value* vp)
        return false;
    }

    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, args[0]));
    RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>());
    if (module->status() == MODULE_STATUS_ERRORED) {
        JS_ReportErrorASCII(cx, "Module environment unavailable");
        return false;
    }

    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, module));
    RootedString name(cx, args[1].toString());
    RootedId id(cx);
    if (!JS_StringToId(cx, name, &id))
+5 −0
Original line number Diff line number Diff line
// |jit-test| error: Error
let m = parseModule(`for (var x of iterator) {}`);
m.declarationInstantiation();
try { m.evaluation(); } catch (e) {}
getModuleEnvironmentValue(m, "r");