forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconformance.textproto
329 lines (290 loc) · 10.2 KB
/
conformance.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
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Conformance requirements:
# See: https://github.com/google/closure-compiler/wiki/JS-Conformance-Framework
# Disallow throwing non-Error types.
requirement: {
type: CUSTOM
java_class:
'com.google.javascript.jscomp.ConformanceRules$BanThrowOfNonErrorTypes'
error_message: 'Throwing non-Error types or Error itself is not allowed; '
'throw shaka.util.Error instead.'
whitelist_regexp: 'test/'
}
requirement: {
type: BANNED_CODE_PATTERN
value: 'function template() { throw new Error(); }'
error_message: 'Throwing non-Error types or Error itself is not allowed; '
'throw shaka.util.Error instead.'
whitelist_regexp: 'test/'
}
# Ban accessing members of unknown types.
requirement: {
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$'
'BanUnknownTypedClassPropsReferences'
error_message: 'Using properties of unknown types is not allowed; add an '
'explicit type to the variable.'
whitelist_regexp: 'demo/'
}
requirement {
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$BanUnknownThis'
error_message: 'Failed to infer type of "this"; '
'please be explicit or use bind!'
# Until we can get this rule updated for ES6 static methods
# (https://github.com/google/closure-compiler/issues/2880):
whitelist_regexp: 'test/test/util/canned_idb.js'
whitelist_regexp: 'test/assets/assets_integration.js'
}
# Ban the use of @expose annotations.
requirement {
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$BanExpose'
error_message: '@expose is not allowed; please use externs instead. '
'See docs/design/export.md for details.'
}
# Reject unresolved types.
requirement {
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$BanUnresolvedType'
error_message: 'Failed to resolve type!'
}
# Reject global variables.
requirement {
type: CUSTOM
java_class: 'com.google.javascript.jscomp.ConformanceRules$BanGlobalVars'
error_message: 'Global variables are not allowed!'
whitelist_regexp: 'demo/'
whitelist_regexp: 'third_party/closure/'
whitelist_regexp: 'test/'
}
# Disallow using "!" on nullable numbers in boolean assignment.
# Note: we can't use the pattern "var b = !n" because it causes too many
# false positives.
requirement: {
type: BANNED_CODE_PATTERN
value: '/** @param {boolean} b @param {?number} n */ '
'function template(b, n) { b = !n; }'
error_message: 'Using "!" on nullable numbers in boolean assignment '
'is not allowed; use an explicit comparison instead.'
}
requirement: {
type: BANNED_CODE_PATTERN
value: '/** @param {*} a'
' @param {(number|string|boolean|null|undefined)} x */'
'function template(a, x) { expect(a).toEqual(x); }'
value: '/** @param {*} a'
' @param {(number|string|boolean|null|undefined)} x */'
'function template(a, x) { expect(a).not.toEqual(x); }'
error_message: 'Use expect.toBe for primitives'
}
requirement: {
type: BANNED_CODE_PATTERN
value: '/** @param {BufferSource} a */'
'function template(a) { new Uint8Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Int8Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Uint8ClampedArray(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Unt16Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Int16Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Uint32Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Int32Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Float32Array(a) }'
value: '/** @param {BufferSource} a */'
'function template(a) { new Float64Array(a) }'
error_message: 'Use shaka.util.BufferUtils.view* instead.'
whitelist_regexp: 'lib/util/buffer_utils.js'
}
# Disallow console logging.
requirement: {
type: BANNED_PROPERTY_CALL
value: 'Console.prototype.debug'
value: 'Console.prototype.log'
value: 'Console.prototype.info'
value: 'Console.prototype.warn'
value: 'Console.prototype.error'
error_message: 'Using "console" is not allowed; '
'use shaka.log instead'
whitelist_regexp: 'demo/'
whitelist_regexp: 'lib/debug/log.js'
whitelist_regexp: 'third_party/closure/'
whitelist_regexp: 'test/test/boot.js'
}
# Disallow Element.children.
requirement: {
type: BANNED_PROPERTY
value: 'Element.prototype.children'
error_message: 'Using "Element.children" is not allowed; '
'use Node.childNodes instead'
}
requirement: {
type: BANNED_PROPERTY
value: 'DataView.prototype.buffer'
value: 'TypedArray.prototype.buffer'
error_message: 'Using "TypedArray.buffer" is not safe since it doesn\'t '
'handle sub-arrays'
whitelist_regexp: 'lib/util/buffer_utils.js'
whitelist_regexp: 'lib/util/object_utils.js'
whitelist_regexp: 'test/util/buffer_utils_unit.js'
}
# Disallow Element.innerHTML and outerHTML.
requirement: {
type: BANNED_PROPERTY
value: 'Element.prototype.innerHTML'
value: 'Element.prototype.outerHTML'
error_message: 'Using "Element.innerHTML" or "Element.outerHTML" is not '
'allowed due to security concerns; use textContent, '
'appendChild, or removeChild instead'
whitelist_regexp: 'test/test/util/util.js'
}
# Disallow Input.valueAsNumber.
requirement: {
type: BANNED_PROPERTY
value: 'HTMLInputElement.prototype.valueAsNumber'
error_message: '"Input.valueAsNumber" is not supported on IE11'
}
# Disallow fdescribe.
requirement: {
type: BANNED_NAME
value: 'fdescribe'
error_message: 'Using "fdescribe" is not allowed'
}
# Disallow fit.
requirement: {
type: BANNED_NAME
value: 'fit'
error_message: 'Using "fit" is not allowed'
whitelist_regexp: 'test/player_external.js'
}
# Disallow classList toggle.
requirement: {
type: BANNED_PROPERTY_CALL
value: 'DOMTokenList.prototype.toggle'
error_message: 'classList toggle is not supported in IE11'
}
# Disallow setInterval.
requirement: {
type: BANNED_NAME
value: 'window.setInterval'
error_message: 'setInterval has several drawbacks, most of '
'all difficulty canceling and surprising behavior '
'when the device goes to sleep. Please use '
'shaka.util.Timer instead.'
whitelist_regexp: 'demo/'
whitelist_regexp: 'test/'
}
requirement: {
type: BANNED_NAME
value: 'setInterval'
error_message: 'setInterval has several drawbacks, most of '
'all difficulty canceling and surprising behavior '
'when the device goes to sleep. Please use '
'shaka.util.Timer instead.'
whitelist_regexp: 'demo/'
whitelist_regexp: 'test/'
}
# Disallow setTimeout.
requirement: {
type: BANNED_NAME
value: 'window.setTimeout'
error_message: 'setTimeout has several drawbacks, most of '
'all difficulty canceling it. Please use '
'shaka.util.Timer instead.'
whitelist_regexp: 'demo/'
whitelist_regexp: 'test/'
whitelist_regexp: 'lib/util/delayed_tick.js'
}
requirement: {
type: BANNED_NAME
value: 'setTimeout'
error_message: 'setTimeout has several drawbacks, most of '
'all difficulty canceling it. Please use '
'shaka.util.Timer instead.'
whitelist_regexp: 'demo/'
whitelist_regexp: 'test/'
}
# Disallow eval, except when testing for modern JS syntax in demo
requirement: {
type: BANNED_NAME
value: 'window.eval'
error_message: 'Using "eval" is not allowed'
whitelist_regexp: 'demo/demo_utils.js'
}
requirement: {
type: BANNED_NAME
value: 'eval'
error_message: 'Using "eval" is not allowed'
whitelist_regexp: 'demo/demo_utils.js'
}
# Disallow the Event constructor, since Event is not constructable on IE.
requirement: {
type: BANNED_CODE_PATTERN
value: '/** @param {*} name */ '
'function template(name) { new Event(name); }'
error_message: 'Event is not constructable on IE. Instead, use '
'document.createEvent(\'CustomEvent\') to create an event and '
'event.initCustomEvent(\'my-event-type\') to initialize it.'
whitelist_regexp: 'lib/polyfill/patchedmediakeys_apple.js'
whitelist_regexp: 'lib/polyfill/pip_webkit.js'
}
# Disallow ES6 methods.
requirement: {
type: BANNED_PROPERTY
value: 'ArrayBuffer.prototype.slice'
error_message: 'ArrayBuffer.slice is not allowed because it '
'is not supported on Tizen 2016'
}
requirement: {
type: BANNED_PROPERTY
value: 'TypedArray.prototype.slice'
error_message: 'TypedArray.slice is not allowed because it '
'is not supported on IE11'
whitelist_regexp: 'lib/polyfill/patchedmediakeys_apple.js'
}
requirement: {
type: BANNED_NAME
value: 'ArrayBuffer.isView'
error_message: 'ES6 ArrayBuffer methods are not allowed '
'because they are not supported in IE11'
}
requirement: {
type: BANNED_NAME
value: 'Int8Array.of'
value: 'Int8Array.from'
value: 'Uint8Array.of'
value: 'Uint8Array.from'
value: 'Uint8ClampedArray.of'
value: 'Uint8ClampedArray.from'
value: 'Int16Array.of'
value: 'Int16Array.from'
value: 'Uint16Array.of'
value: 'Uint16Array.from'
value: 'Int32Array.of'
value: 'Int32Array.from'
value: 'Uint32Array.of'
value: 'Uint32Array.from'
value: 'Float32Array.of'
value: 'Float32Array.from'
value: 'Float64Array.of'
value: 'Float64Array.from'
error_message: 'ES6 TypedArray methods are not allowed '
'because they are not supported in IE11'
}