Bug 1341256 - Fix module namespace object get handler r=anba
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 21 Feb 2017 17:17:34 +0000
changeset 373116 c6a0ab52c21e7c3addc6e233447945c785085490
parent 373115 10bf2b81234bcd8c6174f904bb99483a0fb523e6
child 373117 c7a4c2e34e6e1c888976fd9857fe816804f83550
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1341256
milestone54.0a1
Bug 1341256 - Fix module namespace object get handler r=anba
js/src/builtin/ModuleObject.cpp
js/src/jit-test/tests/modules/import-namespace.js
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -459,18 +459,20 @@ ModuleNamespaceObject::ProxyHandler::get
         }
 
         vp.setUndefined();
         return true;
     }
 
     ModuleEnvironmentObject* env;
     Shape* shape;
-    if (!ns->bindings().lookup(id, &env, &shape))
-        return false;
+    if (!ns->bindings().lookup(id, &env, &shape)) {
+        vp.setUndefined();
+        return true;
+    }
 
     RootedValue value(cx, env->getSlot(shape->slot()));
     if (value.isMagic(JS_UNINITIALIZED_LEXICAL)) {
         ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, id);
         return false;
     }
 
     vp.set(value);
--- a/js/src/jit-test/tests/modules/import-namespace.js
+++ b/js/src/jit-test/tests/modules/import-namespace.js
@@ -40,16 +40,19 @@ let b = moduleRepo['b'] = parseModule(
      export var x = ns.a + ns.b;`
 );
 
 b.declarationInstantiation();
 b.evaluation();
 testHasNames(getModuleEnvironmentNames(b), ["ns", "x"]);
 let ns = getModuleEnvironmentValue(b, "ns");
 testHasNames(Object.keys(ns), ["a", "b"]);
+assertEq(ns.a, 1);
+assertEq(ns.b, 2);
+assertEq(ns.c, undefined);
 assertEq(getModuleEnvironmentValue(b, "x"), 3);
 
 // Test module namespace internal methods as defined in 9.4.6
 assertEq(Object.getPrototypeOf(ns), null);
 assertEq(Reflect.setPrototypeOf(ns, null), true);
 assertEq(Reflect.setPrototypeOf(ns, Object.prototype), false);
 assertThrowsInstanceOf(() => Object.setPrototypeOf(ns, {}), TypeError);
 assertThrowsInstanceOf(function() { ns.foo = 1; }, TypeError);