Changeset 180173 in webkit
- Timestamp:
- Feb 16, 2015 2:10:12 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r180172 r180173 1 2015-02-16 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Scope details sidebar should label objects with constructor names 4 https://bugs.webkit.org/show_bug.cgi?id=139449 5 6 Reviewed by Timothy Hatcher. 7 8 * inspector/model/remote-object-expected.txt: 9 * inspector/model/remote-object.html: 10 Improve the test to include Objects where previously 11 we would have had poorer class name descriptions. 12 1 13 2015-02-16 Myles C. Maxfield <mmaxfield@apple.com> 2 14 -
trunk/LayoutTests/inspector/model/remote-object-expected.txt
r180113 r180173 1496 1496 1497 1497 ----------------------------------------------------- 1498 EXPRESSION: var Foo2 = function() {}; new Foo2 1499 { 1500 "_type": "object", 1501 "_objectId": "<filtered>", 1502 "_description": "Foo2", 1503 "_preview": { 1504 "type": "object", 1505 "description": "Foo2", 1506 "lossless": true, 1507 "properties": [] 1508 } 1509 } 1510 1511 ----------------------------------------------------- 1512 EXPRESSION: var namespace = {}; namespace.Foo3 = function() {}; new namespace.Foo3 1513 { 1514 "_type": "object", 1515 "_objectId": "<filtered>", 1516 "_description": "Foo3", 1517 "_preview": { 1518 "type": "object", 1519 "description": "Foo3", 1520 "lossless": true, 1521 "properties": [] 1522 } 1523 } 1524 1525 ----------------------------------------------------- 1498 1526 EXPRESSION: function Bar() { this._x = 5 }; Bar.prototype = {constructor: Bar, get x() {return this._x;}}; new Bar 1499 1527 { … … 1519 1547 "name": "x", 1520 1548 "type": "accessor" 1549 } 1550 ] 1551 } 1552 } 1553 1554 ----------------------------------------------------- 1555 EXPRESSION: function Bar2() { this._x = 5 }; Bar.prototype = {get x() {return this._x;}}; new Bar2 1556 { 1557 "_type": "object", 1558 "_objectId": "<filtered>", 1559 "_description": "Bar2", 1560 "_preview": { 1561 "type": "object", 1562 "description": "Bar2", 1563 "lossless": true, 1564 "properties": [ 1565 { 1566 "name": "_x", 1567 "type": "number", 1568 "value": "5" 1521 1569 } 1522 1570 ] -
trunk/LayoutTests/inspector/model/remote-object.html
r179659 r180173 91 91 {expression: "({a:function a(){}, b:function b(){}, get getter(){}, set setter(v){}})"}, 92 92 {expression: "function Foo() {}; new Foo"}, 93 {expression: "var Foo2 = function() {}; new Foo2"}, 94 {expression: "var namespace = {}; namespace.Foo3 = function() {}; new namespace.Foo3"}, 93 95 {expression: "function Bar() { this._x = 5 }; Bar.prototype = {constructor: Bar, get x() {return this._x;}}; new Bar"}, 96 {expression: "function Bar2() { this._x = 5 }; Bar.prototype = {get x() {return this._x;}}; new Bar2"}, 94 97 {expression: "window.loadEvent"}, // window.loadEvent is set inside of <body onload="..."> below. 95 98 {expression: "new ArrayBuffer(16)"}, -
trunk/Source/JavaScriptCore/ChangeLog
r180160 r180173 1 2015-02-16 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Scope details sidebar should label objects with constructor names 4 https://bugs.webkit.org/show_bug.cgi?id=139449 5 6 Reviewed by Timothy Hatcher. 7 8 * inspector/JSInjectedScriptHost.cpp: 9 (Inspector::JSInjectedScriptHost::internalConstructorName): 10 * runtime/Structure.cpp: 11 (JSC::Structure::toStructureShape): 12 Share calculatedClassName. 13 14 * runtime/JSObject.h: 15 * runtime/JSObject.cpp: 16 (JSC::JSObject::calculatedClassName): 17 Elaborate on a way to get an Object's class name. 18 1 19 2015-02-16 Filip Pizlo <fpizlo@apple.com> 2 20 -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
r179429 r180173 97 97 return jsUndefined(); 98 98 99 JSObject* thisObject = jsCast<JSObject*>(exec->uncheckedArgument(0).toThis(exec, NotStrictMode)); 100 String result = thisObject->methodTable()->className(thisObject); 101 return jsString(exec, result); 99 JSObject* object = jsCast<JSObject*>(exec->uncheckedArgument(0).toThis(exec, NotStrictMode)); 100 return jsString(exec, JSObject::calculatedClassName(object)); 102 101 } 103 102 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r178928 r180173 256 256 ASSERT(info); 257 257 return info->className; 258 } 259 260 String JSObject::calculatedClassName(JSObject* object) 261 { 262 String prototypeFunctionName; 263 ExecState* exec = object->globalObject()->globalExec(); 264 PropertySlot slot(object->structure()->storedPrototype()); 265 PropertyName constructor(exec->propertyNames().constructor); 266 if (object->getPropertySlot(exec, constructor, slot)) { 267 if (slot.isValue()) { 268 JSValue constructorValue = slot.getValue(exec, constructor); 269 if (constructorValue.isCell()) { 270 if (JSCell* constructorCell = constructorValue.asCell()) { 271 if (JSObject* ctorObject = constructorCell->getObject()) { 272 if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject)) 273 prototypeFunctionName = constructorFunction->calculatedDisplayName(exec); 274 else if (InternalFunction* constructorFunction = jsDynamicCast<InternalFunction*>(ctorObject)) 275 prototypeFunctionName = constructorFunction->calculatedDisplayName(exec); 276 } 277 } 278 } 279 } 280 } 281 282 if (prototypeFunctionName.isNull() || prototypeFunctionName == "Object") { 283 String tableClassName = object->methodTable()->className(object); 284 if (!tableClassName.isNull() && tableClassName != "Object") 285 return tableClassName; 286 287 String classInfoName = object->classInfo()->className; 288 if (!classInfoName.isNull()) 289 return classInfoName; 290 291 if (prototypeFunctionName.isNull()) 292 return ASCIILiteral("Object"); 293 } 294 295 return prototypeFunctionName; 258 296 } 259 297 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r178928 r180173 101 101 102 102 JS_EXPORT_PRIVATE static String className(const JSObject*); 103 JS_EXPORT_PRIVATE static String calculatedClassName(JSObject*); 103 104 104 105 JSValue prototype() const; -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r179429 r180173 1060 1060 } 1061 1061 1062 bool foundCtorName = false; 1063 if (JSObject* profilingVal = curValue.getObject()) { 1064 ExecState* exec = profilingVal->globalObject()->globalExec(); 1065 PropertySlot slot(storedPrototype()); 1066 PropertyName constructor(exec->propertyNames().constructor); 1067 if (profilingVal->getPropertySlot(exec, constructor, slot)) { 1068 if (slot.isValue()) { 1069 JSValue constructorValue = slot.getValue(exec, constructor); 1070 if (constructorValue.isCell()) { 1071 if (JSCell* constructorCell = constructorValue.asCell()) { 1072 if (JSObject* ctorObject = constructorCell->getObject()) { 1073 if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject)) { 1074 curShape->setConstructorName(constructorFunction->calculatedDisplayName(exec)); 1075 foundCtorName = true; 1076 } else if (InternalFunction* constructorFunction = jsDynamicCast<InternalFunction*>(ctorObject)) { 1077 curShape->setConstructorName(constructorFunction->calculatedDisplayName(exec)); 1078 foundCtorName = true; 1079 } 1080 } 1081 } 1082 } 1083 } 1084 } 1085 } 1086 1087 if (!foundCtorName) 1062 1063 if (JSObject* curObject = curValue.getObject()) 1064 curShape->setConstructorName(JSObject::calculatedClassName(curObject)); 1065 else 1088 1066 curShape->setConstructorName(curStructure->classInfo()->className); 1089 1067
Note: See TracChangeset
for help on using the changeset viewer.