diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
commit | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch) | |
tree | b34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp | |
parent | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff) | |
download | qtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz |
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp index b82ab62ab..db8ee1d85 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp @@ -297,7 +297,7 @@ static double parseInt(const UString& s, const CharType* data, int radix) } if (number >= mantissaOverflowLowerBound) { if (radix == 10) - number = WTF::strtod(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0); + number = WTF::strtod<WTF::AllowTrailingJunk>(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0); else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix); } @@ -369,7 +369,7 @@ static double jsStrDecimalLiteral(const CharType*& data, const CharType* end) } byteBuffer.append(0); char* endOfNumber; - double number = WTF::strtod(byteBuffer.data(), &endOfNumber); + double number = WTF::strtod<WTF::AllowTrailingJunk>(byteBuffer.data(), &endOfNumber); // Check if strtod found a number; if so return it. ptrdiff_t consumed = endOfNumber - byteBuffer.data(); @@ -714,4 +714,40 @@ EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeError(ExecState* exec) return throwVMTypeError(exec); } +EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState* exec) +{ + if (!exec->thisValue().isObject()) + return JSValue::encode(exec->thisValue().synthesizePrototype(exec)); + + JSObject* thisObject = asObject(exec->thisValue()); + if (!thisObject->allowsAccessFrom(exec->trueCallerFrame())) + return JSValue::encode(jsUndefined()); + + return JSValue::encode(thisObject->prototype()); +} + +EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState* exec) +{ + JSValue value = exec->argument(0); + + // Setting __proto__ of a primitive should have no effect. + if (!exec->thisValue().isObject()) + return JSValue::encode(jsUndefined()); + + JSObject* thisObject = asObject(exec->thisValue()); + if (!thisObject->allowsAccessFrom(exec->trueCallerFrame())) + return JSValue::encode(jsUndefined()); + + // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla. + if (!value.isObject() && !value.isNull()) + return JSValue::encode(jsUndefined()); + + if (!thisObject->isExtensible()) + return throwVMError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError)); + + if (!thisObject->setPrototypeWithCycleCheck(exec->globalData(), value)) + throwError(exec, createError(exec, "cyclic __proto__ value")); + return JSValue::encode(jsUndefined()); +} + } // namespace JSC |