Fix handling of function proxies in higher-order array and string methods,
which use yet another way to determine strict vs non-strict function receivers. R=kmillikin@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/9270004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10459 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
9672a04de2
commit
c61665604b
@ -1869,9 +1869,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) {
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
|
||||
NoHandleAllocation handle_free;
|
||||
ASSERT(args.length() == 1);
|
||||
CONVERT_CHECKED(JSFunction, function, args[0]);
|
||||
CONVERT_CHECKED(JSReceiver, callable, args[0]);
|
||||
|
||||
if (!callable->IsJSFunction()) {
|
||||
HandleScope scope(isolate);
|
||||
bool threw = false;
|
||||
Handle<Object> delegate =
|
||||
Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw);
|
||||
if (threw) return Failure::Exception();
|
||||
callable = JSFunction::cast(*delegate);
|
||||
}
|
||||
JSFunction* function = JSFunction::cast(callable);
|
||||
|
||||
SharedFunctionInfo* shared = function->shared();
|
||||
if (shared->native() || !shared->is_classic_mode()) {
|
||||
return isolate->heap()->undefined_value();
|
||||
|
@ -611,6 +611,22 @@ TestAccessorCall(
|
||||
|
||||
|
||||
|
||||
// Passing a proxy function to higher-order library functions.
|
||||
|
||||
function TestHigherOrder(f) {
|
||||
assertEquals(6, [6, 2].map(f)[0])
|
||||
assertEquals(4, [5, 2].reduce(f, 4))
|
||||
assertTrue([1, 2].some(f))
|
||||
assertEquals("a.b.c", "a.b.c".replace(".", f))
|
||||
}
|
||||
|
||||
TestHigherOrder(function(x) { return x })
|
||||
TestHigherOrder(function(x) { "use strict"; return x })
|
||||
TestHigherOrder(Proxy.createFunction({}, function(x) { return x }))
|
||||
TestHigherOrder(CreateFrozen({}, function(x) { return x }))
|
||||
|
||||
|
||||
|
||||
// TODO(rossberg): Ultimately, I want to have the following test function
|
||||
// run through, but it currently fails on so many cases (some not even
|
||||
// involving proxies), that I leave that for later...
|
||||
|
Loading…
Reference in New Issue
Block a user