Source/JavaScriptCore/ChangeLog

 12012-05-14 Erik Arvidsson <arv@chromium.org>
 2
 3 Make DOM Exceptions Errors
 4 https://bugs.webkit.org/show_bug.cgi?id=85078
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
 9
 10 For JSC we have access to the Error.prototype from the binding code.
 11
 12 For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
 13 set the prototype as needed.
 14
 15 * JavaScriptCore.xcodeproj/project.pbxproj:
 16 * runtime/JSGlobalObject.cpp:
 17 (JSC::JSGlobalObject::reset):
 18 * runtime/JSGlobalObject.h:
 19 (JSC):
 20 (JSGlobalObject):
 21 (JSC::JSGlobalObject::errorPrototype):
 22
1232012-05-10 Gavin Barraclough <barraclough@apple.com>
224
325 Cache inheritorID on JSFunction

Source/WebCore/ChangeLog

 12012-05-14 Erik Arvidsson <arv@chromium.org>
 2
 3 Make DOM Exceptions Errors
 4 https://bugs.webkit.org/show_bug.cgi?id=85078
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
 9
 10 For JSC we have access to the Error.prototype from the binding code.
 11
 12 For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
 13 set the prototype as needed.
 14
 15 Updated test: fast/dom/DOMException/prototype-object.html
 16
 17 * ForwardingHeaders/runtime/ErrorPrototype.h: Added.
 18 * bindings/scripts/CodeGeneratorJS.pm:
 19 (GenerateHeader):
 20 (GenerateImplementation):
 21 * bindings/scripts/CodeGeneratorV8.pm:
 22 (GenerateNamedConstructorCallback):
 23 (GenerateImplementation):
 24 * bindings/scripts/IDLAttributes.txt:
 25 * bindings/scripts/test/JS/JSFloat64Array.h:
 26 * bindings/scripts/test/JS/JSTestException.cpp:
 27 (WebCore::JSTestException::createPrototype):
 28 * bindings/scripts/test/JS/JSTestException.h:
 29 * bindings/scripts/test/JS/JSTestNode.h:
 30 * bindings/scripts/test/V8/V8Float64Array.cpp:
 31 (WebCore):
 32 * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
 33 (WebCore):
 34 * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
 35 (WebCore):
 36 * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
 37 (WebCore):
 38 * bindings/scripts/test/V8/V8TestEventTarget.cpp:
 39 (WebCore):
 40 * bindings/scripts/test/V8/V8TestException.cpp:
 41 (WebCore):
 42 * bindings/scripts/test/V8/V8TestInterface.cpp:
 43 (WebCore):
 44 * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
 45 (WebCore):
 46 * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
 47 (WebCore):
 48 * bindings/scripts/test/V8/V8TestNode.cpp:
 49 (WebCore):
 50 * bindings/scripts/test/V8/V8TestObj.cpp:
 51 (WebCore):
 52 * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
 53 (WebCore):
 54 * bindings/v8/NPV8Object.cpp:
 55 (WebCore::npObjectTypeInfo):
 56 * bindings/v8/V8BindingPerContextData.cpp:
 57 (WebCore):
 58 (WebCore::V8BindingPerContextData::init):
 59 (WebCore::V8BindingPerContextData::createWrapperFromCacheSlowCase):
 60 (WebCore::V8BindingPerContextData::constructorForTypeSlowCase):
 61 * bindings/v8/V8BindingPerContextData.h:
 62 (V8BindingPerContextData):
 63 * bindings/v8/V8HiddenPropertyName.h:
 64 (WebCore):
 65 * bindings/v8/WrapperTypeInfo.h:
 66 (WebCore):
 67 (WrapperTypeInfo):
 68 * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
 69 (WebCore):
 70
1712012-05-10 Varun Jain <varunjain@google.com>
272
373 [chromium] Trigger context menu for long press gesture

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

505505 A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
506506 A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
507507 BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
508  BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; };
 508 BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
509509 BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; };
510510 BC02E9130E1839DB000F9297 /* NativeErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E90B0E1839DB000F9297 /* NativeErrorPrototype.h */; };
511  BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E98B0E183E38000F9297 /* ErrorInstance.h */; };
 511 BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E98B0E183E38000F9297 /* ErrorInstance.h */; settings = {ATTRIBUTES = (Private, ); }; };
