Commit af63679d authored by cwhan.tunz's avatar cwhan.tunz Committed by Commit bot

Set undefined when calling %TypedArray%.indexOf without arguments

Set undefined to the first argument (search element) if the first
argument is not given in %TypedArray%.prototype.indexOf or
%TypedArray%.prototype.includes

BUG=chromium:700894

Review-Url: https://codereview.chromium.org/2748113002
Cr-Commit-Position: refs/heads/master@{#43794}
parent 0a4c5c44
...@@ -700,7 +700,7 @@ BUILTIN(TypedArrayPrototypeIncludes) { ...@@ -700,7 +700,7 @@ BUILTIN(TypedArrayPrototypeIncludes) {
// TODO(cwhan.tunz): throw. See the above comment in CopyWithin. // TODO(cwhan.tunz): throw. See the above comment in CopyWithin.
if (V8_UNLIKELY(array->WasNeutered())) return isolate->heap()->false_value(); if (V8_UNLIKELY(array->WasNeutered())) return isolate->heap()->false_value();
Handle<Object> search_element = args.at<Object>(1); Handle<Object> search_element = args.atOrUndefined(isolate, 1);
ElementsAccessor* elements = array->GetElementsAccessor(); ElementsAccessor* elements = array->GetElementsAccessor();
Maybe<bool> result = elements->IncludesValue(isolate, array, search_element, Maybe<bool> result = elements->IncludesValue(isolate, array, search_element,
static_cast<uint32_t>(index), static_cast<uint32_t>(index),
...@@ -731,7 +731,7 @@ BUILTIN(TypedArrayPrototypeIndexOf) { ...@@ -731,7 +731,7 @@ BUILTIN(TypedArrayPrototypeIndexOf) {
// TODO(cwhan.tunz): throw. See the above comment in CopyWithin. // TODO(cwhan.tunz): throw. See the above comment in CopyWithin.
if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1); if (V8_UNLIKELY(array->WasNeutered())) return Smi::FromInt(-1);
Handle<Object> search_element = args.at<Object>(1); Handle<Object> search_element = args.atOrUndefined(isolate, 1);
ElementsAccessor* elements = array->GetElementsAccessor(); ElementsAccessor* elements = array->GetElementsAccessor();
Maybe<int64_t> result = elements->IndexOfValue(isolate, array, search_element, Maybe<int64_t> result = elements->IndexOfValue(isolate, array, search_element,
static_cast<uint32_t>(index), static_cast<uint32_t>(index),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment