Diff
Modified: trunk/LayoutTests/ChangeLog (181867 => 181868)
--- trunk/LayoutTests/ChangeLog 2015-03-23 20:48:18 UTC (rev 181867)
+++ trunk/LayoutTests/ChangeLog 2015-03-23 20:48:21 UTC (rev 181868)
@@ -1,3 +1,13 @@
+2015-03-23 Joseph Pecoraro <[email protected]>
+
+ __defineGetter__/__defineSetter__ should throw exceptions
+ https://bugs.webkit.org/show_bug.cgi?id=142934
+
+ Reviewed by Geoffrey Garen.
+
+ * js/property-getters-and-setters-expected.txt:
+ * js/script-tests/property-getters-and-setters.js:
+
2015-03-23 Anders Carlsson <[email protected]>
Make platform/mac-wk2/plugins/destroy-during-async-npp-new.html work again
Modified: trunk/LayoutTests/js/property-getters-and-setters-expected.txt (181867 => 181868)
--- trunk/LayoutTests/js/property-getters-and-setters-expected.txt 2015-03-23 20:48:18 UTC (rev 181867)
+++ trunk/LayoutTests/js/property-getters-and-setters-expected.txt 2015-03-23 20:48:21 UTC (rev 181868)
@@ -43,6 +43,21 @@
When undefined, accessing __lookupGetter__ and __lookupSetter__ should not crash
PASS o13.__lookupGetter__('b') is void 0
PASS o13.__lookupSetter__('b') is void 0
+__defineGetter__ and __defineSetter__ should throw exceptions when acting on sealed objects
+PASS o14.__defineGetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
+PASS o14.__defineGetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
+PASS o14.__defineSetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
+PASS o14.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
+__defineGetter__ and __defineSetter__ should throw exceptions when acting on frozen objects
+PASS o15.__defineGetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
+PASS o15.__defineGetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
+PASS o15.__defineSetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
+PASS o15.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
+__defineGetter__ and __defineSetter__ should throw exceptions when acting on unconfigurable properties
+PASS o16.__defineGetter__('a', function(){}) did not throw exception.
+PASS o16.__defineSetter__('a', function(){}) did not throw exception.
+PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
+PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/js/script-tests/property-getters-and-setters.js (181867 => 181868)
--- trunk/LayoutTests/js/script-tests/property-getters-and-setters.js 2015-03-23 20:48:18 UTC (rev 181867)
+++ trunk/LayoutTests/js/script-tests/property-getters-and-setters.js 2015-03-23 20:48:21 UTC (rev 181868)
@@ -99,3 +99,27 @@
shouldBe("o13.__lookupGetter__('b')", "void 0");
shouldBe("o13.__lookupSetter__('b')", "void 0");
+
+debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on sealed objects");
+var o14 = {a:14};
+Object.seal(o14);
+shouldThrow("o14.__defineGetter__('a', function(){})");
+shouldThrow("o14.__defineGetter__('b', function(){})");
+shouldThrow("o14.__defineSetter__('a', function(){})");
+shouldThrow("o14.__defineSetter__('b', function(){})");
+
+debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on frozen objects");
+var o15 = {a:15};
+Object.freeze(o15);
+shouldThrow("o15.__defineGetter__('a', function(){})");
+shouldThrow("o15.__defineGetter__('b', function(){})");
+shouldThrow("o15.__defineSetter__('a', function(){})");
+shouldThrow("o15.__defineSetter__('b', function(){})");
+
+debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on unconfigurable properties");
+var o16 = {a:16};
+Object.defineProperty(o16, "b", {value: 16, configurable: false});
+shouldNotThrow("o16.__defineGetter__('a', function(){})");
+shouldNotThrow("o16.__defineSetter__('a', function(){})");
+shouldThrow("o16.__defineSetter__('b', function(){})");
+shouldThrow("o16.__defineSetter__('b', function(){})");
Modified: trunk/Source/_javascript_Core/ChangeLog (181867 => 181868)
--- trunk/Source/_javascript_Core/ChangeLog 2015-03-23 20:48:18 UTC (rev 181867)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-03-23 20:48:21 UTC (rev 181868)
@@ -1,5 +1,17 @@
2015-03-23 Joseph Pecoraro <[email protected]>
+ __defineGetter__/__defineSetter__ should throw exceptions
+ https://bugs.webkit.org/show_bug.cgi?id=142934
+
+ Reviewed by Geoffrey Garen.
+
+ * runtime/ObjectPrototype.cpp:
+ (JSC::objectProtoFuncDefineGetter):
+ (JSC::objectProtoFuncDefineSetter):
+ Throw exceptions when these functions are used directly.
+
+2015-03-23 Joseph Pecoraro <[email protected]>
+
Fix DO_PROPERTYMAP_CONSTENCY_CHECK enabled build
https://bugs.webkit.org/show_bug.cgi?id=142952
Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (181867 => 181868)
--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2015-03-23 20:48:18 UTC (rev 181867)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2015-03-23 20:48:21 UTC (rev 181868)
@@ -122,8 +122,10 @@
descriptor.setGetter(get);
descriptor.setEnumerable(true);
descriptor.setConfigurable(true);
- thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
+ bool shouldThrow = true;
+ thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, shouldThrow);
+
return JSValue::encode(jsUndefined());
}
@@ -142,8 +144,10 @@
descriptor.setSetter(set);
descriptor.setEnumerable(true);
descriptor.setConfigurable(true);
- thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
+ bool shouldThrow = true;
+ thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, shouldThrow);
+
return JSValue::encode(jsUndefined());
}