tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

eslint-test-paths.config.mjs (15877B)


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