512512 BC1166020E1997B4008066DD /* DateInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1166010E1997B1008066DD /* DateInstance.h */; settings = {ATTRIBUTES = (Private, ); }; };
513513 BC11667B0E199C05008066DD /* InternalFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = BC11667A0E199C05008066DD /* InternalFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
514514 BC1167DA0E19BCC9008066DD /* JSCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1167D80E19BCC9008066DD /* JSCell.h */; settings = {ATTRIBUTES = (Private, ); }; };

Source/JavaScriptCore/runtime/JSGlobalObject.cpp

@@void JSGlobalObject::reset(JSValue prototype)
241241
242242 m_methodCallDummy.set(exec->globalData(), this, constructEmptyObject(exec));
243243
244  ErrorPrototype* errorPrototype = ErrorPrototype::create(exec, this, ErrorPrototype::createStructure(exec->globalData(), this, m_objectPrototype.get()));
245  m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), this, errorPrototype));
 244 m_errorPrototype.set(exec->globalData(), this, ErrorPrototype::create(exec, this, ErrorPrototype::createStructure(exec->globalData(), this, m_objectPrototype.get())));
 245 m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), this, m_errorPrototype.get()));
246246
247247 // Constructors
248248

@@void JSGlobalObject::reset(JSValue prototype)
256256
257257 m_regExpConstructor.set(exec->globalData(), this, RegExpConstructor::create(exec, this, RegExpConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), m_regExpPrototype.get()));
258258
259  m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), errorPrototype));
 259 m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), m_errorPrototype.get()));
260260
261  Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, errorPrototype);
 261 Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, m_errorPrototype.get());
262262 Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get());
263263 m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
264264 m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError"));

@@void JSGlobalObject::reset(JSValue prototype)
275275 m_numberPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, numberConstructor, DontEnum);
276276 m_datePrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, dateConstructor, DontEnum);
277277 m_regExpPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_regExpConstructor.get(), DontEnum);
278  errorPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
 278 m_errorPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
279279
280280 putDirectWithoutTransition(exec->globalData(), Identifier(exec, "Object"), objectConstructor, DontEnum);
281281 putDirectWithoutTransition(exec->globalData(), Identifier(exec, "Function"), functionConstructor, DontEnum);

Source/JavaScriptCore/runtime/JSGlobalObject.h

@@namespace JSC {
4141 class DatePrototype;
4242 class Debugger;
4343 class ErrorConstructor;
 44 class ErrorPrototype;
4445 class FunctionPrototype;
4546 class GetterSetter;
4647 class GlobalCodeBlock;

@@namespace JSC {
114115 WriteBarrier<NumberPrototype> m_numberPrototype;
115116 WriteBarrier<DatePrototype> m_datePrototype;
116117 WriteBarrier<RegExpPrototype> m_regExpPrototype;
 118 WriteBarrier<ErrorPrototype> m_errorPrototype;
117119
118120 WriteBarrier<Structure> m_argumentsStructure;
119121 WriteBarrier<Structure> m_arrayStructure;

@@namespace JSC {
245247 NumberPrototype* numberPrototype() const { return m_numberPrototype.get(); }
246248 DatePrototype* datePrototype() const { return m_datePrototype.get(); }
247249 RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
 250 ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); }
248251
249252 JSObject* methodCallDummy() const { return m_methodCallDummy.get(); }
250253

Source/WebCore/ForwardingHeaders/runtime/ErrorPrototype.h

 1#ifndef WebCore_FWD_ErrorPrototype_h
 2#define WebCore_FWD_ErrorPrototype_h
 3#include <JavaScriptCore/ErrorPrototype.h>
 4#endif

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateHeader
645645 } else {
646646 $headerIncludes{"JSDOMBinding.h"} = 1;
647647 $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1;
 648 }
 649
 650 if ($dataNode->isException) {
 651 $headerIncludes{"<runtime/ErrorPrototype.h>"} = 1;
 652 } else {
648653 $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1;
649654 }
650655

