From 6ef3b5d3a842469e1e0907bf397cda4908fede73 Mon Sep 17 00:00:00 2001 From: trickypr <23250792+trickypr@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:29:52 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Create=20a=20chrome=20level=20test?= =?UTF-8?q?=20runner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/.prettierrc | 12 -- .config/webpack.config.cjs | 8 + .config/.prettierignore => .prettierignore | 0 package.json | 17 +- pnpm-lock.yaml | 152 ++++++++++++++++++ scripts/license-check.ts | 4 +- scripts/unit-test.ts | 35 ++++ .../shared/search/providers/URLProvider.ts | 7 +- src/content/tests/manager.ts | 39 +++++ src/content/tests/shared/index.ts | 5 + src/content/tests/shared/search/index.ts | 5 + .../shared/search/providers/URLProvider.ts | 61 +++++++ .../tests/shared/search/providers/index.ts | 5 + src/content/tests/tests.ts | 14 ++ src/content/types.d.ts | 6 + src/prefs.js | 3 + tsconfig.json | 15 +- 17 files changed, 367 insertions(+), 21 deletions(-) delete mode 100644 .config/.prettierrc rename .config/.prettierignore => .prettierignore (100%) create mode 100644 scripts/unit-test.ts create mode 100644 src/content/tests/manager.ts create mode 100644 src/content/tests/shared/index.ts create mode 100644 src/content/tests/shared/search/index.ts create mode 100644 src/content/tests/shared/search/providers/URLProvider.ts create mode 100644 src/content/tests/shared/search/providers/index.ts create mode 100644 src/content/tests/tests.ts diff --git a/.config/.prettierrc b/.config/.prettierrc deleted file mode 100644 index 65cc559..0000000 --- a/.config/.prettierrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "semi": false, - "singleQuote": true, - "overrides": [ - { - "files": "src/prefs.js", - "options": { - "semi": true - } - } - ] -} diff --git a/.config/webpack.config.cjs b/.config/webpack.config.cjs index 81700f9..fed87e2 100644 --- a/.config/webpack.config.cjs +++ b/.config/webpack.config.cjs @@ -28,6 +28,7 @@ exports.default = (env, argv) => { { title: 'Settings', folder: 'settings', outFolder: 'settings' }, { title: 'Bookmarks', folder: 'bookmarks', outFolder: 'bookmarks' }, { title: 'Credits', folder: 'credits', outFolder: 'credits' }, + { title: 'Test runner', folder: 'tests', outFolder: 'tests' }, ], dev, ) @@ -61,6 +62,9 @@ const sharedSettings = (contentFiles, dev) => { }, resolve: { extensions: ['.ts', '.mjs', '.js', '.svelte'], + alias: { + '@shared': resolve('src/content/shared'), + }, }, devtool: dev ? 'inline-source-map' : 'source-map', @@ -123,6 +127,10 @@ const sharedSettings = (contentFiles, dev) => { test: /\.(png|jpe?g|gif|svg|webp)$/i, type: 'asset/resource', }, + { + test: /\.txt$/, + type: 'asset/source', + }, ], }, plugins: [ diff --git a/.config/.prettierignore b/.prettierignore similarity index 100% rename from .config/.prettierignore rename to .prettierignore diff --git a/package.json b/package.json index 70b7059..6511e17 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts:build": "tsc -p ./tsconfigs/tsconfig.scripts.json", "script:setup": "node ./.scripts/setup.js", "script:license-check": "node ./.scripts/license-check.js", + "script:unit-test": "node ./.scripts/unit-test.js", "app:start": "MOZ_ENABLE_WAYLAND=1 ./.store/rt/quark-runtime -no-remote", "app:startX": "./.store/rt/quark-runtime -no-remote", "build": "rm -rf dist && concurrently -c auto pnpm:build-*", @@ -28,6 +29,7 @@ "author": "", "license": "ISC", "devDependencies": { + "@tinyhttp/app": "^2.2.1", "@tsconfig/svelte": "^5.0.2", "@types/node": "^20.8.4", "concurrently": "^8.2.1", @@ -52,7 +54,8 @@ "webpack": "^5.89.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.15.1", - "webpack-license-plugin": "^4.4.2" + "webpack-license-plugin": "^4.4.2", + "zora": "^5.2.0" }, "dependencies": { "@catppuccin/palette": "^0.2.0", @@ -65,5 +68,17 @@ "patchedDependencies": { "svelte@4.2.1": "patches/svelte@4.2.1.patch" } + }, + "prettier": { + "semi": false, + "singleQuote": true, + "overrides": [ + { + "files": "src/prefs.js", + "options": { + "semi": true + } + } + ] } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e236617..fbb97ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,6 +27,9 @@ dependencies: version: 2.0.0 devDependencies: + '@tinyhttp/app': + specifier: ^2.2.1 + version: 2.2.1 '@tsconfig/svelte': specifier: ^5.0.2 version: 5.0.2 @@ -102,6 +105,9 @@ devDependencies: webpack-license-plugin: specifier: ^4.4.2 version: 4.4.2(webpack@5.89.0) + zora: + specifier: ^5.2.0 + version: 5.2.0 packages: @@ -213,6 +219,127 @@ packages: fastq: 1.15.0 dev: true + /@tinyhttp/accepts@2.2.0: + resolution: {integrity: sha512-Jz60vPt9eQDXtFNaTHGhVsFNEFoQxHldGhB0a6L1oS4MvGJNs6pX5Ibntgth2/DcdtR+PFtbOhKVsZf8kveDLw==} + engines: {node: '>=12.20.0'} + dependencies: + mime: 4.0.0-beta.1 + negotiator: 0.6.3 + dev: true + + /@tinyhttp/app@2.2.1: + resolution: {integrity: sha512-ncqALQSbEC8Q3s22j8OG2e6DtHOUx4VE11AK7XYbWsVTZ2JKFy1iBfhOiJOmPPd3tlcIZ/dr0zC8iSQ8EFrWLA==} + engines: {node: '>=14.21.3'} + dependencies: + '@tinyhttp/cookie': 2.1.0 + '@tinyhttp/proxy-addr': 2.1.2 + '@tinyhttp/req': 2.2.0 + '@tinyhttp/res': 2.2.0 + '@tinyhttp/router': 2.2.1 + header-range-parser: 1.1.3 + regexparam: 2.0.1 + dev: true + + /@tinyhttp/content-disposition@2.2.0: + resolution: {integrity: sha512-w1dJaSAtcCinOlT/YQg35RnFCOBbCHBGDVhH4yLoiJVtecRAJ2cYMf5HP+UhfbXURa38GC8fkRXO0vODDTjmeg==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/content-type@0.1.4: + resolution: {integrity: sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==} + engines: {node: '>=12.4'} + dev: true + + /@tinyhttp/cookie-signature@2.1.0: + resolution: {integrity: sha512-bpOXBGf9rKoajtEG75O7xjwW+u2I/NNPkJWJTDdr6j7Vx0lG5R9Hnl3ty80Af4jwyo90ywXVpZIxKLubPK6RzA==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/cookie@2.1.0: + resolution: {integrity: sha512-o56utxXvIuLTCtPm66r8lcyUufpw0RkO+u4wQrTbc6snyyGZZ9hHzGRxPyko0ks90ctOkLh0mNKn7YZaTWlvfw==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/encode-url@2.1.0: + resolution: {integrity: sha512-POXlTYIPReU5CBnNmJ1oyzPEpG9uI41bWoW5xBWomJkL6hQgArzlmU8i1kr8+JPf3O+MVBaJ5tMTS/09uOULZw==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/etag@2.1.0: + resolution: {integrity: sha512-zb+SyhwOIaciIzYdoaUWDSJg1asFqRSE8gnDqaUA0nJKg8T1Y1c7Dauzs3QY4VApy2zdbI8gk23XZXOfzL1J0g==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/forwarded@2.1.1: + resolution: {integrity: sha512-nO3kq0R1LRl2+CAMlnggm22zE6sT8gfvGbNvSitV6F9eaUSurHP0A8YZFMihSkugHxK+uIegh1TKrqgD8+lyGQ==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/proxy-addr@2.1.2: + resolution: {integrity: sha512-gqb1RRxMVlvoq4Hg2O6pTVkjnb1beonDYpCNz5dLQEWtNf614KfeP6ih35MEzvda0g1fr09lq2Crp9cp1kvRNg==} + engines: {node: '>=12.20.0'} + dependencies: + '@tinyhttp/forwarded': 2.1.1 + ipaddr.js: 2.1.0 + dev: true + + /@tinyhttp/req@2.2.0: + resolution: {integrity: sha512-Q8qBOdg4YXq299cK9y1EtJ4XDDLtBTvaO7IwE/xZuTwUfEscNeMf/w5FFYXtqhlZnQS+dxGeTv/dlcowBU3hFA==} + engines: {node: '>=12.20.0'} + dependencies: + '@tinyhttp/accepts': 2.2.0 + '@tinyhttp/type-is': 2.2.0 + '@tinyhttp/url': 2.1.0 + header-range-parser: 1.1.3 + dev: true + + /@tinyhttp/res@2.2.0: + resolution: {integrity: sha512-kdZn6cOdlIlZYLj6sXgB+TRppkf/3Lfc/t1DdIy70COb3+CXN8KQvKgtjDirUBjRuMyKv141UtY6edfrt+BqMQ==} + engines: {node: '>=12.20.0'} + dependencies: + '@tinyhttp/content-disposition': 2.2.0 + '@tinyhttp/cookie': 2.1.0 + '@tinyhttp/cookie-signature': 2.1.0 + '@tinyhttp/encode-url': 2.1.0 + '@tinyhttp/req': 2.2.0 + '@tinyhttp/send': 2.2.0 + '@tinyhttp/vary': 0.1.3 + es-escape-html: 0.1.1 + mime: 4.0.0-beta.1 + dev: true + + /@tinyhttp/router@2.2.1: + resolution: {integrity: sha512-ssaXDGRfyAG3bTg2iXqma4N54ehVZLsQPD98/fePTJJxMDsirZYFYMvJaxyH7A7ezRrazys1ZyEDPa6tFDtoCQ==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/send@2.2.0: + resolution: {integrity: sha512-MyWrmsdBci9p8JrSSqd0XuHoxtKfUZNbLQXGMVxf+BmZtcZW4TJV95FjTLnnZPLZ2+r30WpokYSYDiyK48U+Ag==} + engines: {node: '>=12.20.0'} + dependencies: + '@tinyhttp/content-type': 0.1.4 + '@tinyhttp/etag': 2.1.0 + mime: 4.0.0-beta.1 + dev: true + + /@tinyhttp/type-is@2.2.0: + resolution: {integrity: sha512-BtnndSlJ5mv2AUu6D3sweI39xVPSS/+9BaoXWSjCrNsN/fgAEaNZOOaIh+sUU3r0U99y0DQo9LEIwNaIO5nOig==} + engines: {node: '>=12.20.0'} + dependencies: + '@tinyhttp/content-type': 0.1.4 + mime: 4.0.0-beta.1 + dev: true + + /@tinyhttp/url@2.1.0: + resolution: {integrity: sha512-y+VhvhlpFAtIebuqrdwxmg0MpVb0BC5FJ3oWuDWqWkUQNqKAyBnJ2o5pb9AQ05yxX4HQqmxTQonvWAnpnBsiaw==} + engines: {node: '>=12.20.0'} + dev: true + + /@tinyhttp/vary@0.1.3: + resolution: {integrity: sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==} + engines: {node: '>=12.20'} + dev: true + /@tsconfig/svelte@5.0.2: resolution: {integrity: sha512-BRbo1fOtyVbhfLyuCWw6wAWp+U8UQle+ZXu84MYYWzYSEB28dyfnRBIE99eoG+qdAC0po6L2ScIEivcT07UaMA==} dev: true @@ -1222,6 +1349,11 @@ packages: is-arrayish: 0.2.1 dev: true + /es-escape-html@0.1.1: + resolution: {integrity: sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==} + engines: {node: '>=12.x'} + dev: true + /es-module-lexer@1.3.1: resolution: {integrity: sha512-JUFAyicQV9mXc3YRxPnDlrfBKpqt6hUYzz9/boprUJHs4e4KVr3XwOF70doO6gwXUor6EWZJAyWAfKki84t20Q==} dev: true @@ -1578,6 +1710,11 @@ packages: hasBin: true dev: true + /header-range-parser@1.1.3: + resolution: {integrity: sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==} + engines: {node: '>=12.22.0'} + dev: true + /hpack.js@2.1.6: resolution: {integrity: sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ==} dependencies: @@ -2055,6 +2192,12 @@ packages: hasBin: true dev: true + /mime@4.0.0-beta.1: + resolution: {integrity: sha512-8/p99P1RV17prytee/A6D+8shNqdDzyvGJ/CVfiuXwh4cTsv3P3qGyaYSx2hdqnqbKKqYUfTC5zAjCtcd1BShw==} + engines: {node: '>=16'} + hasBin: true + dev: true + /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -2580,6 +2723,11 @@ packages: resolution: {integrity: sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==} dev: true + /regexparam@2.0.1: + resolution: {integrity: sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==} + engines: {node: '>=8'} + dev: true + /relateurl@0.2.7: resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} engines: {node: '>= 0.10'} @@ -3544,6 +3692,10 @@ packages: yargs-parser: 21.1.1 dev: true + /zora@5.2.0: + resolution: {integrity: sha512-FSZOvfJVfMWhk/poictNsDBCXq/Z+2Zu2peWs6d8OhWWb9nY++czw95D47hdw06L/kfjasLevwrbUtnXyWLAJw==} + dev: true + github.com/quark-platform/gecko-types/f849d774972701f18fb5db09084a68025933dc2e: resolution: {tarball: https://codeload.github.com/quark-platform/gecko-types/tar.gz/f849d774972701f18fb5db09084a68025933dc2e} name: gecko-types diff --git a/scripts/license-check.ts b/scripts/license-check.ts index 7ab4613..6f102eb 100644 --- a/scripts/license-check.ts +++ b/scripts/license-check.ts @@ -10,7 +10,9 @@ import { walkDirectory } from './lib/fs.js' import { autoFix, isValidLicense } from './lib/license.js' import { failure } from './lib/logging.js' -const IGNORED_FILES = new RegExp('.*\\.(json|patch|md|jpeg|png|gif|tiff|ico)') +const IGNORED_FILES = new RegExp( + '.*\\.(json|patch|md|jpeg|png|gif|tiff|ico|txt)', +) const shouldFix = argv.includes('--fix') const filesToCheck = [ diff --git a/scripts/unit-test.ts b/scripts/unit-test.ts new file mode 100644 index 0000000..e623c31 --- /dev/null +++ b/scripts/unit-test.ts @@ -0,0 +1,35 @@ +import { argv, exit } from 'node:process' +import { App } from '@tinyhttp/app' +import { type ExecaChildProcess, execa } from 'execa' + +// If you update this port, you should update the port in the test runner +const TEST_PORT = 3948 +const TEST_RUNNER_URL = 'chrome://browser/content/tests/index.html' + +const shouldWatch = argv.includes('--watch') +let testProcess: ExecaChildProcess + +// This is the way that the test runner communicates with the test app +new App() + .get('/config', (_, res) => void res.send({ shouldWatch })) + .post('/results', (req, res) => { + req.on('data', (chunk: Buffer) => { + console.log(chunk.toString()) + }) + req.on('close', () => { + res.send('ok') + + if (!shouldWatch) { + testProcess?.kill() + exit() + } + }) + }) + .listen(TEST_PORT) + +if (!shouldWatch) + testProcess = execa('./.store/rt/quark-runtime', [ + '--no-remote', + '--chrome', + TEST_RUNNER_URL, + ]) diff --git a/src/content/shared/search/providers/URLProvider.ts b/src/content/shared/search/providers/URLProvider.ts index 3dbe7c4..9c0c932 100644 --- a/src/content/shared/search/providers/URLProvider.ts +++ b/src/content/shared/search/providers/URLProvider.ts @@ -6,7 +6,7 @@ import { Provider, type ProviderResult } from '../provider' import tld from './data/tld.txt' const URL_REGEX = - /^^(?https?:\/\/)?(?(\w+\.)+(?\w+))(?\/.*)?$$/gm + /^^(?https?:\/\/)?(?(\w+\.)+(?\w+))(?\/.*)?$$/m const tlds = tld .split('\n') .filter((tld) => tld.length > 0 && !tld.startsWith('#')) @@ -17,14 +17,15 @@ export class URLProvider extends Provider { if (match === null) return [] const { protocol, domain, tld, path } = match.groups || {} - const uri = `${protocol ?? 'https://'}${domain}.${tld}${path ?? ''}` + const uri = `${protocol || 'https://'}${domain}${path || ''}` // If it is not a valid tld, don't show it - if (!tlds.includes(tld)) return [] + if (!tlds.includes(tld.toUpperCase())) return [] return [ { title: uri, + // @ts-ignore url: Services.io.newURI(uri), icon: `chrome://branding/content/icon32.png`, }, diff --git a/src/content/tests/manager.ts b/src/content/tests/manager.ts new file mode 100644 index 0000000..b4e1640 --- /dev/null +++ b/src/content/tests/manager.ts @@ -0,0 +1,39 @@ +import { hold, report, createTAPReporter } from 'zora' + +const TEST_PORT = 3948 +const TEST_OUTPUT = document.createElement('pre') + +document.body.appendChild(TEST_OUTPUT) + +export async function manageTests( + tests: () => Promise, +): Promise<(tests: () => Promise) => Promise> { + const config = await fetch(`http://localhost:${TEST_PORT}/config`).then((r) => + r.json(), + ) + + async function performTests(tests: () => Promise) { + hold() + await tests() + + let log = '' + const reporter = createTAPReporter({ log: (s) => (log += s + '\n') }) + await report({ reporter }) + TEST_OUTPUT.innerHTML = log + + // Send the report back to the test runner + await fetch(`http://localhost:${TEST_PORT}/results`, { + method: 'POST', + body: log, + }) + } + + await performTests(tests) + + // If we aren't watching, close the window when the tests are done + if (!config.shouldWatch) { + window.close() + } + + return performTests +} diff --git a/src/content/tests/shared/index.ts b/src/content/tests/shared/index.ts new file mode 100644 index 0000000..f5d0384 --- /dev/null +++ b/src/content/tests/shared/index.ts @@ -0,0 +1,5 @@ +import search from './search' + +export default async function () { + await search() +} diff --git a/src/content/tests/shared/search/index.ts b/src/content/tests/shared/search/index.ts new file mode 100644 index 0000000..2eb870c --- /dev/null +++ b/src/content/tests/shared/search/index.ts @@ -0,0 +1,5 @@ +import providers from './providers' + +export default async function () { + await providers() +} diff --git a/src/content/tests/shared/search/providers/URLProvider.ts b/src/content/tests/shared/search/providers/URLProvider.ts new file mode 100644 index 0000000..7cf8df9 --- /dev/null +++ b/src/content/tests/shared/search/providers/URLProvider.ts @@ -0,0 +1,61 @@ +import { test } from 'zora' + +import { URLProvider } from '@shared/search/providers/URLProvider' + +export default async function () { + const urlProvider = new URLProvider() + + await test('URLProvider: google.com', async (t) => { + const result = await urlProvider.getResults('google.com') + t.ok(result, 'result exists') + t.ok(result.length > 0, 'result has length') + if (!result.length) return + t.equal(result[0].title, 'https://google.com', 'title is correct') + t.equal(result[0].url.spec, 'https://google.com/', 'url is correct') + }) + + await test('URLProvider: https://google.com', async (t) => { + const result = await urlProvider.getResults('https://google.com') + t.ok(result, 'result exists') + t.ok(result.length > 0, 'result has length') + if (!result.length) return + t.equal(result[0].title, 'https://google.com', 'title is correct') + t.equal(result[0].url.spec, 'https://google.com/', 'url is correct') + }) + + await test('URLProvider: google.com/test', async (t) => { + const result = await urlProvider.getResults('google.com/test') + t.ok(result, 'result exists') + t.ok(result.length > 0, 'result has length') + if (!result.length) return + t.equal(result[0].title, 'https://google.com/test', 'title is correct') + t.equal(result[0].url.spec, 'https://google.com/test', 'url is correct') + }) + + await test('URLProvider: https://google.com/test', async (t) => { + const result = await urlProvider.getResults('https://google.com/test') + t.ok(result, 'result exists') + t.ok(result.length > 0, 'result has length') + if (!result.length) return + t.equal(result[0].title, 'https://google.com/test', 'title is correct') + t.equal(result[0].url.spec, 'https://google.com/test', 'url is correct') + }) + + await test('URLProvider: https://abc.notarealurl', async (t) => { + const result = await urlProvider.getResults('https://abc.notarealurl') + t.ok(result, 'result exists') + t.equal(result.length, 0, 'result has length') + }) + + await test('URLProvider: https://abc.notarealurl/test', async (t) => { + const result = await urlProvider.getResults('https://abc.notarealurl/test') + t.ok(result, 'result exists') + t.equal(result.length, 0, 'result has length') + }) + + await test('URLProvider: text', async (t) => { + const result = await urlProvider.getResults('text') + t.ok(result, 'result exists') + t.equal(result.length, 0, 'result has length') + }) +} diff --git a/src/content/tests/shared/search/providers/index.ts b/src/content/tests/shared/search/providers/index.ts new file mode 100644 index 0000000..84f4555 --- /dev/null +++ b/src/content/tests/shared/search/providers/index.ts @@ -0,0 +1,5 @@ +import URLProvider from './URLProvider' + +export default async function () { + await URLProvider() +} diff --git a/src/content/tests/tests.ts b/src/content/tests/tests.ts new file mode 100644 index 0000000..4fc48d7 --- /dev/null +++ b/src/content/tests/tests.ts @@ -0,0 +1,14 @@ +import { test } from 'zora' +import { manageTests } from './manager' + +import shared from './shared' + +async function tests() { + await shared() +} + +await manageTests(tests) + +if (module.hot) { + module.hot.dispose(() => window.location.reload()) +} diff --git a/src/content/types.d.ts b/src/content/types.d.ts index 7fd3ec0..4fd4931 100644 --- a/src/content/types.d.ts +++ b/src/content/types.d.ts @@ -13,3 +13,9 @@ declare module '*.txt' { declare interface Window { windowApi: typeof import('./lib/globalApi').windowApi } + +declare interface NodeModule { + hot?: { + dispose: (cb: () => void) => void + } +} diff --git a/src/prefs.js b/src/prefs.js index 1a52496..e5e2727 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -37,3 +37,6 @@ pref('accessibility.typeaheadfind', false); pref('accessibility.typeaheadfind.timeout', 5000); pref('accessibility.typeaheadfind.linksonly', false); pref('accessibility.typeaheadfind.flashBar', 1); + +// Enable firefox compat +pref('general.useragent.compatMode.firefox', true); diff --git a/tsconfig.json b/tsconfig.json index 110e886..87b7d99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,9 +4,16 @@ "target": "es2022", "allowArbitraryExtensions": true, "paths": { - /* "~/*": ["./src/*"] */ + "@shared/*": [ + "./src/content/shared/*" + ] } }, - "include": ["src/content/**/*"], - "exclude": ["node_modules/*", "public/*"] -} + "include": [ + "src/content/**/*" + ], + "exclude": [ + "node_modules/*", + "public/*" + ] +} \ No newline at end of file