diff options
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp index ce814b2..e160364 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp @@ -531,14 +531,19 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t // 15.4.4.12 JSArray* resObj = constructEmptyArray(exec); JSValue result = resObj; - unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); + + // FIXME: Firefox returns an empty array. if (!args.size()) return jsUndefined(); - int begin = args.at(0).toUInt32(exec); - if (begin < 0) - begin = std::max<int>(begin + length, 0); - else - begin = std::min<int>(begin, length); + + unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); + double relativeBegin = args.at(0).toInteger(exec); + unsigned begin; + if (relativeBegin < 0) { + relativeBegin += length; + begin = (relativeBegin < 0) ? 0 : static_cast<unsigned>(relativeBegin); + } else + begin = std::min<unsigned>(static_cast<unsigned>(relativeBegin), length); unsigned deleteCount; if (args.size() > 1) @@ -564,7 +569,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec, JSObject*, JSValue t for (unsigned k = length; k > length - deleteCount + additionalArgs; --k) thisObj->deleteProperty(exec, k - 1); } else { - for (unsigned k = length - deleteCount; (int)k > begin; --k) { + for (unsigned k = length - deleteCount; k > begin; --k) { if (JSValue obj = getProperty(exec, thisObj, k + deleteCount - 1)) thisObj->put(exec, k + additionalArgs - 1, obj); else |