Ignore:
Timestamp:
Oct 30, 2015, 2:37:25 PM (10 years ago)
Author:
[email protected]
Message:

[ES6] Add support for toStringTag
https://bugs.webkit.org/show_bug.cgi?id=150696

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

This patch adds support for Symbol.toStringTag. This is a simple
feature, if an object passed to Object.prototype.toString() has a
toStringTag we use the tag in the string rather than the class info.
Added a test that checks this works for all the default supported classes
along with the corresponding prototype and custom cases.

  • runtime/ArrayIteratorPrototype.cpp:

(JSC::ArrayIteratorPrototype::finishCreation):

  • runtime/CommonIdentifiers.h:
  • runtime/JSArrayBufferPrototype.cpp:

(JSC::JSArrayBufferPrototype::finishCreation):

  • runtime/JSDataViewPrototype.cpp:

(JSC::JSDataViewPrototype::finishCreation):

  • runtime/JSDataViewPrototype.h:
  • runtime/JSModuleNamespaceObject.cpp:

(JSC::JSModuleNamespaceObject::finishCreation):

  • runtime/JSONObject.cpp:

(JSC::JSONObject::finishCreation):

  • runtime/JSPromisePrototype.cpp:

(JSC::JSPromisePrototype::finishCreation):

  • runtime/JSTypedArrayViewPrototype.cpp:

(JSC::typedArrayViewProtoGetterFuncToStringTag):
(JSC::JSTypedArrayViewPrototype::finishCreation):

  • runtime/MapIteratorPrototype.cpp:

(JSC::MapIteratorPrototype::finishCreation):

  • runtime/MapPrototype.cpp:

(JSC::MapPrototype::finishCreation):

  • runtime/MathObject.cpp:

(JSC::MathObject::finishCreation):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncToString):

  • runtime/SetIteratorPrototype.cpp:

(JSC::SetIteratorPrototype::finishCreation):

  • runtime/SetPrototype.cpp:

(JSC::SetPrototype::finishCreation):

  • runtime/SmallStrings.cpp:

(JSC::SmallStrings::SmallStrings):
(JSC::SmallStrings::initializeCommonStrings):
(JSC::SmallStrings::visitStrongReferences):

  • runtime/SmallStrings.h:

(JSC::SmallStrings::objectStringStart):

  • runtime/StringIteratorPrototype.cpp:

(JSC::StringIteratorPrototype::finishCreation):

  • runtime/SymbolPrototype.cpp:

(JSC::SymbolPrototype::finishCreation):

  • runtime/WeakMapPrototype.cpp:

(JSC::WeakMapPrototype::finishCreation):

  • runtime/WeakSetPrototype.cpp:

(JSC::WeakSetPrototype::finishCreation):

  • tests/modules/namespace.js:
  • tests/stress/symbol-tostringtag.js: Added.

(toStr):
(strName):
(classes.string_appeared_here):

LayoutTests:

Symbol now has toStringTag as a member. Since Object.prototype.toString()
now does a Get on the object being stringed there are new console
error messages when accessing another window's properties.

  • http/tests/history/cross-origin-replace-history-object-child-expected.txt:
  • http/tests/security/cross-frame-access-custom-expected.txt:
  • http/tests/security/cross-frame-access-history-get-expected.txt:
  • http/tests/security/cross-frame-access-object-setPrototypeOf-expected.txt:
  • js/Object-getOwnPropertyNames-expected.txt:
  • js/script-tests/Object-getOwnPropertyNames.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.h

    r190829 r191815  
    110110    }
    111111
     112    JSString* objectStringStart() const { return m_objectStringStart; }
    112113    JSString* nullObjectString() const { return m_nullObjectString; }
    113114    JSString* undefinedObjectString() const { return m_undefinedObjectString; }
     
    132133    JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION)
    133134#undef JSC_COMMON_STRINGS_ATTRIBUTE_DECLARATION
     135    JSString* m_objectStringStart;
    134136    JSString* m_nullObjectString;
    135137    JSString* m_undefinedObjectString;
Note: See TracChangeset for help on using the changeset viewer.