From 16a73576ee9ae79f2eeb1d2300a7ae070c8cae14 Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Sun, 2 Aug 2009 01:40:42 +0000 Subject: [PATCH] See bug 489329 #52: Make defineProperty throw a TypeError when attributes is both data and accessor descriptor. As per 8.10.5 step 9 of the spec. Patch from Raphel Speyer. git-svn-id: svn://10.0.0.236/trunk@257920 18797224-902f-48f8-a5cc-f745e15eee43 --- .../js/rhino/src/org/mozilla/javascript/ScriptableObject.java | 3 +++ .../src/org/mozilla/javascript/resources/Messages.properties | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java index 838e9d0bb44..46ad423e2ec 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java @@ -1581,6 +1581,9 @@ public abstract class ScriptableObject implements Scriptable, Serializable, if (setter != NOT_FOUND && !(setter instanceof Callable)) { throw ScriptRuntime.notFunctionError(setter); } + if (isDataDescriptor(desc) && isAccessorDescriptor(desc)) { + throw ScriptRuntime.typeError0("msg.both.data.and.accessor.desc"); + } if (slot == null) { // new property if (!isExtensible()) throw ScriptRuntime.typeError("msg.not.extensible"); 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 874b6094fdf..4c9b1391fd4 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties +++ b/mozilla/js/rhino/src/org/mozilla/javascript/resources/Messages.properties @@ -680,6 +680,9 @@ msg.modify.sealed =\ msg.modify.readonly =\ Cannot modify readonly property: {0}. +msg.both.data.and.accessor.desc =\ + Cannot be both a data and an accessor descriptor. + msg.change.configurable.false.to.true =\ Cannot change the configurable attribute of "{0}" from false to true.