⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181868 in webkit


Ignore:
Timestamp:
Mar 23, 2015, 1:48:21 PM (11 years ago)
Author:
Joseph Pecoraro
Message:

defineGetter/defineSetter should throw exceptions
https://bugs.webkit.org/show_bug.cgi?id=142934

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
Throw exceptions when these functions are used directly.

LayoutTests:

  • js/property-getters-and-setters-expected.txt:
  • js/script-tests/property-getters-and-setters.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181864 r181868  
     12015-03-23  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        __defineGetter__/__defineSetter__ should throw exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=142934
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/property-getters-and-setters-expected.txt:
     9        * js/script-tests/property-getters-and-setters.js:
     10
    1112015-03-23  Anders Carlsson  <andersca@apple.com>
    212
  • trunk/LayoutTests/js/property-getters-and-setters-expected.txt

    r165680 r181868  
    4444PASS o13.__lookupGetter__('b') is void 0
    4545PASS o13.__lookupSetter__('b') is void 0
     46__defineGetter__ and __defineSetter__ should throw exceptions when acting on sealed objects
     47PASS o14.__defineGetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
     48PASS o14.__defineGetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
     49PASS o14.__defineSetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
     50PASS o14.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
     51__defineGetter__ and __defineSetter__ should throw exceptions when acting on frozen objects
     52PASS o15.__defineGetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
     53PASS o15.__defineGetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
     54PASS o15.__defineSetter__('a', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
     55PASS o15.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to define property on object that is not extensible..
     56__defineGetter__ and __defineSetter__ should throw exceptions when acting on unconfigurable properties
     57PASS o16.__defineGetter__('a', function(){}) did not throw exception.
     58PASS o16.__defineSetter__('a', function(){}) did not throw exception.
     59PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
     60PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to configurable attribute of unconfigurable property..
    4661PASS successfullyParsed is true
    4762
  • trunk/LayoutTests/js/script-tests/property-getters-and-setters.js

    r165680 r181868  
    100100shouldBe("o13.__lookupGetter__('b')", "void 0");
    101101shouldBe("o13.__lookupSetter__('b')", "void 0");
     102
     103debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on sealed objects");
     104var o14 = {a:14};
     105Object.seal(o14);
     106shouldThrow("o14.__defineGetter__('a', function(){})");
     107shouldThrow("o14.__defineGetter__('b', function(){})");
     108shouldThrow("o14.__defineSetter__('a', function(){})");
     109shouldThrow("o14.__defineSetter__('b', function(){})");
     110
     111debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on frozen objects");
     112var o15 = {a:15};
     113Object.freeze(o15);
     114shouldThrow("o15.__defineGetter__('a', function(){})");
     115shouldThrow("o15.__defineGetter__('b', function(){})");
     116shouldThrow("o15.__defineSetter__('a', function(){})");
     117shouldThrow("o15.__defineSetter__('b', function(){})");
     118
     119debug("__defineGetter__ and __defineSetter__ should throw exceptions when acting on unconfigurable properties");
     120var o16 = {a:16};
     121Object.defineProperty(o16, "b", {value: 16, configurable: false});
     122shouldNotThrow("o16.__defineGetter__('a', function(){})");
     123shouldNotThrow("o16.__defineSetter__('a', function(){})");
     124shouldThrow("o16.__defineSetter__('b', function(){})");
     125shouldThrow("o16.__defineSetter__('b', function(){})");
  • trunk/Source/JavaScriptCore/ChangeLog

    r181867 r181868  
     12015-03-23  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        __defineGetter__/__defineSetter__ should throw exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=142934
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * runtime/ObjectPrototype.cpp:
     9        (JSC::objectProtoFuncDefineGetter):
     10        (JSC::objectProtoFuncDefineSetter):
     11        Throw exceptions when these functions are used directly.
     12
    1132015-03-23  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r181814 r181868  
    123123    descriptor.setEnumerable(true);
    124124    descriptor.setConfigurable(true);
    125     thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
     125
     126    bool shouldThrow = true;
     127    thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, shouldThrow);
    126128
    127129    return JSValue::encode(jsUndefined());
     
    143145    descriptor.setEnumerable(true);
    144146    descriptor.setConfigurable(true);
    145     thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
     147
     148    bool shouldThrow = true;
     149    thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, shouldThrow);
    146150
    147151    return JSValue::encode(jsUndefined());
Note: See TracChangeset for help on using the changeset viewer.