Changeset 202796 in webkit


Ignore:
Timestamp:
Jul 3, 2016 8:25:04 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] lookupGetter and lookupSetter should not ignore exceptions
https://bugs.webkit.org/show_bug.cgi?id=159390

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-03
Reviewed by Mark Lam.

Source/JavaScriptCore:

See:
-https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter
-https://tc39.github.io/ecma262/#sec-object.prototype.__lookupSetter

They are both supposed to be regular GetOwnProperty?.

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):

LayoutTests:

  • js/property-getters-and-setters-expected.txt:
  • js/script-tests/property-getters-and-setters.js:

(getter17):
(get getter17):
(getOwnPropertyDescriptor):
(setter18):
(set setter18):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202794 r202796  
     12016-07-03  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] __lookupGetter__ and __lookupSetter__ should not ignore exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=159390
     5
     6        Reviewed by Mark Lam.
     7
     8        * js/property-getters-and-setters-expected.txt:
     9        * js/script-tests/property-getters-and-setters.js:
     10        (getter17):
     11        (get getter17):
     12        (getOwnPropertyDescriptor):
     13        (setter18):
     14        (set setter18):
     15
    1162016-07-03  Frederic Wang  <fred.wang@free.fr>
    217
  • trunk/LayoutTests/js/property-getters-and-setters-expected.txt

    r202755 r202796  
    5959PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to change configurable attribute of unconfigurable property..
    6060PASS o16.__defineSetter__('b', function(){}) threw exception TypeError: Attempting to change configurable attribute of unconfigurable property..
     61__lookupGetter__ can be interrupted by a proxy throwing an exception
     62PASS o17.property is "WebKit!"
     63PASS o17.__lookupGetter__('property') is getter17
     64PASS o17.__lookupSetter__('property') is undefined
     65PASS o17Proxy.__lookupGetter__('property') threw exception o17 Proxy raised exception.
     66PASS o17Proxy.__lookupSetter__('property') threw exception o17 Proxy raised exception.
     67PASS o17Proxy.property is "WebKit!"
     68PASS o17.property is "WebKit!"
     69PASS o17.__lookupGetter__('property') is getter17
     70__lookupSetter__ can be interrupted by a proxy throwing an exception
     71PASS o18.property = 5 is 5
     72PASS o18.property is undefined
     73PASS o18.value is 5
     74PASS o18.__lookupGetter__('property') is undefined
     75PASS o18.__lookupSetter__('property') is setter18
     76PASS o18Proxy.__lookupGetter__('property') threw exception o18 Proxy raised exception.
     77PASS o18Proxy.__lookupSetter__('property') threw exception o18 Proxy raised exception.
     78PASS o18Proxy.property = 'JavaScriptCore!' threw exception o18 Proxy raised exception.
     79PASS o18Proxy.property is undefined
     80PASS o18Proxy.value is 5
     81PASS o18.property = 'JavaScriptCore!' is "JavaScriptCore!"
     82PASS o18.property is undefined
     83PASS o18.value is "JavaScriptCore!"
     84PASS o18.__lookupGetter__('property') is undefined
     85PASS o18.__lookupSetter__('property') is setter18
    6186PASS successfullyParsed is true
    6287
  • trunk/LayoutTests/js/script-tests/property-getters-and-setters.js

    r202755 r202796  
    124124shouldThrow("o16.__defineSetter__('b', function(){})");
    125125shouldThrow("o16.__defineSetter__('b', function(){})");
     126
     127debug("__lookupGetter__ can be interrupted by a proxy throwing an exception");
     128var getter17 = () => { return "WebKit!"}
     129var o17 = Object.defineProperty(new Object, 'property', { get: getter17 });
     130shouldBeEqualToString("o17.property", "WebKit!");
     131shouldBe("o17.__lookupGetter__('property')", "getter17");
     132shouldBe("o17.__lookupSetter__('property')", "undefined");
     133
     134var o17Exception = { toString: () => { return "o17 Proxy raised exception"; } };
     135var o17Proxy = new Proxy(o17, { getOwnPropertyDescriptor: () => { throw o17Exception; } });
     136shouldThrow("o17Proxy.__lookupGetter__('property')", o17Exception);
     137shouldThrow("o17Proxy.__lookupSetter__('property')", o17Exception);
     138shouldBeEqualToString("o17Proxy.property", "WebKit!");
     139shouldBeEqualToString("o17.property", "WebKit!");
     140shouldBe("o17.__lookupGetter__('property')", "getter17");
     141
     142debug("__lookupSetter__ can be interrupted by a proxy throwing an exception");
     143var setter18 = function (newValue) { return this.value = newValue; }
     144var o18 = Object.defineProperty(new Object, 'property', { set: setter18 });
     145shouldBe("o18.property = 5", "5");
     146shouldBe("o18.property", "undefined");
     147shouldBe("o18.value", "5");
     148shouldBe("o18.__lookupGetter__('property')", "undefined");
     149shouldBe("o18.__lookupSetter__('property')", "setter18");
     150
     151var o18Exception = { toString: () => { return "o18 Proxy raised exception"; } };
     152var o18Proxy = new Proxy(o18, { getOwnPropertyDescriptor: () => { throw o18Exception; } });
     153shouldThrow("o18Proxy.__lookupGetter__('property')", o18Exception);
     154shouldThrow("o18Proxy.__lookupSetter__('property')", o18Exception);
     155shouldThrow("o18Proxy.property = 'JavaScriptCore!'", o18Exception);
     156shouldBe("o18Proxy.property", "undefined");
     157shouldBe("o18Proxy.value", "5");
     158shouldBeEqualToString("o18.property = 'JavaScriptCore!'", "JavaScriptCore!");
     159shouldBe("o18.property", "undefined");
     160shouldBeEqualToString("o18.value", "JavaScriptCore!");
     161shouldBe("o18.__lookupGetter__('property')", "undefined");
     162shouldBe("o18.__lookupSetter__('property')", "setter18");
  • trunk/Source/JavaScriptCore/ChangeLog

    r202795 r202796  
     12016-07-03  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] __lookupGetter__ and __lookupSetter__ should not ignore exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=159390
     5
     6        Reviewed by Mark Lam.
     7
     8        See:
     9        -https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter__
     10        -https://tc39.github.io/ecma262/#sec-object.prototype.__lookupSetter__
     11
     12        They are both supposed to be regular [[GetOwnProperty]].
     13
     14        * runtime/ObjectPrototype.cpp:
     15        (JSC::objectProtoFuncLookupGetter):
     16        (JSC::objectProtoFuncLookupSetter):
     17
    1182016-07-03  Saam Barati  <sbarati@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r202755 r202796  
    188188        return JSValue::encode(jsUndefined());
    189189
    190     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
     190    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
    191191    if (thisObject->getPropertySlot(exec, propertyName, slot)) {
    192192        if (slot.isAccessor()) {
     
    215215        return JSValue::encode(jsUndefined());
    216216
    217     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
     217    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
    218218    if (thisObject->getPropertySlot(exec, propertyName, slot)) {
    219219        if (slot.isAccessor()) {
Note: See TracChangeset for help on using the changeset viewer.