@@sub GenerateImplementation
15911596 if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) {
15921597 push(@implContent, "JSObject* ${className}::createPrototype(ExecState* exec, JSGlobalObject* globalObject)\n");
15931598 push(@implContent, "{\n");
 1599
15941600 if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") {
15951601 push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(exec->globalData(), globalObject, ${parentClassName}Prototype::self(exec, globalObject)));\n");
15961602 } else {
1597  push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));\n");
 1603 my $prototype = $dataNode->isException ? "errorPrototype" : "objectPrototype";
 1604 push(@implContent, " return ${className}Prototype::create(exec->globalData(), globalObject, ${className}Prototype::createStructure(globalObject->globalData(), globalObject, globalObject->${prototype}()));\n");
15981605 }
15991606 push(@implContent, "}\n\n");
16001607 }

Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

@@sub GenerateNamedConstructorCallback
18721872
18731873 if ($dataNode->extendedAttributes->{"ActiveDOMObject"}) {
18741874 push(@implContent, <<END);
1875 WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, V8${implClassName}::derefObject, V8${implClassName}::toActiveDOMObject, 0 };
 1875WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, V8${implClassName}::derefObject, V8${implClassName}::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
18761876
18771877END
18781878 } else {
18791879 push(@implContent, <<END);
1880 WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, 0, 0, 0 };
 1880WrapperTypeInfo V8${implClassName}Constructor::info = { V8${implClassName}Constructor::GetTemplate, 0, 0, 0, WrapperTypeObjectPrototype };
18811881
18821882END
18831883 }

@@sub GenerateImplementation
23362336 }
23372337 push(@implContentDecls, "namespace WebCore {\n\n");
23382338 my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0";
2339  push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, ${toActive}, ${parentClassInfo} };\n\n");
 2339
 2340 my $WrapperTypePrototype = $dataNode->isException ? "WrapperTypeErrorPrototype" : "WrapperTypeObjectPrototype";
 2341
 2342 push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, $toActive, $parentClassInfo, $WrapperTypePrototype };\n\n");
23402343 push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n");
 2344
23412345 push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n");
23422346
23432347 my $hasConstructors = 0;

Source/WebCore/bindings/scripts/IDLAttributes.txt

1919#
2020
2121ActiveDOMObject
 22ArrayClass
2223CPPPureInterface
2324CachedAttribute
2425CallWith=ScriptExecutionContext|ScriptState|ScriptArguments|CallStack

Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.h

2424#include "JSArrayBufferView.h"
2525#include "JSDOMBinding.h"
2626#include <runtime/JSObject.h>
 27#include <runtime/ObjectPrototype.h>
