JSValue jsLocationOrigin(ExecState* exec, JSValue slotBase, const Identifier&) { JSLocation* castedThis = static_cast<JSLocation*>(asObject(slotBase)); UNUSED_PARAM(exec); Location* imp = static_cast<Location*>(castedThis->impl()); JSValue result = jsString(exec, imp->origin()); #ifdef JSC_TAINTED TaintedCounter* counter = TaintedCounter::getInstance(); unsigned int tainted = counter->getCount(); result.setTainted(tainted); TaintedStructure trace_struct; trace_struct.taintedno = tainted; trace_struct.internalfunc = "jsLocationOrigin"; trace_struct.jsfunc = "location.origin"; trace_struct.action = "source"; char msg[20]; stringstream msgss; snprintf(msg, 20, "%s", result.toString(exec).utf8(true).data()); msgss << msg; msgss >> trace_struct.value; TaintedTrace* trace = TaintedTrace::getInstance(); trace->addTaintedTrace(trace_struct); #endif return result; }
void JSLocation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { JSLocation* thisObject = jsCast<JSLocation*>(object); // Only allow the location object to enumerated by frames in the same origin. if (!allowAccessToFrame(exec, thisObject->impl()->frame())) return; Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); }
bool JSLocation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName) { JSLocation* thisObject = jsCast<JSLocation*>(cell); // Only allow deleting by frames in the same origin. if (!allowAccessToFrame(exec, thisObject->impl()->frame())) return false; return Base::deleteProperty(thisObject, exec, propertyName); }
bool JSLocation::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) { JSLocation* thisObject = jsCast<JSLocation*>(cell); // Only allow deleting by frames in the same origin. if (!BindingSecurity::shouldAllowAccessToFrame(exec, thisObject->wrapped().frame(), ThrowSecurityError)) return false; return Base::deleteProperty(thisObject, exec, propertyName); }
EncodedJSValue JSC_HOST_CALL jsLocationPrototypeFunctionReload(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSLocation::s_info)) return throwVMTypeError(exec); JSLocation* castedThis = static_cast<JSLocation*>(asObject(thisValue)); return JSValue::encode(castedThis->reload(exec)); }
bool JSLocation::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName) { JSLocation* thisObject = jsCast<JSLocation*>(cell); // Only allow deleting by frames in the same origin. if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame())) return false; return Base::deletePropertyByIndex(thisObject, exec, propertyName); }
bool JSLocationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSLocation* jsLocation = static_cast<JSLocation*>(handle.get().asCell()); if (!isObservable(jsLocation)) return false; Frame* root = jsLocation->impl()->frame(); if (!root) return false; return visitor.containsOpaqueRoot(root); }
EncodedJSValue JSC_HOST_CALL jsLocationPrototypeFunctionToString(ExecState* exec) { #ifdef JSC_TAINTED // implement @ bindings/js/JSLocationCustom.cpp toStringFunction() #endif JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSLocation::s_info)) return throwVMTypeError(exec); JSLocation* castedThis = static_cast<JSLocation*>(asObject(thisValue)); return JSValue::encode(castedThis->toStringFunction(exec)); }
EncodedJSValue JSC_HOST_CALL jsLocationPrototypeFunctionGetParameter(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSLocation::s_info)) return throwVMTypeError(exec); JSLocation* castedThis = static_cast<JSLocation*>(asObject(thisValue)); Location* imp = static_cast<Location*>(castedThis->impl()); const String& name(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsString(exec, imp->getParameter(name)); return JSValue::encode(result); }
void setJSLocationHash(ExecState* exec, JSObject* thisObject, JSValue value) { #ifdef JSC_TAINTED unsigned int tainted = 0; if (value.isString() && value.isTainted()) { tainted = value.isTainted(); } if (value.inherits(&StringObject::s_info) && asStringObject(value)->isTainted()) { tainted = asStringObject(value)->isTainted(); } if (value.isObject()) { UString s = value.toString(exec); if (s.isTainted()) { tainted = s.isTainted(); } } if (tainted) { JSLocation* castedThis = static_cast<JSLocation*>(thisObject); Location* imp = static_cast<Location*>(castedThis->impl()); imp->frame()->document()->setTainted(tainted); TaintedStructure trace_struct; trace_struct.taintedno = tainted; trace_struct.internalfunc = "setJSLocationHash"; trace_struct.jsfunc = "location.hash"; trace_struct.action = "sink"; char msg[20]; stringstream msgss; snprintf(msg, 20, "%s", value.toString(exec).utf8(true).data()); msgss << msg; msgss >> trace_struct.value; TaintedTrace* trace = TaintedTrace::getInstance(); trace->addTaintedTrace(trace_struct); } #endif static_cast<JSLocation*>(thisObject)->setHash(exec, value); }
void JSLocationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSLocation* jsLocation = static_cast<JSLocation*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsLocation->impl(), jsLocation); }