diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java index f200d3a073a..ba37a92b419 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java @@ -2076,9 +2076,11 @@ public abstract class ScriptableObject implements Scriptable, Serializable, if (slot instanceof GetterSlot) { Object setterObj = ((GetterSlot)slot).setter; if (setterObj == null) { - // Odd case: Assignment to a property with only a getter - // defined. The assignment cancels out the getter. - ((GetterSlot)slot).getter = null; + if (((GetterSlot)slot).getter != null) { + // Based on TC39 ES3.1 Draft of 9-Feb-2009, 8.12.4, step 2, + // we should throw a TypeError in this case. + throw ScriptRuntime.typeError1("msg.set.prop.no.setter", name); + } } else { Context cx = Context.getContext(); if (setterObj instanceof MemberBox) { diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties b/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties index 52223cf3bc2..e1f071e1c88 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties +++ b/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties @@ -528,6 +528,9 @@ msg.ref.undefined.prop =\ msg.prop.not.found =\ Property {0} not found. +msg.set.prop.no.setter =\ + Cannot set property {0} that has only a getter. + msg.invalid.type =\ Invalid JavaScript value of type {0} diff --git a/mozilla/js/rhino/testsrc/base.skip b/mozilla/js/rhino/testsrc/base.skip index 342bcaab281..aa1a96898c2 100644 --- a/mozilla/js/rhino/testsrc/base.skip +++ b/mozilla/js/rhino/testsrc/base.skip @@ -4,6 +4,9 @@ # test has yet to be fixed, or because the test is not applicable to Rhino. # +# bad test: cannot write a property that has only a getter defined +js1_5/extensions/regress-341956-01.js + # timer resolution test js1_5/extensions/regress-363258.js