|
| 1 | +//------------------------------------------------------------------------------------------------------- |
| 2 | +// Copyright (C) Microsoft. All rights reserved. |
| 3 | +// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. |
| 4 | +//------------------------------------------------------------------------------------------------------- |
| 5 | + |
| 6 | +WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js"); |
| 7 | + |
| 8 | +var tests = [ |
| 9 | + { |
| 10 | + name: "Object.prototype.__lookupGetter__ -> [[GetOwnProperty]], [[GetPrototypeOf]]", |
| 11 | + body: function () { |
| 12 | + // Object.prototype.__lookupGetter__ -> [[GetOwnProperty]] |
| 13 | + // Object.prototype.__lookupGetter__ -> [[GetPrototypeOf]] |
| 14 | + var gopd = []; |
| 15 | + var gpo = false; |
| 16 | + var p = new Proxy({}, |
| 17 | + { |
| 18 | + getPrototypeOf: function(o) { gpo = true; return Object.getPrototypeOf(o); }, |
| 19 | + getOwnPropertyDescriptor: function(o, v) { gopd.push(v); return Object.getOwnPropertyDescriptor(o, v); } |
| 20 | + }); |
| 21 | + Object.prototype.__lookupGetter__.call(p, "foo"); |
| 22 | + assert.areEqual(1, gopd.length, "getOwnPropertyDescriptor should only be called once"); |
| 23 | + assert.areEqual("foo", gopd[0], "getOwnPropertyDescriptor should be called with foo"); |
| 24 | + assert.isTrue(gpo, "getPrototypeOf should be called"); |
| 25 | + } |
| 26 | + }, |
| 27 | + { |
| 28 | + name: "Object.prototype.__lookupSetter__ -> [[GetOwnProperty]], [[GetPrototypeOf]]", |
| 29 | + body: function () { |
| 30 | + // Object.prototype.__lookupSetter__ -> [[GetOwnProperty]] |
| 31 | + // Object.prototype.__lookupSetter__ -> [[GetPrototypeOf]] |
| 32 | + var gopd = []; |
| 33 | + var gpo = false; |
| 34 | + var p = new Proxy({}, |
| 35 | + { |
| 36 | + getPrototypeOf: function(o) { gpo = true; return Object.getPrototypeOf(o); }, |
| 37 | + getOwnPropertyDescriptor: function(o, v) { gopd.push(v); return Object.getOwnPropertyDescriptor(o, v); } |
| 38 | + }); |
| 39 | + Object.prototype.__lookupSetter__.call(p, "foo"); |
| 40 | + assert.areEqual(1, gopd.length, "getOwnPropertyDescriptor should only be called once"); |
| 41 | + assert.areEqual("foo", gopd[0], "getOwnPropertyDescriptor should be called with foo"); |
| 42 | + assert.isTrue(gpo, "getPrototypeOf should be called"); |
| 43 | + } |
| 44 | + } |
| 45 | +]; |
| 46 | + |
| 47 | +testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" }); |
0 commit comments