Exemple #1
0
void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
    JSStorage* thisObject = jsCast<JSStorage*>(object);
    ExceptionCode ec = 0;
    unsigned length = thisObject->wrapped().length(ec);
    setDOMException(exec, ec);
    if (exec->hadException())
        return;
    for (unsigned i = 0; i < length; ++i) {
        propertyNames.add(Identifier::fromString(exec, thisObject->wrapped().key(i, ec)));
        setDOMException(exec, ec);
        if (exec->hadException())
            return;
    }
        
    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
Exemple #2
0
bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
    JSStorage* thisObject = jsCast<JSStorage*>(cell);
    // Only perform the custom delete if the object doesn't have a native property by this name.
    // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
    // the native property slots manually.
    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);

    static_assert(!hasStaticPropertyTable, "This function does not handle static instance properties");

    JSValue prototype = thisObject->getPrototypeDirect();
    if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
        return Base::deleteProperty(thisObject, exec, propertyName);

    if (propertyName.isSymbol())
        return Base::deleteProperty(thisObject, exec, propertyName);

    ExceptionCode ec = 0;
    thisObject->wrapped().removeItem(propertyNameToString(propertyName), ec);
    setDOMException(exec, ec);
    return true;
}
Exemple #3
0
bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
    JSStorage* thisObject = jsCast<JSStorage*>(cell);
    // Only perform the custom delete if the object doesn't have a native property by this name.
    // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
    // the native property slots manually.
    PropertySlot slot(thisObject);
    if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.staticPropHashTable, thisObject, propertyName, slot))
        return Base::deleteProperty(thisObject, exec, propertyName);

    JSValue prototype = thisObject->prototype();
    if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
        return Base::deleteProperty(thisObject, exec, propertyName);

    if (propertyName.isSymbol())
        return Base::deleteProperty(thisObject, exec, propertyName);

    ExceptionCode ec = 0;
    thisObject->wrapped().removeItem(propertyNameToString(propertyName), ec);
    setDOMException(exec, ec);
    return true;
}