-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Original Author: [email protected] Original Git: Original Reviewed By: avp Original Revision: D68907619 Like regular Proxy, JSCallableProxy should not have a parent, which may be observed by the prototype traversal in the `stack` accessor. Reviewed By: avp Differential Revision: D68939221 fbshipit-source-id: a353066acea6e266173a001c54409bdadd6f0a06
- Loading branch information
1 parent
6bf2a6a
commit 94c132c
Showing
3 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// RUN: %hermes %s | %FileCheck --match-full-lines %s | ||
// RUN: %shermes -exec %s | %FileCheck --match-full-lines %s | ||
|
||
// We previously set the parent of a proxy to Object.prototype, which is | ||
// incorrect and may be observed by the prototype traversal in the error stack | ||
// getter. Test this by installing stack trace information on Object.prototype | ||
// and verifying that the stack trace getter does not find it. | ||
|
||
// Install stack trace information on Object.prototype. | ||
Error.captureStackTrace(Object.prototype); | ||
|
||
// Check that lookup on a regular proxy fails. | ||
try{ | ||
var p = new Proxy(new Error(), {}); | ||
p.stack; | ||
} catch (e) { | ||
print(e); | ||
} | ||
// CHECK: TypeError: Error.stack getter called with an invalid receiver | ||
|
||
// Check that lookup on a callable proxy fails. | ||
try { | ||
function foo(){} | ||
foo.__proto__ = new Error(); | ||
var cp = new Proxy(foo, {}); | ||
cp.stack; | ||
} catch (e) { | ||
print(e); | ||
} | ||
// CHECK-NEXT: TypeError: Error.stack getter called with an invalid receiver |