JSRemoteDOMWindowCustom.cpp [plain text]
#include "config.h"
#include "JSRemoteDOMWindow.h"
#include "JSDOMExceptionHandling.h"
#include "JSDOMWindowCustom.h"
#include "WebCoreJSClientData.h"
namespace WebCore {
using namespace JSC;
bool JSRemoteDOMWindow::getOwnPropertySlot(JSObject* object, JSGlobalObject* lexicalGlobalObject, PropertyName propertyName, PropertySlot& slot)
{
if (Optional<unsigned> index = parseIndex(propertyName))
return getOwnPropertySlotByIndex(object, lexicalGlobalObject, index.value(), slot);
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *lexicalGlobalObject, propertyName, slot, String());
}
bool JSRemoteDOMWindow::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObject* lexicalGlobalObject, unsigned index, PropertySlot& slot)
{
VM& vm = lexicalGlobalObject->vm();
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
slot.disableCaching();
return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *lexicalGlobalObject, Identifier::from(vm, index), slot, String());
}
bool JSRemoteDOMWindow::put(JSCell* cell, JSGlobalObject* lexicalGlobalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
VM& vm = lexicalGlobalObject->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(lexicalGlobalObject, propertyName, thisObject, value, *s_info.staticPropHashTable, slot, putResult))
return putResult;
return false;
}
throwSecurityError(*lexicalGlobalObject, scope, errorMessage);
return false;
}
bool JSRemoteDOMWindow::putByIndex(JSCell*, JSGlobalObject*, unsigned, JSValue, bool)
{
return false;
}
bool JSRemoteDOMWindow::deleteProperty(JSCell*, JSGlobalObject* lexicalGlobalObject, PropertyName)
{
VM& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*lexicalGlobalObject, scope, String());
return false;
}
bool JSRemoteDOMWindow::deletePropertyByIndex(JSCell*, JSGlobalObject* lexicalGlobalObject, unsigned)
{
VM& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*lexicalGlobalObject, scope, String());
return false;
}
void JSRemoteDOMWindow::getOwnPropertyNames(JSObject*, JSGlobalObject* lexicalGlobalObject, PropertyNameArray& propertyNames, EnumerationMode mode)
{
if (mode.includeDontEnumProperties())
addCrossOriginOwnPropertyNames<CrossOriginObject::Window>(*lexicalGlobalObject, propertyNames);
}
bool JSRemoteDOMWindow::defineOwnProperty(JSC::JSObject*, JSC::JSGlobalObject* lexicalGlobalObject, JSC::PropertyName, const JSC::PropertyDescriptor&, bool)
{
VM& vm = lexicalGlobalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwSecurityError(*lexicalGlobalObject, scope, String());
return false;
}
JSValue JSRemoteDOMWindow::getPrototype(JSObject*, JSGlobalObject*)
{
return jsNull();
}
bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
{
auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
return false;
}
String JSRemoteDOMWindow::toStringName(const JSObject*, JSGlobalObject*)
{
return "Object"_s;
}
}