diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-14 08:51:05 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-14 08:51:05 +0200 |
commit | e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f (patch) | |
tree | 49b484a4a14ab2c8418f0e439122f26458ddcb59 /js/src | |
parent | a7f7a2231938e49ca2521fd417be7a313045c006 (diff) | |
download | UXP-e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f.tar UXP-e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f.tar.gz UXP-e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f.tar.lz UXP-e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f.tar.xz UXP-e2719e1dbf7b706cd5ec8b3ecd899d2fc063c20f.zip |
Bug 1326453 - Part 3: Don't throw a TypeError when SetPrototypeOf for module namespace objects is called with null
Diffstat (limited to 'js/src')
-rw-r--r-- | js/src/builtin/ModuleObject.cpp | 2 | ||||
-rw-r--r-- | js/src/jit-test/tests/modules/import-namespace.js | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index f7323e852..28a3329a8 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -345,6 +345,8 @@ bool ModuleNamespaceObject::ProxyHandler::setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, ObjectOpResult& result) const { + if (!proto) + return result.succeed(); return result.failCantSetProto(); } diff --git a/js/src/jit-test/tests/modules/import-namespace.js b/js/src/jit-test/tests/modules/import-namespace.js index 71a1ce7df..27d0193aa 100644 --- a/js/src/jit-test/tests/modules/import-namespace.js +++ b/js/src/jit-test/tests/modules/import-namespace.js @@ -39,7 +39,9 @@ assertEq(getModuleEnvironmentValue(b, "x"), 3); // Test module namespace internal methods as defined in 9.4.6 assertEq(Object.getPrototypeOf(ns), null); -assertThrowsInstanceOf(() => Object.setPrototypeOf(ns, null), TypeError); +assertEq(Reflect.setPrototypeOf(ns, null), true); +assertEq(Reflect.setPrototypeOf(ns, Object.prototype), false); +assertThrowsInstanceOf(() => Object.setPrototypeOf(ns, {}), TypeError); assertThrowsInstanceOf(function() { ns.foo = 1; }, TypeError); assertEq(Object.isExtensible(ns), false); Object.preventExtensions(ns); |