2728#include <wtf/Float64Array.h>
2829
2930namespace WebCore {

Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp

@@void JSTestException::finishCreation(JSGlobalData& globalData)
104104
105105JSObject* JSTestException::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
106106{
107  return JSTestExceptionPrototype::create(exec->globalData(), globalObject, JSTestExceptionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
 107 return JSTestExceptionPrototype::create(exec->globalData(), globalObject, JSTestExceptionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->errorPrototype()));
108108}
109109
110110void JSTestException::destroy(JSC::JSCell* cell)

Source/WebCore/bindings/scripts/test/JS/JSTestException.h

2323
2424#include "JSDOMBinding.h"
2525#include "TestException.h"
 26#include <runtime/ErrorPrototype.h>
2627#include <runtime/JSGlobalObject.h>
2728#include <runtime/JSObject.h>
28 #include <runtime/ObjectPrototype.h>
2929
3030namespace WebCore {
3131

Source/WebCore/bindings/scripts/test/JS/JSTestNode.h

2525#include "JSNode.h"
2626#include "TestNode.h"
2727#include <runtime/JSObject.h>
 28#include <runtime/ObjectPrototype.h>
2829
2930namespace WebCore {
3031

Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp

4242
4343namespace WebCore {
4444
45 WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info };
 45WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info, WrapperTypeObjectPrototype };
4646
4747namespace Float64ArrayV8Internal {
4848

Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp

3434
3535namespace WebCore {
3636
37 WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0 };
 37WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, WrapperTypeObjectPrototype };
3838
3939namespace TestActiveDOMObjectV8Internal {
4040

Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp

3333
3434namespace WebCore {
3535
36 WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0 };
 36WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0, WrapperTypeObjectPrototype };
3737
3838namespace TestCustomNamedGetterV8Internal {
3939

Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp

3333
3434namespace WebCore {
3535
36 WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0 };
 36WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0, WrapperTypeObjectPrototype };
3737
3838namespace TestEventConstructorV8Internal {
3939

Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp

3636
3737namespace WebCore {
3838
39 WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0 };
 39WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0, WrapperTypeObjectPrototype };
4040
4141namespace TestEventTargetV8Internal {
4242

Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp

3131
3232namespace WebCore {
3333
34 WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0 };
 34WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0, WrapperTypeErrorPrototype };
3535
3636namespace TestExceptionV8Internal {
3737

Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

4141
4242namespace WebCore {
4343
44 WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0 };
 44WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
4545
4646namespace TestInterfaceV8Internal {
4747

Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp

3434
3535namespace WebCore {
3636
37 WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0 };
 37WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0, WrapperTypeObjectPrototype };
3838
3939namespace TestMediaQueryListListenerV8Internal {
4040

Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp

3333
3434namespace WebCore {
3535
36 WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 };
 36WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
3737
3838namespace TestNamedConstructorV8Internal {
3939

@@template <typename T> void V8_USE(T) { }
4141
4242} // namespace TestNamedConstructorV8Internal
4343
44 WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 };
 44WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, WrapperTypeObjectPrototype };
4545
4646static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8::Arguments& args)
4747{

Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp

3232
3333namespace WebCore {
3434
35 WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, &V8Node::info };
 35WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, &V8Node::info, WrapperTypeObjectPrototype };
3636
3737namespace TestNodeV8Internal {
3838

Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

7373
7474namespace WebCore {
7575
76 WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0 };
 76WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0, WrapperTypeObjectPrototype };
7777
7878namespace TestObjV8Internal {
7979

Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp

3939
4040namespace WebCore {
4141
42 WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0 };
 42WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0, WrapperTypeObjectPrototype };
4343
4444namespace TestSerializedScriptValueInterfaceV8Internal {
4545

Source/WebCore/bindings/v8/NPV8Object.cpp

@@namespace WebCore {
5353
5454WrapperTypeInfo* npObjectTypeInfo()
5555{
56  static WrapperTypeInfo typeInfo = { 0, 0, 0, 0 };
 56 static WrapperTypeInfo typeInfo = { 0, 0, 0, 0, WrapperTypeObjectPrototype };
5757 return &typeInfo;
5858}
5959

Source/WebCore/bindings/v8/V8BindingPerContextData.cpp

@@void V8BindingPerContextData::dispose()
5656 }
5757}
5858
 59#define V8_STORE_PRIMORDIAL(name, Name) \
 60{ \
 61 ASSERT(m_##name##Prototype.get().IsEmpty()); \
 62 v8::Handle<v8::String> symbol = v8::String::NewSymbol(#Name); \
 63 if (symbol.IsEmpty()) \
 64 return false; \
 65 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context->Global()->Get(symbol)); \
 66 if (object.IsEmpty()) \
 67 return false; \
 68 v8::Handle<v8::Value> prototypeValue = object->Get(prototypeString); \
 69 if (prototypeValue.IsEmpty()) \
 70 return false; \
 71 m_##name##Prototype.set(prototypeValue); \
 72}
 73
5974bool V8BindingPerContextData::init()
6075{
61  ASSERT(m_objectPrototype.get().IsEmpty());
62 
63  v8::Handle<v8::String> objectString = v8::String::New("Object");
64  v8::Handle<v8::String> prototypeString = v8::String::New("prototype");
65  if (objectString.IsEmpty() || prototypeString.IsEmpty())
 76 v8::Handle<v8::String> prototypeString = v8::String::NewSymbol("prototype");
 77 if (prototypeString.IsEmpty())
6678 return false;
6779
68  v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context->Global()->Get(objectString));
69  if (object.IsEmpty())
70  return false;
71  v8::Handle<v8::Value> objectPrototype = object->Get(prototypeString);
72  if (objectPrototype.IsEmpty())
73  return false;
 80 V8_STORE_PRIMORDIAL(error, Error);
 81 V8_STORE_PRIMORDIAL(object, Object);
7482
75  m_objectPrototype.set(objectPrototype);
7683 return true;
7784}
7885
 86#undef V8_STORE_PRIMORDIAL
 87
7988v8::Local<v8::Object> V8BindingPerContextData::createWrapperFromCacheSlowCase(WrapperTypeInfo* type)
8089{
 90 ASSERT(!m_errorPrototype.get().IsEmpty());
8191 ASSERT(!m_objectPrototype.get().IsEmpty());
8292
8393 v8::Context::Scope scope(m_context);

@@v8::Local<v8::Object> V8BindingPerContextData::createWrapperFromCacheSlowCase(Wr
92102
93103v8::Local<v8::Function> V8BindingPerContextData::constructorForTypeSlowCase(WrapperTypeInfo* type)
94104{
 105 ASSERT(!m_errorPrototype.get().IsEmpty());
95106 ASSERT(!m_objectPrototype.get().IsEmpty());
96107
97108 v8::Context::Scope scope(m_context);

@@v8::Local<v8::Function> V8BindingPerContextData::constructorForTypeSlowCase(Wrap
104115
105116 function->SetPrototype(m_objectPrototype.get());
106117
 118 if (type->wrapperTypePrototype == WrapperTypeErrorPrototype) {
 119 v8::Local<v8::Value> prototypeValue = function->Get(v8::String::NewSymbol("prototype"));
 120 if (prototypeValue->IsObject())
 121 v8::Local<v8::Object>::Cast(prototypeValue)->SetPrototype(m_errorPrototype.get());
 122 }
 123
107124 m_constructorMap.set(type, v8::Persistent<v8::Function>::New(function));
108125
109126 return function;

Source/WebCore/bindings/v8/V8BindingPerContextData.h

@@private:
9090 ConstructorMap m_constructorMap;
9191
9292 v8::Handle<v8::Context> m_context;
 93 OwnHandle<v8::Value> m_errorPrototype;
9394 OwnHandle<v8::Value> m_objectPrototype;
9495};
9596

Source/WebCore/bindings/v8/V8HiddenPropertyName.h

3636namespace WebCore {
3737
3838#define V8_HIDDEN_PROPERTIES(V) \
39  V(objectPrototype) \
4039 V(listener) \
4140 V(attributeListener) \
4241 V(scriptState) \

Source/WebCore/bindings/v8/WrapperTypeInfo.h

@@namespace WebCore {
4646 typedef v8::Persistent<v8::FunctionTemplate> (*GetTemplateFunction)();
4747 typedef void (*DerefObjectFunction)(void*);
4848 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
49 
 49
 50 enum WrapperTypePrototype {
 51 WrapperTypeObjectPrototype,
 52 WrapperTypeErrorPrototype
 53 };
 54
5055 // This struct provides a way to store a bunch of information that is helpful when unwrapping
5156 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo member, so
5257 // comparing pointers is a safe way to determine if types match.
5358 struct WrapperTypeInfo {
54 
 59
5560 static WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapper)
5661 {
5762 return reinterpret_cast<WrapperTypeInfo*>(v8::External::Unwrap(typeInfoWrapper));

@@namespace WebCore {
9297 const DerefObjectFunction derefObjectFunction;
9398 const ToActiveDOMObjectFunction toActiveDOMObjectFunction;
9499 const WrapperTypeInfo* parentClass;
 100 const WrapperTypePrototype wrapperTypePrototype;
95101 };
96102}
97103

Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp

4444
4545namespace WebCore {
4646
47 WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, 0, 0 };
 47WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, 0, 0, WrapperTypeObjectPrototype };
4848
4949static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arguments& args)
5050{

LayoutTests/ChangeLog

 12012-05-14 Erik Arvidsson <arv@chromium.org>
 2
 3 Make DOM Exceptions Errors
 4 https://bugs.webkit.org/show_bug.cgi?id=85078
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 WebIDL mandates that exceptions should have Error.prototype on its prototype chain.
 9
 10 For JSC we have access to the Error.prototype from the binding code.
 11
 12 For V8 we set a field in the WrapperTypeInfo and when the constructor function is created we
 13 set the prototype as needed.
 14
 15 * fast/dom/DOMException/prototype-object-expected.txt:
 16 * fast/dom/DOMException/prototype-object.html:
 17 * fast/dom/DOMException/resources/prototype-object.js: Removed.
 18 * platform/chromium-mac/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Removed.
 19 * platform/chromium-mac/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Removed.
 20 * platform/chromium-mac/fast/dynamic/015-expected.txt:
 21 * platform/chromium-mac/svg/filters/feBlend-invalid-mode-expected.txt: Removed.
 22 * platform/chromium-win/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Removed.
 23 * platform/chromium-win/fast/dynamic/015-expected.txt:
 24 * platform/chromium-win/svg/filters/feBlend-invalid-mode-expected.txt: Removed.
 25 * platform/chromium/dom/xhtml/level3/core/documentnormalizedocument10-expected.txt: Added.
 26 * platform/chromium/dom/xhtml/level3/core/documentsetxmlversion03-expected.txt: Added.
 27 * platform/chromium/fast/dom/DOMException/prototype-object-expected.txt:
 28 * platform/chromium/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt: Renamed from LayoutTests/platform/chromium-win/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt.
 29 * platform/chromium/fast/dom/insertAdjacentHTML-DocumentFragment-crash-expected.txt:
 30 * platform/chromium/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt: Added.
 31 * platform/chromium/fast/events/remove-target-with-shadow-in-drag-expected.txt:
 32 * platform/chromium/fast/inspector-support/uncaught-dom1-exception-expected.txt:
 33 * platform/chromium/fast/inspector-support/uncaught-dom3-exception-expected.txt:
 34 * platform/chromium/fast/inspector-support/uncaught-dom8-exception-expected.txt:
 35 * platform/chromium/svg/filters/feBlend-invalid-mode-expected.txt: Added.
 36
1372012-05-10 Varun Jain <varunjain@google.com>
238
339 [chromium] Trigger context menu for long press gesture

LayoutTests/fast/dom/DOMException/prototype-object-expected.txt

1 DOMException needs a real prototype: http://bugs.webkit.org/show_bug.cgi?id=16637
 1This tests the prototype chain of DOMException objects.
22
33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

@@On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
66PASS e.toString() is "Error: HIERARCHY_REQUEST_ERR: DOM Exception 3"
77PASS Object.prototype.toString.call(e) is "[object DOMException]"
88PASS Object.prototype.toString.call(e.__proto__) is "[object DOMExceptionPrototype]"
 9PASS Object.prototype.toString.call(e.__proto__.__proto__) is "[object Error]"
910PASS e.constructor.toString() is "[object DOMExceptionConstructor]"
 11PASS e instanceof DOMException is true
 12PASS e instanceof Error is true
1013PASS e.constructor is window.DOMException
1114PASS e.HIERARCHY_REQUEST_ERR is e.constructor.HIERARCHY_REQUEST_ERR
1215PASS e.HIERARCHY_REQUEST_ERR is 3
 16PASS e.code is 3
 17PASS e.name is "HIERARCHY_REQUEST_ERR"
 18PASS e.message is "HIERARCHY_REQUEST_ERR: DOM Exception 3"
1319PASS successfullyParsed is true
1420
1521TEST COMPLETE

LayoutTests/fast/dom/DOMException/prototype-object.html

1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
 1<!DOCTYPE html>
42<script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script src="resources/prototype-object.js"></script>
 3<script>
 4
 5description("This tests the prototype chain of DOMException objects.")
 6
 7var e;
 8try {
 9 document.appendChild(document);
 10 // raises a HIERARCHY_REQUEST_ERR
 11} catch (err) {
 12 e = err;
 13}
 14
 15shouldBeEqualToString("e.toString()", "Error: HIERARCHY_REQUEST_ERR: DOM Exception 3");
 16shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMException]");
 17shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[object DOMExceptionPrototype]");
 18shouldBeEqualToString("Object.prototype.toString.call(e.__proto__.__proto__)", "[object Error]");
 19shouldBeEqualToString("e.constructor.toString()", "[object DOMExceptionConstructor]");
 20shouldBeTrue("e instanceof DOMException");
 21shouldBeTrue("e instanceof Error");
 22shouldBe("e.constructor", "window.DOMException");
 23shouldBe("e.HIERARCHY_REQUEST_ERR", "e.constructor.HIERARCHY_REQUEST_ERR");
 24shouldBe("e.HIERARCHY_REQUEST_ERR", "3");
 25shouldBe("e.code", "3");
 26shouldBeEqualToString("e.name", "HIERARCHY_REQUEST_ERR");
 27shouldBeEqualToString("e.message", "HIERARCHY_REQUEST_ERR: DOM Exception 3");
 28
 29</script>
830<script src="../../js/resources/js-test-post.js"></script>
9 </body>
10 </html>

LayoutTests/fast/dom/DOMException/resources/prototype-object.js

1 description("DOMException needs a real prototype: http://bugs.webkit.org/show_bug.cgi?id=16637")
2 
3 var e;
4 try {
5  document.body.appendChild(document.documentElement);
6  // raises a HIERARCHY_REQUEST_ERR
7 } catch (err) {
8  e = err;
9 }
10 
11 shouldBeEqualToString("e.toString()", "Error: HIERARCHY_REQUEST_ERR: DOM Exception 3");
12 shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMException]");
13 shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[object DOMExceptionPrototype]");
14 shouldBeEqualToString("e.constructor.toString()", "[object DOMExceptionConstructor]");
15 shouldBe("e.constructor", "window.DOMException");
16 shouldBe("e.HIERARCHY_REQUEST_ERR", "e.constructor.HIERARCHY_REQUEST_ERR");
17 shouldBe("e.HIERARCHY_REQUEST_ERR", "3");

LayoutTests/platform/chromium-mac/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt

1 CONSOLE MESSAGE: line 7: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
2 This passes if it does not crash. (see https://bugs.webkit.org/show_bug.cgi?id=18958)

LayoutTests/platform/chromium-mac/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt

1 CONSOLE MESSAGE: line 10: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
2 

LayoutTests/platform/chromium-mac/fast/dynamic/015-expected.txt

1 CONSOLE MESSAGE: line 16: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
 1CONSOLE MESSAGE: line 16: Uncaught INDEX_SIZE_ERR: INDEX_SIZE_ERR: DOM Exception 1
22layer at (0,0) size 800x600
33 RenderView at (0,0) size 800x600
44layer at (0,0) size 800x600

LayoutTests/platform/chromium-mac/svg/filters/feBlend-invalid-mode-expected.txt

1 CONSOLE MESSAGE: line 14: Uncaught Error: SVG_INVALID_VALUE_ERR: DOM SVG Exception 1
2 PASS: Invalid blend modes do not trigger a crash.

LayoutTests/platform/chromium-win/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt

1 CONSOLE MESSAGE: line 7: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
2 This passes if it does not crash. (see https://bugs.webkit.org/show_bug.cgi?id=18958)

LayoutTests/platform/chromium-win/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt

1 CONSOLE MESSAGE: line 10: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
2 

LayoutTests/platform/chromium-win/fast/dynamic/015-expected.txt

1 CONSOLE MESSAGE: line 16: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
 1CONSOLE MESSAGE: line 16: Uncaught INDEX_SIZE_ERR: INDEX_SIZE_ERR: DOM Exception 1
22layer at (0,0) size 800x600
33 RenderView at (0,0) size 800x600
44layer at (0,0) size 800x600

LayoutTests/platform/chromium-win/svg/filters/feBlend-invalid-mode-expected.txt

1 CONSOLE MESSAGE: line 14: Uncaught Error: SVG_INVALID_VALUE_ERR: DOM SVG Exception 1
2 PASS: Invalid blend modes do not trigger a crash.

LayoutTests/platform/chromium/dom/xhtml/level3/core/documentnormalizedocument10-expected.txt

 1Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormalizedocument10
 2Status error
 3Message Line undefined: HIERARCHY_REQUEST_ERR

LayoutTests/platform/chromium/dom/xhtml/level3/core/documentsetxmlversion03-expected.txt

 1Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetxmlversion03
 2Status error
 3Message Line undefined: NOT_SUPPORTED_ERR

LayoutTests/platform/chromium/fast/dom/DOMException/prototype-object-expected.txt

1 DOMException needs a real prototype: http://bugs.webkit.org/show_bug.cgi?id=16637
 1This tests the prototype chain of DOMException objects.
22
33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

@@On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
66PASS e.toString() is "Error: HIERARCHY_REQUEST_ERR: DOM Exception 3"
77PASS Object.prototype.toString.call(e) is "[object DOMException]"
88FAIL Object.prototype.toString.call(e.__proto__) should be [object DOMExceptionPrototype]. Was [object Object].
 9PASS Object.prototype.toString.call(e.__proto__.__proto__) is "[object Error]"
910FAIL e.constructor.toString() should be [object DOMExceptionConstructor]. Was function DOMException() { [native code] }.
 11PASS e instanceof DOMException is true
 12PASS e instanceof Error is true
1013PASS e.constructor is window.DOMException
1114PASS e.HIERARCHY_REQUEST_ERR is e.constructor.HIERARCHY_REQUEST_ERR
1215PASS e.HIERARCHY_REQUEST_ERR is 3
 16PASS e.code is 3
 17PASS e.name is "HIERARCHY_REQUEST_ERR"
 18PASS e.message is "HIERARCHY_REQUEST_ERR: DOM Exception 3"
1319PASS successfullyParsed is true
1420
1521TEST COMPLETE

LayoutTests/platform/chromium/fast/dom/NamedNodeMap-setNamedItem-crash-expected.txt

 1CONSOLE MESSAGE: line 7: Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOM Exception 8
 2This passes if it does not crash. (see https://bugs.webkit.org/show_bug.cgi?id=18958)

LayoutTests/platform/chromium/fast/dom/insertAdjacentHTML-DocumentFragment-crash-expected.txt

1 CONSOLE MESSAGE: line 9: Uncaught Error: NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7
 1CONSOLE MESSAGE: line 9: Uncaught NO_MODIFICATION_ALLOWED_ERR: NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7
22This test passes if it doesn't crash (or ASSERT).

LayoutTests/platform/chromium/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt

 1CONSOLE MESSAGE: line 10: Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOM Exception 8
 2

LayoutTests/platform/chromium/fast/events/remove-target-with-shadow-in-drag-expected.txt

1 CONSOLE MESSAGE: line 34: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
2 CONSOLE MESSAGE: line 34: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
 1CONSOLE MESSAGE: line 34: Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOM Exception 8
 2CONSOLE MESSAGE: line 34: Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOM Exception 8
33PASS. DRT didn't crash.

LayoutTests/platform/chromium/fast/inspector-support/uncaught-dom1-exception-expected.txt

1 CONSOLE MESSAGE: line 13: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
 1CONSOLE MESSAGE: line 13: Uncaught INDEX_SIZE_ERR: INDEX_SIZE_ERR: DOM Exception 1
22This tests that we are getting the correct message for DOM Exception 1: INDEX_SIZE_ERR.

LayoutTests/platform/chromium/fast/inspector-support/uncaught-dom3-exception-expected.txt

1 CONSOLE MESSAGE: line 9: Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3
 1CONSOLE MESSAGE: line 9: Uncaught HIERARCHY_REQUEST_ERR: HIERARCHY_REQUEST_ERR: DOM Exception 3
22This tests that we are getting the correct message for DOM Exception 3: HIERARCHY_REQUEST_ERR.

LayoutTests/platform/chromium/fast/inspector-support/uncaught-dom8-exception-expected.txt

1 CONSOLE MESSAGE: line 9: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
 1CONSOLE MESSAGE: line 9: Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOM Exception 8
22This tests that we are getting the correct message for DOM Exception 8: NOT_FOUND_ERR.

LayoutTests/platform/chromium/svg/filters/feBlend-invalid-mode-expected.txt

 1CONSOLE MESSAGE: line 14: Uncaught SVG_INVALID_VALUE_ERR: SVG_INVALID_VALUE_ERR: DOM SVG Exception 1
 2PASS: Invalid blend modes do not trigger a crash.