Bug 1417962 - Don't unbox proxies when reporting strict assignment error. r=jandem
authorTom Schuster <evilpies@gmail.com>
Tue, 21 Nov 2017 21:03:39 +0100
changeset 392881 e6ace8b5531cd2f50b6685ef8fdb180afcd9344e
parent 392880 840cf9044de30a0ddddff5904c9415a8a074faf8
child 392882 0f356a5c4dea9aa3cc0f806f74338beb484b9f12
push id97559
push userevilpies@gmail.com
push dateTue, 21 Nov 2017 20:04:01 +0000
treeherdermozilla-inbound@e6ace8b5531c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1417962
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1417962 - Don't unbox proxies when reporting strict assignment error. r=jandem
js/src/jit-test/tests/basic/assign-primitive-proxy-class-error.js
js/src/jsapi.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/assign-primitive-proxy-class-error.js
@@ -0,0 +1,14 @@
+'use strict';
+
+load(libdir + 'asserts.js');
+
+let hook = {}
+let Base = function() {}
+Base.prototype = new Proxy(Base.prototype, hook);
+class Derived extends Base {
+    testPrimitiveReceiver() {
+        super.foo = "Derived";
+    }
+}
+assertTypeErrorMessage(() => Derived.prototype.testPrimitiveReceiver.call(null),
+                       `can't assign to property "foo" on ({}): not an object`)
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -177,19 +177,21 @@ JS::ObjectOpResult::reportStrictErrorOrW
             return false;
 
         JSAutoByteString propName;
         if (!propName.encodeUtf8(cx, str))
             return false;
 
         if (code_ == JSMSG_SET_NON_OBJECT_RECEIVER) {
             // We know that the original receiver was a primitive, so unbox it.
-            RootedValue val(cx);
-            if (!Unbox(cx, obj, &val))
-                return false;
+            RootedValue val(cx, ObjectValue(*obj));
+            if (!obj->is<ProxyObject>()) {
+                if (!Unbox(cx, obj, &val))
+                    return false;
+            }
             return ReportValueErrorFlags(cx, flags, code_, JSDVG_IGNORE_STACK, val,
                                          nullptr, propName.ptr(), nullptr);
         }
 
         if (ErrorTakesObjectArgument(code_)) {
             return JS_ReportErrorFlagsAndNumberUTF8(cx, flags, GetErrorMessage, nullptr, code_,
                                                     obj->getClass()->name, propName.ptr());
         }