Changeset 53930 in webkit
- Timestamp:
- Jan 27, 2010 6:25:11 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r53927 r53930 1 2010-01-27 Kent Hansen <kent.hansen@nokia.com> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] Meta-methods can't be introspected using ES5 API 6 https://bugs.webkit.org/show_bug.cgi?id=34087 7 8 Add getOwnPropertyDescriptor() and getOwnPropertyNames() reimplementations. 9 10 Tests are in WebKit/qt/tests/qwebframe 11 12 * bridge/qt/qt_runtime.cpp: 13 (JSC::Bindings::QtRuntimeMetaMethod::getOwnPropertyDescriptor): 14 (JSC::Bindings::QtRuntimeMetaMethod::getOwnPropertyNames): 15 (JSC::Bindings::QtRuntimeConnectionMethod::getOwnPropertyDescriptor): 16 (JSC::Bindings::QtRuntimeConnectionMethod::getOwnPropertyNames): 17 * bridge/qt/qt_runtime.h: 18 1 19 2010-01-27 Tony Chang <tony@chromium.org> 2 20 -
trunk/WebCore/bridge/qt/qt_runtime.cpp
r53611 r53930 1401 1401 } 1402 1402 1403 bool QtRuntimeMetaMethod::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) 1404 { 1405 if (propertyName == "connect") { 1406 PropertySlot slot; 1407 slot.setCustom(this, connectGetter); 1408 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); 1409 return true; 1410 } 1411 1412 if (propertyName == "disconnect") { 1413 PropertySlot slot; 1414 slot.setCustom(this, disconnectGetter); 1415 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); 1416 return true; 1417 } 1418 1419 if (propertyName == exec->propertyNames().length) { 1420 PropertySlot slot; 1421 slot.setCustom(this, lengthGetter); 1422 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); 1423 return true; 1424 } 1425 1426 return QtRuntimeMethod::getOwnPropertyDescriptor(exec, propertyName, descriptor); 1427 } 1428 1429 void QtRuntimeMetaMethod::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 1430 { 1431 if (mode == IncludeDontEnumProperties) { 1432 propertyNames.add(Identifier(exec, "connect")); 1433 propertyNames.add(Identifier(exec, "disconnect")); 1434 propertyNames.add(exec->propertyNames().length); 1435 } 1436 1437 QtRuntimeMethod::getOwnPropertyNames(exec, propertyNames, mode); 1438 } 1439 1403 1440 JSValue QtRuntimeMetaMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot&) 1404 1441 { … … 1585 1622 1586 1623 return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot); 1624 } 1625 1626 bool QtRuntimeConnectionMethod::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) 1627 { 1628 if (propertyName == exec->propertyNames().length) { 1629 PropertySlot slot; 1630 slot.setCustom(this, lengthGetter); 1631 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); 1632 return true; 1633 } 1634 1635 return QtRuntimeMethod::getOwnPropertyDescriptor(exec, propertyName, descriptor); 1636 } 1637 1638 void QtRuntimeConnectionMethod::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 1639 { 1640 if (mode == IncludeDontEnumProperties) 1641 propertyNames.add(exec->propertyNames().length); 1642 1643 QtRuntimeMethod::getOwnPropertyNames(exec, propertyNames, mode); 1587 1644 } 1588 1645 -
trunk/WebCore/bridge/qt/qt_runtime.h
r53464 r53930 156 156 157 157 protected: 158 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags | OverridesMarkChildren;158 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | InternalFunction::StructureFlags | OverridesMarkChildren; 159 159 160 160 QtRuntimeMethodData *d_func() const {return d_ptr;} … … 169 169 170 170 virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); 171 virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); 172 virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties); 171 173 172 174 virtual void markChildren(MarkStack& markStack); … … 190 192 191 193 virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); 194 virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); 195 virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties); 192 196 193 197 protected: -
trunk/WebKit/qt/ChangeLog
r53851 r53930 1 2010-01-27 Kent Hansen <kent.hansen@nokia.com> 2 3 Reviewed by Simon Hausmann. 4 5 [Qt] Meta-methods can't be introspected using ES5 API 6 https://bugs.webkit.org/show_bug.cgi?id=34087 7 8 Test that Object.getOwnPropertyDescriptor and 9 Object.getOwnPropertyNames work with meta-methods. 10 11 * tests/qwebframe/tst_qwebframe.cpp: 12 1 13 2010-01-26 Simon Hausmann <simon.hausmann@nokia.com> 2 14 -
trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r52444 r53930 574 574 void qObjectWrapperWithSameIdentity(); 575 575 void scrollRecursively(); 576 void introspectQtMethods_data(); 577 void introspectQtMethods(); 576 578 577 579 private: … … 2862 2864 } 2863 2865 2866 void tst_QWebFrame::introspectQtMethods_data() 2867 { 2868 QTest::addColumn<QString>("objectExpression"); 2869 QTest::addColumn<QString>("methodName"); 2870 QTest::addColumn<QStringList>("expectedPropertyNames"); 2871 2872 QTest::newRow("myObject.mySignal") 2873 << "myObject" << "mySignal" << (QStringList() << "connect" << "disconnect" << "length" << "name"); 2874 QTest::newRow("myObject.mySlot") 2875 << "myObject" << "mySlot" << (QStringList() << "connect" << "disconnect" << "length" << "name"); 2876 QTest::newRow("myObject.myInvokable") 2877 << "myObject" << "myInvokable" << (QStringList() << "connect" << "disconnect" << "length" << "name"); 2878 QTest::newRow("myObject.mySignal.connect") 2879 << "myObject.mySignal" << "connect" << (QStringList() << "length" << "name"); 2880 QTest::newRow("myObject.mySignal.disconnect") 2881 << "myObject.mySignal" << "disconnect" << (QStringList() << "length" << "name"); 2882 } 2883 2884 void tst_QWebFrame::introspectQtMethods() 2885 { 2886 QFETCH(QString, objectExpression); 2887 QFETCH(QString, methodName); 2888 QFETCH(QStringList, expectedPropertyNames); 2889 2890 QString methodLookup = QString::fromLatin1("%0['%1']").arg(objectExpression).arg(methodName); 2891 QCOMPARE(evalJSV(QString::fromLatin1("Object.getOwnPropertyNames(%0).sort()").arg(methodLookup)).toStringList(), expectedPropertyNames); 2892 2893 for (int i = 0; i < expectedPropertyNames.size(); ++i) { 2894 QString name = expectedPropertyNames.at(i); 2895 QCOMPARE(evalJS(QString::fromLatin1("%0.hasOwnProperty('%1')").arg(methodLookup).arg(name)), sTrue); 2896 evalJS(QString::fromLatin1("var descriptor = Object.getOwnPropertyDescriptor(%0, '%1')").arg(methodLookup).arg(name)); 2897 QCOMPARE(evalJS("typeof descriptor"), QString::fromLatin1("object")); 2898 QCOMPARE(evalJS("descriptor.get"), sUndefined); 2899 QCOMPARE(evalJS("descriptor.set"), sUndefined); 2900 QCOMPARE(evalJS(QString::fromLatin1("descriptor.value === %0['%1']").arg(methodLookup).arg(name)), sTrue); 2901 QCOMPARE(evalJS(QString::fromLatin1("descriptor.enumerable")), sFalse); 2902 QCOMPARE(evalJS(QString::fromLatin1("descriptor.configurable")), sFalse); 2903 } 2904 2905 QVERIFY(evalJSV("var props=[]; for (var p in myObject.deleteLater) {props.push(p);}; props.sort()").toStringList().isEmpty()); 2906 } 2907 2864 2908 QTEST_MAIN(tst_QWebFrame) 2865 2909 #include "tst_qwebframe.moc"
Note: See TracChangeset
for help on using the changeset viewer.