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