JSLocationCustom.cpp [plain text]
#include "config.h"
#include "JSLocation.h"
#include "JSDOMBinding.h"
#include "RuntimeApplicationChecks.h"
#include <runtime/JSFunction.h>
using namespace JSC;
namespace WebCore {
bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
Frame* frame = wrapped().frame();
if (!frame) {
slot.setUndefined();
return true;
}
String message;
if (shouldAllowAccessToFrame(exec, frame, message))
return false;
if (propertyName == exec->propertyNames().replace) {
slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsLocationInstanceFunctionReplace, 1>);
return true;
}
printErrorMessageForFrame(frame, message);
slot.setUndefined();
return true;
}
bool JSLocation::putDelegate(ExecState* exec, PropertyName propertyName, JSValue, PutPropertySlot&, bool& putResult)
{
putResult = false;
Frame* frame = wrapped().frame();
if (!frame)
return true;
if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
return true;
if (shouldAllowAccessToFrame(exec, frame))
return false;
return propertyName != exec->propertyNames().href;
}
bool JSLocation::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
JSLocation* thisObject = jsCast<JSLocation*>(cell);
if (!shouldAllowAccessToFrame(exec, thisObject->wrapped().frame()))
return false;
return Base::deleteProperty(thisObject, exec, propertyName);
}
bool JSLocation::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName)
{
JSLocation* thisObject = jsCast<JSLocation*>(cell);
if (!shouldAllowAccessToFrame(exec, thisObject->wrapped().frame()))
return false;
return Base::deletePropertyByIndex(thisObject, exec, propertyName);
}
void JSLocation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSLocation* thisObject = jsCast<JSLocation*>(object);
if (!shouldAllowAccessToFrame(exec, thisObject->wrapped().frame()))
return;
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
bool JSLocation::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool throwException)
{
if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
return false;
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
JSValue JSLocation::toStringFunction(ExecState& state)
{
Frame* frame = wrapped().frame();
if (!frame || !shouldAllowAccessToFrame(&state, frame))
return jsUndefined();
return jsStringWithCache(&state, wrapped().toString());
}
bool JSLocationPrototype::putDelegate(ExecState* exec, PropertyName propertyName, JSValue, PutPropertySlot&, bool& putResult)
{
putResult = false;
return (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf);
}
bool JSLocationPrototype::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool throwException)
{
if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
return false;
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
}