Skip to content

Commit 001f924

Browse files
committed
PR feedback
1 parent 475e1ec commit 001f924

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

lib/Runtime/Library/JavascriptProxy.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@ namespace Js
5959
// the proxies could be deep nested and cause SO when processed recursively.
6060
static const JavascriptProxy* UnwrapNestedProxies(const JavascriptProxy* proxy)
6161
{
62-
while (proxy->handler != nullptr && JavascriptProxy::Is(proxy->target))
62+
// continue while we have a proxy that is not revoked
63+
while (proxy->handler != nullptr)
6364
{
64-
proxy = JavascriptProxy::FromVar(proxy->target);
65+
JavascriptProxy* nestedProxy = JavascriptOperators::TryFromVar<JavascriptProxy>(proxy->target);
66+
if (nestedProxy == nullptr)
67+
{
68+
break;
69+
}
70+
71+
proxy = nestedProxy;
6572
}
6673

6774
return proxy;

test/es6/ProxyInProxy.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,17 @@ function test7() {
225225
function test8() {
226226
print("*** deeply nested proxy and typeof");
227227

228-
var __v_8697 = Proxy.revocable([], {}).proxy;
229-
for (var __v_8698 = 0; __v_8698 < 1e5; __v_8698++) {
230-
__v_8697 = new Proxy(__v_8697, {});
228+
var nestedProxy = Proxy.revocable([], {}).proxy;
229+
for (let i = 0; i < 1e5; i++) {
230+
nestedProxy = new Proxy(nestedProxy, {});
231231
}
232-
var __v_8702 = new Proxy({}, {
233-
});
234-
(function () {
235-
if (__v_8697 != null && typeof __v_8697 == "object") try {
232+
233+
(function () {
234+
if (nestedProxy != null && typeof nestedProxy == "object")
235+
{
236236
console.log("pass");
237-
} catch (e) {}
238-
})();
237+
}
238+
})();
239239
}
240240

241241
test1();

0 commit comments

Comments
 (0)