Changeset 90402 in webkit


Ignore:
Timestamp:
Jul 5, 2011 12:02:44 PM (13 years ago)
Author:
barraclough@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=63947
ASSERT running Object.preventExtensions(Math.sin)

Reviewed by Oliver Hunt.

This is due to calling scope() on a hostFunction as a part of
calling createPrototypeProperty to reify the prototype property.
But host functions don't have a prototype property anyway!

Source/JavaScriptCore:

Prevent callling createPrototypeProperty on a host function.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::createPrototypeProperty):
(JSC::JSFunction::preventExtensions):

LayoutTests:

Add test case for calling preventExtensions on a host function.

  • fast/js/preventExtensions-expected.txt:
  • fast/js/script-tests/preventExtensions.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90401 r90402  
     12011-07-05  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=63947
     4        ASSERT running Object.preventExtensions(Math.sin)
     5
     6        Reviewed by Oliver Hunt.
     7
     8        This is due to calling scope() on a hostFunction as a part of
     9        calling createPrototypeProperty to reify the prototype property.
     10        But host functions don't have a prototype property anyway!
     11
     12        Add test case for calling preventExtensions on a host function.
     13
     14        * fast/js/preventExtensions-expected.txt:
     15        * fast/js/script-tests/preventExtensions.js:
     16
    1172011-07-04  Gavin Barraclough  <barraclough@apple.com>
    218
  • trunk/LayoutTests/fast/js/preventExtensions-expected.txt

    r87826 r90402  
    1111PASS test(seal(obj())) is "(a:1)(b:4)S"
    1212PASS test(freeze(obj())) is "(a:1)(b:2)SF"
     13PASS Object.preventExtensions(Math.sin) is Math.sin
    1314PASS successfullyParsed is true
    1415
  • trunk/LayoutTests/fast/js/script-tests/preventExtensions.js

    r87826 r90402  
    6666shouldBe('test(freeze(obj()))', '"(a:1)(b:2)SF"'); // sealed and frozen, CANNOT delete a, CANNOT modify b, and CANNOT add c
    6767
     68// check that we can preventExtensions on a host function.
     69shouldBe('Object.preventExtensions(Math.sin)', 'Math.sin');
     70
    6871successfullyParsed = true;
  • trunk/Source/JavaScriptCore/ChangeLog

    r90401 r90402  
     12011-07-05  Gavin Barraclough  <barraclough@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=63947
     4        ASSERT running Object.preventExtensions(Math.sin)
     5
     6        Reviewed by Oliver Hunt.
     7
     8        This is due to calling scope() on a hostFunction as a part of
     9        calling createPrototypeProperty to reify the prototype property.
     10        But host functions don't have a prototype property anyway!
     11
     12        Prevent callling createPrototypeProperty on a host function.
     13
     14        * runtime/JSFunction.cpp:
     15        (JSC::JSFunction::createPrototypeProperty):
     16        (JSC::JSFunction::preventExtensions):
     17
    1182011-07-04  Gavin Barraclough  <barraclough@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r88315 r90402  
    180180static inline WriteBarrierBase<Unknown>* createPrototypeProperty(JSGlobalData& globalData, JSGlobalObject* globalObject, JSFunction* function)
    181181{
     182    ASSERT(!isHostFunction());
     183
    182184    ExecState* exec = globalObject->globalExec();
    183185    if (WriteBarrierBase<Unknown>* location = function->getDirectLocation(globalData, exec->propertyNames().prototype))
     
    191193void JSFunction::preventExtensions(JSGlobalData& globalData)
    192194{
    193     createPrototypeProperty(globalData, scope()->globalObject.get(), this);
     195    if (!isHostFunction())
     196        createPrototypeProperty(globalData, scope()->globalObject.get(), this);
    194197    JSObject::preventExtensions(globalData);
    195198}
Note: See TracChangeset for help on using the changeset viewer.