Changeset 86758 in webkit


Ignore:
Timestamp:
May 18, 2011 7:12:56 AM (13 years ago)
Author:
caio.oliveira@openbossa.org
Message:

2011-05-18 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>

Reviewed by Andreas Kling.

[Qt] Fix tst_QWebFrame::getSetStaticProperty() autotest
https://bugs.webkit.org/show_bug.cgi?id=60984

The code for converting objects to QVariantMap was causing exception,
that was "leaking" to the next evaluation. One situation was reading
the property 'localStorage' when we do not have a proper security
origin, which throws a SECURITY_ERR.

Now, we will simply not include on the QVariantMap those properties,
and make sure that we clean the exception if necessary.

  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::convertValueToQVariantMap): Extracted function that performs conversion from JSObject to a QVariantMap. This functions makes sure that exception is clean after its execution.

(JSC::Bindings::convertValueToQVariant):
Use the previous function. Add a comment explaining the choice of distance value.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86757 r86758  
     12011-05-18  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] Fix tst_QWebFrame::getSetStaticProperty() autotest
     6        https://bugs.webkit.org/show_bug.cgi?id=60984
     7
     8        The code for converting objects to QVariantMap was causing exception,
     9        that was "leaking" to the next evaluation. One situation was reading
     10        the property 'localStorage' when we do not have a proper security
     11        origin, which throws a SECURITY_ERR.
     12
     13        Now, we will simply not include on the QVariantMap those properties,
     14        and make sure that we clean the exception if necessary.
     15
     16        * bridge/qt/qt_runtime.cpp:
     17        (JSC::Bindings::convertValueToQVariantMap):
     18        Extracted function that performs conversion from JSObject to a QVariantMap. This
     19        functions makes sure that exception is clean after its execution.
     20
     21        (JSC::Bindings::convertValueToQVariant):
     22        Use the previous function. Add a comment explaining the choice of distance value.
     23
    1242011-05-18  Ilya Tikhonovsky  <loislo@chromium.org>
    225
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r86498 r86758  
    179179
    180180    return String; // I don't know.
     181}
     182
     183QVariant convertValueToQVariant(ExecState*, JSValue, QMetaType::Type, int*, HashSet<JSObject*>*, int);
     184
     185static QVariantMap convertValueToQVariantMap(ExecState* exec, JSObject* object, HashSet<JSObject*>* visitedObjects, int recursionLimit)
     186{
     187    Q_ASSERT(!exec->hadException());
     188
     189    PropertyNameArray properties(exec);
     190    object->getPropertyNames(exec, properties);
     191    PropertyNameArray::const_iterator it = properties.begin();
     192    QVariantMap result;
     193    int objdist = 0;
     194
     195    while (it != properties.end()) {
     196        if (object->propertyIsEnumerable(exec, *it)) {
     197            JSValue val = object->get(exec, *it);
     198            if (exec->hadException())
     199                exec->clearException();
     200            else {
     201                QVariant v = convertValueToQVariant(exec, val, QMetaType::Void, &objdist, visitedObjects, recursionLimit);
     202                if (objdist >= 0) {
     203                    UString ustring = (*it).ustring();
     204                    QString id = QString((const QChar*)ustring.impl()->characters(), ustring.length());
     205                    result.insert(id, v);
     206                }
     207            }
     208        }
     209        ++it;
     210    }
     211    return result;
    181212}
    182213
     
    355386        case QMetaType::QVariantMap:
    356387            if (type == Object || type == Array || type == RTArray) {
    357                 // Enumerate the contents of the object
    358                 PropertyNameArray properties(exec);
    359                 object->getPropertyNames(exec, properties);
    360                 PropertyNameArray::const_iterator it = properties.begin();
    361 
    362                 QVariantMap result;
    363                 int objdist = 0;
    364                 while(it != properties.end()) {
    365                     if (object->propertyIsEnumerable(exec, *it)) {
    366                         JSValue val = object->get(exec, *it);
    367                         QVariant v = convertValueToQVariant(exec, val, QMetaType::Void, &objdist, visitedObjects, recursionLimit);
    368                         if (objdist >= 0) {
    369                             UString ustring = (*it).ustring();
    370                             QString id = QString((const QChar*)ustring.impl()->characters(), ustring.length());
    371                             result.insert(id, v);
    372                         }
    373                     }
    374                     ++it;
    375                 }
     388                ret = QVariant(convertValueToQVariantMap(exec, object, visitedObjects, recursionLimit));
     389                // Those types can still have perfect matches, e.g. 'bool' if value is a Boolean Object.
    376390                dist = 1;
    377                 ret = QVariant(result);
    378391            }
    379392            break;
Note: See TracChangeset for help on using the changeset viewer.