-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathforInArrayAdd.js
140 lines (118 loc) · 3.05 KB
/
forInArrayAdd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
//
//NOTE: this may break if enumeration order policy is changed in Chakra but that doesn't mean we have a bug in TTD
//
var a = [11,22,33,44];
a.x = "a.x";
a.y = "a.y";
a.z = "a.z";
var d = [1];
var counter = 0;
WScript.SetTimeout(testFunction, 50);
/////////////////
function testFunction()
{
telemetryLog("Scenario:1 - Adding new array indexes while enumerating expandos", true);
for(var i in a)
{
if(i == "y")
{
a[5] = 55;
a[6] = 66;
}
telemetryLog(`Index:${i} Value:${a[i]}`, true);
}
telemetryLog("Scenario:2 - Adding new array expandos while enumerating array for second time", true);
for(var i in a)
{
if(i == "z")
{
a[7] = 77;
a[9] = 99;
}
if(i == "7")
{
a.xx = "a.xx";
a.yy = "a.yy";
}
telemetryLog(`Index:${i} Value:${a[i]}`, true);
}
telemetryLog("Scenario:3 - Adding new array expandos while enumerating Object for second time", true);
var b = [11,22,33,44];
b.x = "b.x";
b.y = "b.y";
b.z = "b.z";
for(var i in b)
{
if(i == "x")
{
b[5] = 55;
b[7] = 77;
}
if(i == "7")
{
b.xx = "b.xx";
b.yy = "b.yy";
}
if(i == "xx")
{
b[9] = 99;
b[10] = 1010;
}
if(i == "9")
{
b.zz = "b.zz";
}
telemetryLog(`Index:${i} Value:${b[i]}`, true);
}
telemetryLog("Scenario:3 - Adding new array expandos while enumerating Object for second time", true);
var b = [11,22,33,44];
b.x = "b.x";
b.y = "b.y";
b.z = "b.z";
for(var i in b)
{
if(i == "x")
{
b[5] = 55;
b[7] = 77;
}
if(i == "7")
{
b.xx = "b.xx";
b.yy = "b.yy";
}
if(i == "xx")
{
b[9] = 99;
b[10] = 1010;
}
if(i == "9")
{
b.zz = "b.zz";
}
telemetryLog(`Index:${i} Value:${b[i]}`, true);
}
telemetryLog("Scenario:4 - random additions", true);
for(var i in d)
{
if(counter == 25)
{
break;
}
if(counter%2 == 1)
{
d[counter*counter] = counter*counter;
}
else
{
d["x"+counter] = "d.x"+counter;
}
telemetryLog(`Index:${i} Value:${d[i]}`, true);
counter++;
}
emitTTDLog(ttdLogURI);
}