jdk8/jdk8/nashorn: 0548c134b9ac (original) (raw)
OpenJDK / jdk8 / jdk8 / nashorn
changeset 170:0548c134b9ac
8011421: When using Object.defineProperty on arrays, PropertyDescriptor's property accessors are invoked multiple times Reviewed-by: lagergren, hannesw
sundar | |
---|---|
date | Thu, 04 Apr 2013 13:54:51 +0530 |
parents | a5a8ddc2e028 |
children | 069923cc9de5 5eb1427b6a6d |
files | src/jdk/nashorn/internal/objects/NativeArray.java test/script/basic/JDK-8011421.js |
diffstat | 2 files changed, 54 insertions(+), 3 deletions(-)[+] [-] src/jdk/nashorn/internal/objects/NativeArray.java 6 test/script/basic/JDK-8011421.js 51 |
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/objects/NativeArray.java Thu Apr 04 10:24:46 2013 +0530 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Thu Apr 04 13:54:51 2013 +0530 @@ -160,7 +160,7 @@ if ("length".equals(key)) { // Step 3a if (!desc.has(VALUE)) {
return super.defineOwnProperty("length", propertyDesc, reject);[](#l1.7)
return super.defineOwnProperty("length", desc, reject);[](#l1.8) }[](#l1.9)
// Step 3b @@ -242,7 +242,7 @@ // Step 4c // set the new array element
final boolean succeeded = super.defineOwnProperty(key, propertyDesc, false);[](#l1.16)
final boolean succeeded = super.defineOwnProperty(key, desc, false);[](#l1.17)
// Step 4d if (!succeeded) { @@ -263,7 +263,7 @@ } // not an index property
return super.defineOwnProperty(key, propertyDesc, reject);[](#l1.25)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8011421.js Thu Apr 04 13:54:51 2013 +0530 @@ -0,0 +1,51 @@ +/*
- *
- *
- *
- *
- or visit www.oracle.com if you need additional information or have any
- */ + +/**
- *
- */ + +var configurableGetterCalled = 0; + +// create a property descriptor object with "configurable" +// property with a user defined getter +var propDesc = Object.defineProperty({},
- "configurable",
- {
get: function() {[](#l2.41)
configurableGetterCalled++;[](#l2.42)
return false[](#l2.43)
}[](#l2.44)
- }
+); + +// make array length non-configurable +Object.defineProperty([], "length", propDesc); + +// above should have called "configurable" getter only once +if (configurableGetterCalled !== 1) {