Changeset 110521 in webkit


Ignore:
Timestamp:
Mar 12, 2012, 6:16:08 PM (14 years ago)
Author:
barraclough@apple.com
Message:

Object.defineProperty doesn't respect attributes when applied to the Global Object
https://bugs.webkit.org/show_bug.cgi?id=38636
Object.defineProperty doesn't create property on Global Object in the presence of a setter in the prototype chain
https://bugs.webkit.org/show_bug.cgi?id=48911

Rubber stamped by Michael Saboff.

  • fast/js/Object-defineProperty-expected.txt:
  • fast/js/script-tests/Object-defineProperty.js:
    • Added test cases for bugs #38636 & #48911.
Location:
trunk/LayoutTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r110517 r110521  
     12012-03-12  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Object.defineProperty doesn't respect attributes when applied to the Global Object
     4        https://bugs.webkit.org/show_bug.cgi?id=38636
     5        Object.defineProperty doesn't create property on Global Object in the presence of a setter in the prototype chain
     6        https://bugs.webkit.org/show_bug.cgi?id=48911
     7
     8        Rubber stamped by Michael Saboff.
     9
     10        * fast/js/Object-defineProperty-expected.txt:
     11        * fast/js/script-tests/Object-defineProperty.js:
     12            - Added test cases for bugs #38636 & #48911.
     13
    1142012-03-12  Dirk Pranke  <dpranke@chromium.org>
    215
  • trunk/LayoutTests/fast/js/Object-defineProperty-expected.txt

    r109866 r110521  
    126126PASS var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0]; is undefined.
    127127PASS 'use strict'; var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0]; threw exception TypeError: Attempted to assign to readonly property..
     128PASS anObj.slot1 is "foo"
     129PASS anObj.slot2 is "bar"
     130PASS anObj.propertyIsEnumerable('slot1') is true
     131PASS anObj.propertyIsEnumerable('slot2') is false
     132PASS anObj.slot4 is "goo"
     133PASS anObj.slot5 is 123
     134PASS anObj._Slot5 is 123
     135PASS Object.getOwnPropertyDescriptor(anObj, 'slot5') is undefined.
     136PASS anObj.slot5 is 456
     137PASS anObj._Slot5 is 123
     138PASS Object.getOwnPropertyDescriptor(anObj, 'slot5').value is 456
     139PASS anObj.slot1 is "foo"
     140PASS anObj.slot2 is "bar"
     141PASS anObj.propertyIsEnumerable('slot1') is true
     142PASS anObj.propertyIsEnumerable('slot2') is false
     143PASS anObj.slot4 is "goo"
     144PASS anObj.slot5 is 123
     145PASS anObj._Slot5 is 123
     146PASS Object.getOwnPropertyDescriptor(anObj, 'slot5') is undefined.
     147PASS anObj.slot5 is 456
     148PASS anObj._Slot5 is 123
     149PASS Object.getOwnPropertyDescriptor(anObj, 'slot5').value is 456
    128150PASS successfullyParsed is true
    129151
  • trunk/LayoutTests/fast/js/script-tests/Object-defineProperty.js

    r109866 r110521  
    184184shouldBeUndefined("var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");
    185185shouldThrow("'use strict'; var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");
     186
     187function testObject()
     188{
     189    // Test case from https://bugs.webkit.org/show_bug.cgi?id=38636
     190    Object.defineProperty(anObj, 'slot1', {value: 'foo', enumerable: true});
     191    Object.defineProperty(anObj, 'slot2', {value: 'bar', writable: true});
     192    Object.defineProperty(anObj, 'slot3', {value: 'baz', enumerable: false});
     193    Object.defineProperty(anObj, 'slot4', {value: 'goo', configurable: false});
     194    shouldBe("anObj.slot1", '"foo"');
     195    shouldBe("anObj.slot2", '"bar"');
     196    anObj.slot2 = 'bad value';
     197    shouldBeTrue("anObj.propertyIsEnumerable('slot1')");
     198    shouldBeFalse("anObj.propertyIsEnumerable('slot2')");
     199    delete anObj.slot4;
     200    shouldBe("anObj.slot4", '"goo"');
     201
     202    // Test case from https://bugs.webkit.org/show_bug.cgi?id=48911
     203    Object.defineProperty(Object.getPrototypeOf(anObj), 'slot5', {get: function() { return this._Slot5; }, set: function(v) { this._Slot5 = v; }, configurable: false});
     204    anObj.slot5 = 123;
     205    shouldBe("anObj.slot5", '123');
     206    shouldBe("anObj._Slot5", '123');
     207    shouldBeUndefined("Object.getOwnPropertyDescriptor(anObj, 'slot5')");
     208    Object.defineProperty(anObj, 'slot5', { value: 456 });
     209    shouldBe("anObj.slot5", '456');
     210    shouldBe("anObj._Slot5", '123');
     211    shouldBe("Object.getOwnPropertyDescriptor(anObj, 'slot5').value", '456');
     212}
     213var anObj = {};
     214testObject();
     215var anObj = this;
     216testObject();
Note: See TracChangeset for help on using the changeset viewer.