MissingPropertyCache2.js 884 B

1234567891011121314151617181920212223
  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. // Make sure we invalidate missing property caches, if the property is shadowed on the instance.
  6. var o = {};
  7. var v;
  8. function test() {
  9. v = o.a;
  10. WScript.Echo("v = " + o.a);
  11. }
  12. // Run once, walk the proto chain on the slow path not finding property v anywhere, cache it.
  13. test();
  14. // Retrieve the value of v (undefined) from the missing property cache.
  15. test();
  16. // Now add the property to the object, which should invalidate the cache.
  17. o.a = 0;
  18. // Verify we get the new value now.
  19. test();