Changeset 92618 in webkit


Ignore:
Timestamp:
Aug 8, 2011 12:09:51 PM (13 years ago)
Author:
oliver@apple.com
Message:

Non-extensibility does not prevent mutating Prototype?
https://bugs.webkit.org/show_bug.cgi?id=65832

Reviewed by Gavin Barraclough.

../../../../Volumes/Data/git/WebKit/OpenSource/LayoutTests:

Add tests to ensure we can't assign to proto when an object
is not extensible.

  • fast/js/preventExtensions-expected.txt:
  • fast/js/script-tests/preventExtensions.js:

../../../../Volumes/Data/git/WebKit/OpenSource/Source/JavaScriptCore:

Disallow mutation of proto on objects that are not extensible.

  • runtime/JSObject.cpp:

(JSC::JSObject::put):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92616 r92618  
     12011-08-08  Oliver Hunt  <oliver@apple.com>
     2
     3        Non-extensibility does not prevent mutating [[Prototype]]
     4        https://bugs.webkit.org/show_bug.cgi?id=65832
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Add tests to ensure we can't assign to __proto__ when an object
     9        is not extensible.
     10
     11        * fast/js/preventExtensions-expected.txt:
     12        * fast/js/script-tests/preventExtensions.js:
     13
    1142011-08-08  Jian Li  <jianli@chromium.org>
    215
  • trunk/LayoutTests/fast/js/preventExtensions-expected.txt

    r90402 r92618  
    1212PASS test(freeze(obj())) is "(a:1)(b:2)SF"
    1313PASS Object.preventExtensions(Math.sin) is Math.sin
     14PASS var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" }; o.newProp; is undefined.
     15PASS "use strict"; var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" }; threw exception TypeError: Attempted to assign to readonly property..
    1416PASS successfullyParsed is true
    1517
  • trunk/LayoutTests/fast/js/script-tests/preventExtensions.js

    r90402 r92618  
    6969shouldBe('Object.preventExtensions(Math.sin)', 'Math.sin');
    7070
     71shouldBeUndefined('var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" }; o.newProp;');
     72shouldThrow('"use strict"; var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" };');
     73
    7174successfullyParsed = true;
  • trunk/Source/JavaScriptCore/ChangeLog

    r92593 r92618  
     12011-08-08  Oliver Hunt  <oliver@apple.com>
     2
     3        Non-extensibility does not prevent mutating [[Prototype]]
     4        https://bugs.webkit.org/show_bug.cgi?id=65832
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Disallow mutation of __proto__ on objects that are not extensible.
     9
     10        * runtime/JSObject.cpp:
     11        (JSC::JSObject::put):
     12
    1132011-08-08  Filip Pizlo  <fpizlo@apple.com>
    214
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r91194 r92618  
    111111        if (!value.isObject() && !value.isNull())
    112112            return;
     113
     114        if (!isExtensible()) {
     115            if (slot.isStrictMode())
     116                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     117            return;
     118        }
     119           
    113120        if (!setPrototypeWithCycleCheck(exec->globalData(), value))
    114121            throwError(exec, createError(exec, "cyclic __proto__ value"));
Note: See TracChangeset for help on using the changeset viewer.