/
conformance-config.textproto
359 lines (300 loc) · 9.54 KB
/
conformance-config.textproto
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# Custom Rules
requirement: {
rule_id: 'closure:throwOfNonErrorTypes'
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$BanThrowOfNonErrorTypes'
error_message: 'Should not throw a non-Error object.'
}
# Element
requirement: {
type: BANNED_PROPERTY_READ
error_message: 'Use getStyle, setStyle, or setStyles in src/style.js'
value: 'Element.prototype.style'
whitelist: 'src/style.js'
whitelist: 'src/layout.js'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Use closestAncestorElementBySelector in src/dom.js'
value: 'Element.prototype.closest'
whitelist: 'src/dom.js'
}
# CSSStyleDeclaration
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Use setStyle or setStyles in src/style.js'
value: 'CSSStyleDeclaration.prototype.setProperty'
whitelist: 'src/style.js'
}
# History
requirement: {
type: BANNED_PROPERTY
error_message: 'History.p.state is broken in IE11. Please use the helper methods provided in src/history.js'
value: 'History.prototype.state'
whitelist: 'src/history.js'
}
# Strings
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.padStart is not allowed'
value: 'string.prototype.padStart'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.padEnd is not allowed'
value: 'string.prototype.padEnd'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Use string.js#startsWith'
value: 'string.prototype.startsWith'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.endsWith is not allowed'
value: 'string.prototype.endsWith'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.includes is not allowed'
value: 'string.prototype.includes'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.repeat is not allowed'
value: 'string.prototype.repeat'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.normalize is not allowed'
value: 'string.prototype.normalize'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'string.prototype.codePointAt is not allowed'
value: 'string.prototype.codePointAt'
}
requirement: {
type: BANNED_NAME
error_message: 'String.fromCodePoint is not allowed'
value: 'String.fromCodePoint'
}
# Object
requirement: {
type: BANNED_NAME
error_message: 'Object.entries is not allowed'
value: 'Object.entries'
}
requirement: {
type: BANNED_NAME
error_message: 'Object.getOwnPropertyDescriptors is not allowed'
value: 'Object.getOwnPropertyDescriptors'
}
# Array
requirement: {
type: BANNED_NAME
error_message: 'Array.from is not allowed'
value: 'Array.from'
}
requirement: {
type: BANNED_NAME
error_message: 'Array.of is not allowed'
value: 'Array.of'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Array.prototype.find is not allowed'
value: 'Array.prototype.find'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Array.prototype.findIndex is not allowed'
value: 'Array.prototype.findIndex'
}
# Math
requirement: {
type: BANNED_NAME
error_message: 'Math.trunc is not allowed'
value: 'Math.trunc'
}
# Number
requirement: {
type: BANNED_NAME
error_message: 'Number.isSafeInteger is not allowed'
value: 'Number.isSafeInteger'
}
requirement: {
type: BANNED_NAME
error_message: 'Number.isNaN is not allowed'
value: 'Number.isNaN'
}
requirement: {
type: BANNED_NAME
error_message: 'Number.isFinite is not allowed'
value: 'Number.isFinite'
}
requirement: {
type: BANNED_NAME
error_message: 'Number.EPSILON is not allowed'
value: 'Number.EPSILON'
}
# Structures
requirement: {
type: BANNED_NAME
error_message: 'Map is not allowed'
value: 'Map'
}
requirement: {
type: BANNED_NAME
error_message: 'WeakMap is not allowed'
value: 'WeakMap'
}
requirement: {
type: BANNED_NAME
error_message: 'Set is not allowed'
value: 'Set'
}
requirement: {
type: BANNED_NAME
error_message: 'WeakSet is not allowed'
value: 'WeakSet'
}
requirement: {
type: BANNED_NAME
error_message: 'Symbol is not allowed'
value: 'Symbol'
}
requirement: {
type: BANNED_NAME
error_message: 'Use jsonParse instead. Usage in 3p ads can be whitelisted for now.'
value: 'JSON.parse'
whitelist: 'ads/adfox.js'
whitelist: 'ads/adincube.js'
whitelist: 'ads/imedia.js'
whitelist: 'ads/kargo.js'
whitelist: 'ads/mads.js'
whitelist: 'ads/google/imaVideo.js'
whitelist: 'ads/zen.js'
whitelist: 'src/json.js' # Where jsonParse itself is implemented.
}
requirement: {
type: BANNED_PROPERTY_READ
error_message: 'Use eventHelper#getData to read the data property. OK to whitelist 3p ads for now.'
value: 'Event.prototype.data'
value: 'MessageEvent.prototype.data'
whitelist: 'src/event-helper.js' # getData is implemented here
whitelist: 'src/web-worker/amp-worker.js' # OK to use in version bound worker
whitelist: 'src/web-worker/web-worker.js' # OK to use in version bound worker
# 3p ads are OK
whitelist: 'ads/adfox.js'
whitelist: 'ads/google/imaVideo.js'
whitelist: 'ads/netletix.js'
whitelist: 'ads/yandex.js'
whitelist: 'extensions/amp-access/0.1/amp-access-iframe.js' # False-positive
whitelist: 'extensions/amp-access/0.1/iframe-api/messenger.js' # 3p-intent
whitelist: 'src/service/history-impl.js' # False-positive
}
requirement: {
type: BANNED_PROPERTY_READ
error_message: 'Use eventHelper#getDetail to read the detail property. OK to whitelist 3p ads for now.'
value: 'Event.prototype.detail'
value: 'MessageEvent.prototype.detail'
whitelist: 'src/event-helper.js' # getDetail is implemented here
# 3p ads are OK
whitelist: 'ads/adhese.js'
whitelist: 'ads/loka.js'
whitelist: 'ads/xlift.js'
}
requirement: {
type: RESTRICTED_METHOD_CALL
error_message: 'postMessage must be called with a string or a JsonObject'
value: 'Window.prototype.postMessage:function((string|?JsonObject), string, (Array|Transferable)=)'
# Guaranteed same version call
whitelist: 'src/web-worker/web-worker.js'
# Allowing violations in ads code for now.
# We would have to fix this to property obfuscated the 3p frame code.
whitelist: '3p/iframe-messaging-client.js'
whitelist: 'ads/google/deprecated_doubleclick.js'
whitelist: 'ads/google/imaVideo.js'
}
requirement: {
type: RESTRICTED_NAME_CALL
error_message: 'JSON.stringify must be called with a JsonObject'
# Unfortunately the Array is untyped, because the compiler doesn't check
# for the template type.
value: 'JSON.stringify:function((?JsonObject|AmpViewerMessage|string|number|boolean|undefined|Array),!Function=)'
# Allowing violations in ads code for now.
# We would have to fix this to property obfuscated the 3p frame code.
whitelist: 'ads/google/deprecated_doubleclick.js'
}
# Cookies
requirement: {
type: BANNED_PROPERTY
error_message: 'Use cookies#getCookie or cookies#setCookie to read or write cookies. Note that usage of cookies requires dedicated review due to being privacy sensitive. Please file an issue asking for permission to use if you have not yet done so'
value: 'Document.prototype.cookie'
whitelist: 'src/cookies.js'
}
requirement: {
type: BANNED_NAME
error_message: 'Usage of cookies requires dedicated review due to being privacy sensitive. Please file an issue asking for permission to use if you have not yet done so'
value: 'module$src$cookies.getCookie'
value: 'module$src$cookies.setCookie'
whitelist: 'src/cookies.js'
whitelist: 'src/experiments.js'
whitelist: 'src/service/cid-api.js'
whitelist: 'src/service/cid-impl.js'
whitelist: 'extensions/amp-analytics/0.1/cookie-writer.js'
}
# Function
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'Function.prototype.name is not allowed due to IE11 non-support.'
value: 'Function.prototype.name'
}
# Bans DOM v4 methods, to limit the surface area of the Custom Elements Polyfill
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ChildNode.p.remove() is unusual. Please use Node.p.removeChild()'
value: 'DocumentType.prototype.remove'
value: 'Element.prototype.remove'
value: 'CharacterData.prototype.remove'
whitelist: 'extensions/amp-inputmask/0.1/mask-impl.js'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ChildNode.p.replaceWith() is unusual. Please use Node.p.replaceChild()'
value: 'DocumentType.prototype.replaceWith'
value: 'Element.prototype.replaceWith'
value: 'CharacterData.prototype.replaceWith'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ParentNode.p.append() is unusual. Please use Node.p.appendChild()'
value: 'Element.prototype.append'
value: 'Document.prototype.append'
value: 'DocumentFragment.prototype.append'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ParentNode.p.prepend() is unusual. Please use Node.p.insertBefore()'
value: 'Element.prototype.prepend'
value: 'Document.prototype.prepend'
value: 'DocumentFragment.prototype.prepend'
}
requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ChildNode.p.before() is unusual. Please use Node.p.insertBefore()'
value: 'Element.prototype.before'
value: 'DocumentType.prototype.before'
value: 'CharacterData.prototype.before'
# It's really hard to properly type check this one.
whitelist: 'extensions/amp-date-picker/0.1/dates-list.js'
}
# TODO(rsimha): Reenable when we move RRule to a node module.
# requirement: {
# type: BANNED_PROPERTY_CALL
# error_message: 'ChildNode.p.after() is unusual. Please use Node.p.insertBefore()'
# value: 'Element.prototype.after'
# value: 'DocumentType.prototype.after'
# value: 'CharacterData.prototype.after'
# }