Commit 8bc98b5c authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

Fix Array.indexOf for Proxies that throw

When the slow path for Array.prototype.indexOf calls a Proxy's "has"
trap, it must check afterwards whether an exception was thrown.

BUG=chromium:728813

Change-Id: I998bba6ddcd65adfed2eefb63b3285da60d2a43c
Reviewed-on: https://chromium-review.googlesource.com/527173Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45759}
parent 76aef2f3
...@@ -610,9 +610,9 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { ...@@ -610,9 +610,9 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
LookupIterator it = LookupIterator::PropertyOrElement( LookupIterator it = LookupIterator::PropertyOrElement(
isolate, object, index_obj, &success); isolate, object, index_obj, &success);
DCHECK(success); DCHECK(success);
if (!JSReceiver::HasProperty(&it).FromJust()) { Maybe<bool> present = JSReceiver::HasProperty(&it);
continue; MAYBE_RETURN(present, isolate->heap()->exception());
} if (!present.FromJust()) continue;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k,
Object::GetProperty(&it)); Object::GetProperty(&it));
if (search_element->StrictEquals(*element_k)) { if (search_element->StrictEquals(*element_k)) {
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var p = new Proxy({}, {
has: function () { throw "nope"; }
});
p.length = 2;
assertThrows(() => Array.prototype.indexOf.call(p));
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