JSRemoteDOMWindowCustom.cpp [plain text]
#include "config.h"
#include "JSRemoteDOMWindow.h"
#include "JSDOMWindowCustom.h"
#include "WebCoreJSClientData.h"
namespace WebCore {
bool JSRemoteDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
{
if (std::optional<unsigned> index = parseIndex(propertyName))
return getOwnPropertySlotByIndex(object, state, index.value(), slot);
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *state, propertyName, slot, String());
}
bool JSRemoteDOMWindow::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
{
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
slot.disableCaching();
return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *state, Identifier::from(state, index), slot, String());
}
bool JSRemoteDOMWindow::put(JSCell* cell, ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
auto* thisObject = jsCast<JSRemoteDOMWindow*>(cell);
if (!thisObject->wrapped().frame())
return false;
String errorMessage;
if (propertyName == static_cast<JSVMClientData*>(vm.clientData)->builtinNames().locationPublicName()) {
bool putResult = false;
if (lookupPut(state, propertyName, thisObject, value, *s_info.staticPropHashTable, slot, putResult))
return putResult;
return false;
}
throwSecurityError(*state, scope, errorMessage);
return false;
}
bool JSRemoteDOMWindow::putByIndex(JSCell*, ExecState*, unsigned, JSValue, bool)
{
return false;
}
bool JSRemoteDOMWindow::deleteProperty(JSCell*, ExecState* state, PropertyName)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*state, scope, String());
return false;
}
bool JSRemoteDOMWindow::deletePropertyByIndex(JSCell*, ExecState* state, unsigned)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*state, scope, String());
return false;
}
void JSRemoteDOMWindow::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
if (mode.includeDontEnumProperties())
addCrossOriginWindowOwnPropertyNames(*exec, thisObject->wrapped(), propertyNames);
}
bool JSRemoteDOMWindow::defineOwnProperty(JSC::JSObject*, JSC::ExecState* state, JSC::PropertyName, const JSC::PropertyDescriptor&, bool)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*state, scope, String());
return false;
}
JSValue JSRemoteDOMWindow::getPrototype(JSObject*, ExecState*)
{
return jsNull();
}
bool JSRemoteDOMWindow::preventExtensions(JSObject*, ExecState* exec)
{
auto scope = DECLARE_THROW_SCOPE(exec->vm());
throwTypeError(exec, scope, "Cannot prevent extensions on this object"_s);
return false;
}
String JSRemoteDOMWindow::toStringName(const JSObject*, ExecState*)
{
return "Object"_s;
}
}