Skip to content

Commit 4ccd8b6

Browse files
committed
another case
1 parent 4efd113 commit 4ccd8b6

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/Runtime/Library/JavascriptProxy.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ namespace Js
272272
{
273273
JavascriptError::ThrowTypeError(requestContext, JSERR_InconsistentTrapResult, _u("getOwnPropertyDescriptor"));
274274
}
275+
276+
// do not use "target" here, the trap may have caused it to change
275277
if (!targetObj->IsExtensible())
276278
{
277279
JavascriptError::ThrowTypeError(requestContext, JSERR_InconsistentTrapResult, _u("getOwnPropertyDescriptor"));
@@ -292,7 +294,8 @@ namespace Js
292294
//i.Throw a TypeError exception.
293295
//22. Return resultDesc.
294296

295-
BOOL isTargetExtensible = target->IsExtensible();
297+
// do not use "target" here, the trap may have caused it to change
298+
BOOL isTargetExtensible = targetObj->IsExtensible();
296299
BOOL toProperty = JavascriptOperators::ToPropertyDescriptor(getResult, resultDescriptor, requestContext);
297300
if (!toProperty && isTargetExtensible)
298301
{

test/es6/proxybugs.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,27 @@ var tests = [
253253
assert.isTrue(trapCalled);
254254
}
255255
},
256+
{
257+
name: "Assertion validation : revoking the proxy in getOwnPropertyDescriptor trap, not undefined return",
258+
body() {
259+
var trapCalled = false;
260+
var handler = {
261+
getOwnPropertyDescriptor: function (a, b, c) {
262+
trapCalled = true;
263+
let result = Object.getOwnPropertyDescriptor(obj, 'proxy');
264+
265+
obj.revoke();
266+
267+
// used to cause AV
268+
return result;
269+
}
270+
};
271+
272+
var obj = Proxy.revocable({}, handler);
273+
Object.getOwnPropertyDescriptor(obj.proxy);
274+
assert.isTrue(trapCalled);
275+
}
276+
},
256277
{
257278
name: "Assertion validation : revoking the proxy by invoking getOwnPropertyDescriptor trap but no handler present",
258279
body() {

0 commit comments

Comments
 (0)