2
0

forInArrayAdd.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. //NOTE: this may break if enumeration order policy is changed in Chakra but that doesn't mean we have a bug in TTD
  7. //
  8. var a = [11,22,33,44];
  9. a.x = "a.x";
  10. a.y = "a.y";
  11. a.z = "a.z";
  12. var d = [1];
  13. var counter = 0;
  14. WScript.SetTimeout(testFunction, 50);
  15. /////////////////
  16. function testFunction()
  17. {
  18. telemetryLog("Scenario:1 - Adding new array indexes while enumerating expandos", true);
  19. for(var i in a)
  20. {
  21. if(i == "y")
  22. {
  23. a[5] = 55;
  24. a[6] = 66;
  25. }
  26. telemetryLog(`Index:${i} Value:${a[i]}`, true);
  27. }
  28. telemetryLog("Scenario:2 - Adding new array expandos while enumerating array for second time", true);
  29. for(var i in a)
  30. {
  31. if(i == "z")
  32. {
  33. a[7] = 77;
  34. a[9] = 99;
  35. }
  36. if(i == "7")
  37. {
  38. a.xx = "a.xx";
  39. a.yy = "a.yy";
  40. }
  41. telemetryLog(`Index:${i} Value:${a[i]}`, true);
  42. }
  43. telemetryLog("Scenario:3 - Adding new array expandos while enumerating Object for second time", true);
  44. var b = [11,22,33,44];
  45. b.x = "b.x";
  46. b.y = "b.y";
  47. b.z = "b.z";
  48. for(var i in b)
  49. {
  50. if(i == "x")
  51. {
  52. b[5] = 55;
  53. b[7] = 77;
  54. }
  55. if(i == "7")
  56. {
  57. b.xx = "b.xx";
  58. b.yy = "b.yy";
  59. }
  60. if(i == "xx")
  61. {
  62. b[9] = 99;
  63. b[10] = 1010;
  64. }
  65. if(i == "9")
  66. {
  67. b.zz = "b.zz";
  68. }
  69. telemetryLog(`Index:${i} Value:${b[i]}`, true);
  70. }
  71. telemetryLog("Scenario:3 - Adding new array expandos while enumerating Object for second time", true);
  72. var b = [11,22,33,44];
  73. b.x = "b.x";
  74. b.y = "b.y";
  75. b.z = "b.z";
  76. for(var i in b)
  77. {
  78. if(i == "x")
  79. {
  80. b[5] = 55;
  81. b[7] = 77;
  82. }
  83. if(i == "7")
  84. {
  85. b.xx = "b.xx";
  86. b.yy = "b.yy";
  87. }
  88. if(i == "xx")
  89. {
  90. b[9] = 99;
  91. b[10] = 1010;
  92. }
  93. if(i == "9")
  94. {
  95. b.zz = "b.zz";
  96. }
  97. telemetryLog(`Index:${i} Value:${b[i]}`, true);
  98. }
  99. telemetryLog("Scenario:4 - random additions", true);
  100. for(var i in d)
  101. {
  102. if(counter == 25)
  103. {
  104. break;
  105. }
  106. if(counter%2 == 1)
  107. {
  108. d[counter*counter] = counter*counter;
  109. }
  110. else
  111. {
  112. d["x"+counter] = "d.x"+counter;
  113. }
  114. telemetryLog(`Index:${i} Value:${d[i]}`, true);
  115. counter++;
  116. }
  117. emitTTDLog(ttdLogURI);
  118. }