Backed out 2 changesets (bug 1900842, bug 1900851) for causing mochitest failures...
[gecko.git] / .eslintrc-test-paths.js
blob3beca52b054d59bd95e1d11fee70b756eb77086f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 // The `*testPaths` defined below for test paths are the main path formats we
8 // prefer to support for tests as they are commonly used across the tree.
10 // We prefer the tests to be in named directories as this makes it easier
11 // to identify the types of tests developers are working with. Additionally,
12 // it is not possible to scope ESLint rules to individual files based on .ini
13 // files without a build step that would break editors, or an expensive loading
14 // cycle.
16 // Please do not add more cases of multiple test types in a single
17 // directory. This may cause ESLint rules to be incorrectly applied to the wrong
18 // tests, leading to false negatives. It could cause the wrong sets of globals
19 // to be defined in the scope, causing false positives when checking for no
20 // undefined variables.
22 // See https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint.html#i-m-adding-tests-how-do-i-set-up-the-right-configuration
23 // for more information.
25 const browserTestPaths = ["**/test*/**/browser*/"];
27 const chromeTestPaths = ["**/test*/chrome/"];
29 const mochitestTestPaths = [
30   // Note: we do not want to match testing/mochitest as that would apply
31   // too many globals for that directory.
32   "**/test/mochitest*/",
33   "**/tests/mochitest*/",
34   "testing/mochitest/tests/SimpleTest/",
35   "testing/mochitest/tests/Harness_sanity/",
38 const xpcshellTestPaths = [
39   "**/test*/unit*/**/",
40   "**/test*/*/unit*/",
41   "**/test*/xpcshell/**/",
44 // NOTE: Before adding to the list below, please see the note at the top
45 // of the file.
47 const extraXpcshellTestPaths = [
48   "devtools/platform/tests/xpcshell/",
49   "dom/file/tests/",
50   "dom/ipc/tests/",
51   "intl/benchmarks/",
52   "intl/l10n/test/",
53   "ipc/testshell/tests/",
54   "memory/replace/dmd/test/",
55   "netwerk/test/httpserver/test/",
56   "testing/modules/tests/xpcshell/",
57   "toolkit/components/backgroundhangmonitor/tests/",
58   "toolkit/components/downloads/test/data/",
59   "toolkit/components/mozintl/test/",
60   "toolkit/components/places/tests/",
61   "toolkit/components/places/tests/bookmarks/",
62   "toolkit/components/places/tests/expiration/",
63   "toolkit/components/places/tests/favicons/",
64   "toolkit/components/places/tests/history/",
65   "toolkit/components/places/tests/legacy/",
66   "toolkit/components/places/tests/migration/",
67   "toolkit/components/places/tests/queries/",
68   "toolkit/components/thumbnails/test/",
69   "toolkit/modules/tests/modules/",
70   "toolkit/mozapps/update/tests/data/",
71   "toolkit/profile/xpcshell/",
72   "toolkit/xre/test/",
73   "widget/headless/tests/",
76 // NOTE: Before adding to the list below, please see the note at the top
77 // of the file.
79 const extraBrowserTestPaths = [
80   "dom/ipc/tests/",
81   "toolkit/components/thumbnails/test/",
82   "toolkit/xre/test/",
83   "browser/base/content/test/about/",
84   "browser/base/content/test/alerts/",
85   "browser/base/content/test/backforward/",
86   "browser/base/content/test/caps/",
87   "browser/base/content/test/captivePortal/",
88   "browser/base/content/test/contentTheme/",
89   "browser/base/content/test/contextMenu/",
90   "browser/base/content/test/favicons/",
91   "browser/base/content/test/forms/",
92   "browser/base/content/test/fullscreen/",
93   "browser/base/content/test/general/",
94   "browser/base/content/test/gesture/",
95   "browser/base/content/test/historySwipeAnimation/",
96   "browser/base/content/test/keyboard/",
97   "browser/base/content/test/menubar/",
98   "browser/base/content/test/metaTags/",
99   "browser/base/content/test/notificationbox/",
100   "browser/base/content/test/outOfProcess/",
101   "browser/base/content/test/pageActions/",
102   "browser/base/content/test/pageStyle/",
103   "browser/base/content/test/pageinfo/",
104   "browser/base/content/test/performance/",
105   "browser/base/content/test/permissions/",
106   "browser/base/content/test/plugins/",
107   "browser/base/content/test/popupNotifications/",
108   "browser/base/content/test/popups/",
109   "browser/base/content/test/privateBrowsing/",
110   "browser/base/content/test/protectionsUI/",
111   "browser/base/content/test/referrer/",
112   "browser/base/content/test/sanitize/",
113   "browser/base/content/test/sidebar/",
114   "browser/base/content/test/siteIdentity/",
115   "browser/base/content/test/startup/",
116   "browser/base/content/test/static/",
117   "browser/base/content/test/sync/",
118   "browser/base/content/test/tabMediaIndicator/",
119   "browser/base/content/test/tabPrompts/",
120   "browser/base/content/test/tabcrashed/",
121   "browser/base/content/test/tabdialogs/",
122   "browser/base/content/test/touch/",
123   "browser/base/content/test/utilityOverlay/",
124   "browser/base/content/test/webextensions/",
125   "browser/base/content/test/webrtc/",
126   "browser/base/content/test/zoom/",
127   "browser/components/customizableui/test/",
128   "browser/components/pocket/test/",
129   "browser/components/preferences/tests/",
130   "browser/components/safebrowsing/content/test/",
131   "browser/components/sessionstore/test/",
132   "browser/components/shell/test/",
133   "browser/components/touchbar/tests/",
134   "browser/components/uitour/test/",
135   "browser/extensions/report-site-issue/test/browser/",
136   "browser/tools/mozscreenshots/",
137   "caps/tests/mochitest/",
138   "devtools/client/debugger/test/mochitest/",
139   "devtools/client/dom/test/",
140   "devtools/client/framework/browser-toolbox/test/",
141   "devtools/client/framework/test/",
142   "devtools/client/inspector/animation/test/",
143   "devtools/client/inspector/boxmodel/test/",
144   "devtools/client/inspector/changes/test/",
145   "devtools/client/inspector/computed/test/",
146   "devtools/client/inspector/extensions/test/",
147   "devtools/client/inspector/flexbox/test/",
148   "devtools/client/inspector/fonts/test/",
149   "devtools/client/inspector/grids/test/",
150   "devtools/client/inspector/markup/test/",
151   "devtools/client/inspector/rules/test/",
152   "devtools/client/inspector/shared/test/",
153   "devtools/client/inspector/test/",
154   "devtools/client/jsonview/test/",
155   "devtools/client/memory/test/browser/",
156   "devtools/client/netmonitor/src/har/test/",
157   "devtools/client/netmonitor/test/",
158   "devtools/client/shared/sourceeditor/test/",
159   "devtools/client/shared/test/",
160   "devtools/client/storage/test/",
161   "devtools/client/styleeditor/test/",
162   "devtools/shared/commands/inspected-window/tests/",
163   "devtools/shared/commands/inspector/tests/",
164   "devtools/shared/commands/network/tests/",
165   "devtools/shared/commands/resource/tests/",
166   "devtools/shared/commands/script/tests/",
167   "devtools/shared/commands/target-configuration/tests/",
168   "devtools/shared/commands/target/tests/",
169   "devtools/shared/commands/thread-configuration/tests/",
170   "devtools/shared/test-helpers/",
171   "docshell/test/navigation/",
172   "dom/base/test/",
173   "dom/broadcastchannel/tests/",
174   "dom/events/test/",
175   "dom/fetch/tests/",
176   "dom/file/ipc/tests/",
177   "dom/html/test/",
178   "dom/indexedDB/test/",
179   "dom/ipc/tests/",
180   "dom/l10n/tests/mochitest/",
181   "dom/localstorage/test/",
182   "dom/manifest/test/",
183   "dom/midi/tests/",
184   "dom/payments/test/",
185   "dom/plugins/test/mochitest/",
186   "dom/reporting/tests/",
187   "dom/security/test/cors/",
188   "dom/security/test/csp/",
189   "dom/security/test/general/",
190   "dom/security/test/https-first/",
191   "dom/security/test/https-only/",
192   "dom/security/test/mixedcontentblocker/",
193   "dom/security/test/referrer-policy/",
194   "dom/security/test/sec-fetch/",
195   "dom/serviceworkers/test/",
196   "dom/tests/browser/",
197   "dom/url/tests/",
198   "dom/workers/test/",
199   "dom/xhr/tests/",
200   "editor/libeditor/tests/",
201   "extensions/permissions/test/",
202   "layout/base/tests/",
203   "layout/style/test/",
204   "layout/xul/test/",
205   "netwerk/test/useragent/",
206   "parser/htmlparser/tests/mochitest/",
207   "security/sandbox/test/",
208   "testing/mochitest/baselinecoverage/browser_chrome/",
209   "testing/mochitest/tests/python/files/",
210   "toolkit/components/alerts/test/",
211   "toolkit/components/mozprotocol/tests/",
212   "toolkit/components/narrate/test/",
213   "toolkit/components/pdfjs/test/",
214   "toolkit/components/pictureinpicture/tests/",
215   "toolkit/components/printing/tests/",
216   "toolkit/components/reader/tests/",
217   "toolkit/components/thumbnails/test/",
218   "toolkit/components/tooltiptext/tests/",
219   "toolkit/components/windowcreator/test/",
220   "toolkit/components/windowwatcher/test/",
221   "toolkit/mozapps/extensions/test/xpinstall/",
222   "uriloader/exthandler/tests/mochitest/",
225 // NOTE: Before adding to the list below, please see the note at the top
226 // of the file.
228 const extraChromeTestPaths = [
229   "devtools/shared/security/tests/chrome/",
230   "devtools/shared/webconsole/test/chrome/",
231   "dom/base/test/",
232   "dom/battery/test/",
233   "dom/bindings/test/",
234   "dom/console/tests/",
235   "dom/encoding/test/",
236   "dom/events/test/",
237   "dom/flex/test/",
238   "dom/grid/test/",
239   "dom/html/test/",
240   "dom/html/test/forms/",
241   "dom/indexedDB/test/",
242   "dom/messagechannel/tests/",
243   "dom/network/tests/",
244   "dom/promise/tests/",
245   "dom/security/test/general/",
246   "dom/security/test/sec-fetch/",
247   "dom/serviceworkers/test/",
248   "dom/system/tests/",
249   "dom/url/tests/",
250   "dom/websocket/tests/",
251   "dom/workers/test/",
252   "dom/xul/test/",
253   "editor/composer/test/",
254   "extensions/universalchardet/tests/",
255   "gfx/layers/apz/test/mochitest/",
256   "image/test/mochitest/",
257   "layout/forms/test/",
258   "layout/generic/test/",
259   "layout/mathml/tests/",
260   "layout/svg/tests/",
261   "layout/xul/test/",
262   "toolkit/components/aboutmemory/tests/",
263   "toolkit/components/printing/tests/",
264   "toolkit/components/url-classifier/tests/mochitest/",
265   "toolkit/components/viewsource/test/",
266   "toolkit/components/windowcreator/test/",
267   "toolkit/components/windowwatcher/test/",
268   "toolkit/components/workerloader/tests/",
269   "toolkit/content/tests/widgets/",
270   "toolkit/profile/test/",
271   "widget/tests/",
272   "xpfe/appshell/test/",
275 // NOTE: Before adding to the list below, please see the note at the top
276 // of the file.
278 const extraMochitestTestPaths = [
279   "dom/ipc/tests/",
280   "toolkit/xre/test/",
281   "accessible/tests/crashtests/",
282   "browser/components/protocolhandler/test/",
283   "caps/tests/mochitest/",
284   "docshell/test/iframesandbox/",
285   "docshell/test/navigation/",
286   "dom/abort/tests/",
287   "dom/animation/test/mozilla/",
288   "dom/animation/test/style/",
289   "dom/base/test/",
290   "dom/battery/test/",
291   "dom/bindings/test/",
292   "dom/broadcastchannel/tests/",
293   "dom/canvas/test/",
294   "dom/console/tests/",
295   "dom/credentialmanagement/tests/",
296   "dom/crypto/test/",
297   "dom/encoding/test/",
298   "dom/events/test/",
299   "dom/file/tests/",
300   "dom/file/ipc/tests/",
301   "dom/filesystem/compat/tests/",
302   "dom/filesystem/tests/",
303   "dom/html/test/",
304   "dom/html/test/forms/",
305   "dom/indexedDB/test/",
306   "dom/ipc/tests/",
307   "dom/jsurl/test/",
308   "dom/localstorage/test/",
309   "dom/locks/test/",
310   "dom/manifest/test/",
311   "dom/media/mediasession/test/",
312   "dom/media/mediasource/test/",
313   "dom/media/test/",
314   "dom/media/webaudio/test/",
315   "dom/media/webcodecs/test/",
316   "dom/media/webspeech/recognition/test/",
317   "dom/media/webspeech/synth/test/",
318   "dom/messagechannel/tests/",
319   "dom/midi/tests/",
320   "dom/network/tests/",
321   "dom/payments/test/",
322   "dom/performance/tests/",
323   "dom/permission/tests/",
324   "dom/plugins/test/mochitest/",
325   "dom/promise/tests/",
326   "dom/push/test/",
327   "dom/quota/test/modules/content/",
328   "dom/reporting/tests/",
329   "dom/security/test/cors/",
330   "dom/security/test/csp/",
331   "dom/security/test/https-only/",
332   "dom/security/test/mixedcontentblocker/",
333   "dom/security/test/referrer-policy/",
334   "dom/security/test/sec-fetch/",
335   "dom/security/test/sri/",
336   "dom/serviceworkers/test/",
337   "dom/smil/test/",
338   "dom/svg/test/",
339   "dom/system/tests/",
340   "dom/u2f/tests/",
341   "dom/url/tests/",
342   "dom/webauthn/tests/",
343   "dom/websocket/tests/",
344   "dom/workers/test/",
345   "dom/worklet/tests/",
346   "dom/xhr/tests/",
347   "dom/xml/test/",
348   "dom/xul/test/",
349   "editor/composer/test/",
350   "editor/libeditor/tests/",
351   "editor/spellchecker/tests/",
352   "extensions/permissions/test/",
353   "gfx/layers/apz/test/mochitest/",
354   "image/test/mochitest/",
355   "intl/uconv/tests/",
356   "layout/base/tests/",
357   "layout/forms/test/",
358   "layout/generic/test/",
359   "layout/inspector/tests/",
360   "layout/style/test/",
361   "layout/svg/tests/",
362   "layout/tables/test/",
363   "layout/xul/test/",
364   "parser/htmlparser/tests/mochitest/",
365   "services/sync/tests/tps/",
366   "testing/mochitest/baselinecoverage/plain/",
367   "testing/mochitest/tests/python/files/",
368   "toolkit/components/alerts/test/",
369   "toolkit/components/passwordmgr/test/mochitest/",
370   "toolkit/components/prompts/test/",
371   "toolkit/components/satchel/test/",
372   "toolkit/components/url-classifier/tests/mochitest/",
373   "toolkit/components/windowcreator/test/",
374   "toolkit/components/windowwatcher/test/",
375   "toolkit/content/tests/widgets/",
376   "toolkit/xre/test/",
377   "uriloader/exthandler/tests/mochitest/",
378   "widget/tests/",
381 // Please DO NOT add more entries to the list below.
382 // Doing so may cause conflicts in ESLint rules and globals, and cause
383 // unexpected issues to be raised or missed.
384 let expectedDupePaths = new Set([
385   "caps/tests/mochitest/",
386   "docshell/test/navigation/",
387   "dom/base/test/",
388   "dom/battery/test/",
389   "dom/bindings/test/",
390   "dom/broadcastchannel/tests/",
391   "dom/console/tests/",
392   "dom/encoding/test/",
393   "dom/events/test/",
394   "dom/file/tests/",
395   "dom/file/ipc/tests/",
396   "dom/indexedDB/test/",
397   "dom/ipc/tests/",
398   "dom/localstorage/test/",
399   "dom/html/test/",
400   "dom/html/test/forms/",
401   "dom/manifest/test/",
402   "dom/messagechannel/tests/",
403   "dom/midi/tests/",
404   "dom/network/tests/",
405   "dom/payments/test/",
406   "dom/plugins/test/mochitest/",
407   "dom/promise/tests/",
408   "dom/reporting/tests/",
409   "dom/security/test/cors/",
410   "dom/security/test/csp/",
411   "dom/security/test/general/",
412   "dom/security/test/https-only/",
413   "dom/security/test/mixedcontentblocker/",
414   "dom/security/test/referrer-policy/",
415   "dom/security/test/sec-fetch/",
416   "dom/serviceworkers/test/",
417   "dom/system/tests/",
418   "dom/url/tests/",
419   "dom/websocket/tests/",
420   "dom/workers/test/",
421   "dom/xhr/tests/",
422   "dom/xul/test/",
423   "editor/composer/test/",
424   "editor/libeditor/tests/",
425   "extensions/permissions/test/",
426   "gfx/layers/apz/test/mochitest/",
427   "image/test/mochitest/",
428   "layout/base/tests/",
429   "layout/forms/test/",
430   "layout/generic/test/",
431   "layout/style/test/",
432   "layout/svg/tests/",
433   "layout/xul/test/",
434   "parser/htmlparser/tests/mochitest/",
435   "testing/mochitest/tests/python/files/",
436   "toolkit/components/alerts/test/",
437   "toolkit/components/printing/tests/",
438   "toolkit/components/thumbnails/test/",
439   "toolkit/components/url-classifier/tests/mochitest/",
440   "toolkit/components/windowcreator/test/",
441   "toolkit/components/windowwatcher/test/",
442   "toolkit/content/tests/widgets/",
443   "toolkit/xre/test/",
444   "uriloader/exthandler/tests/mochitest/",
445   "widget/tests/",
447 // Please DO NOT add more paths to the list above.
449 let paths = new Set(extraXpcshellTestPaths);
450 for (let path of [
451   ...extraBrowserTestPaths,
452   ...extraChromeTestPaths,
453   ...extraMochitestTestPaths,
454 ]) {
455   if (paths.has(path) && !expectedDupePaths.has(path)) {
456     throw new Error(`
457 Unexpected directory containing different test types: ${path}
459 Please do not add new paths containing different test types. Please use
460 separate directories.
462 Having different test types in the same directory may cause ESLint rules to be
463 incorrectly applied.
465   }
466   paths.add(path);
469 module.exports = {
470   testPaths: {
471     browser: [...browserTestPaths, ...extraBrowserTestPaths],
472     chrome: [...chromeTestPaths, ...extraChromeTestPaths],
473     mochitest: [...mochitestTestPaths, ...extraMochitestTestPaths],
474     xpcshell: [...xpcshellTestPaths, ...extraXpcshellTestPaths],
475   },