Skip to content

Commit c70b53d

Browse files
committed
111
1 parent b540daf commit c70b53d

9 files changed

Lines changed: 707 additions & 20 deletions

File tree

.github/workflows/auto-test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Auto test
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Install pnpm
18+
uses: pnpm/action-setup@v4
19+
with:
20+
version: 10
21+
run_install: false
22+
- name: Install node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 24
26+
cache: 'pnpm'
27+
- run: pnpm i
28+
- run: playwright install chromium
29+
- run: pnpm test

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Auto release
22

33
on:
44
push:
5-
tags:
5+
tags:
66
- v*
77

88
jobs:
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install node
2323
uses: actions/setup-node@v4
2424
with:
25-
node-version: 18
25+
node-version: 24
2626
cache: 'pnpm'
2727
- run: pnpm i
2828
- run: node scripts/getChangeLog.mjs > CHANGELOG.txt
@@ -37,4 +37,4 @@ jobs:
3737
build/*.zip
3838
metafile-*.json
3939
token: ${{ secrets.GITHUB_TOKEN }}
40-
body_path: CHANGELOG.txt
40+
body_path: CHANGELOG.txt

e2e/bot-detector.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { wait } from '@root/utils'
2+
import { expect, test } from './fixtures'
3+
import { evaluate } from './utils'
4+
5+
const url = 'https://bot-detector.rebrowser.net/'
6+
7+
test('bot detector', async ({ page }) => {
8+
await page.goto(url)
9+
10+
await page.evaluate(() => window.dummyFn())
11+
12+
// exposeFunctionLeak
13+
await page.exposeFunction('exposedFn', () => {
14+
console.log('exposedFn call')
15+
})
16+
17+
// sourceUrlLeak
18+
await page.evaluate(() => document.getElementById('detections-json'))
19+
20+
/*
21+
playwright - there is no way to explicitly evaluate script in an isolated context
22+
follow rebrowser-patches on github for the fix
23+
*/
24+
await page.evaluate(() => document.getElementsByClassName('div'))
25+
26+
await wait(3000)
27+
const { isBot, botStatus } = await evaluate(page, () => {
28+
const els = Array.from(
29+
document.querySelectorAll('tbody>tr>td:nth-child(1)'),
30+
) as HTMLElement[]
31+
32+
let botStatus = [] as string[],
33+
isBot = false
34+
for (const el of els) {
35+
if (el.innerText.startsWith('🔴')) {
36+
botStatus.push(el.innerText)
37+
isBot = true
38+
}
39+
}
40+
return { isBot, botStatus }
41+
})
42+
43+
if (!isBot) {
44+
console.error('🔴 botStatus', botStatus)
45+
}
46+
await expect(isBot).toBe(false)
47+
})

e2e/docPIP.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { onPageAndExtensionLoaded, wait } from './utils'
44
const testUrls = [
55
'https://www.bilibili.com/video/BV17E411k7kv/?vd_source=8e6ad3d5f5612b1d591931b1eff4dea7',
66
'https://live.douyin.com/870887192950',
7-
'https://www.youtube.com/watch?v=SXC2wO1XdMI&ab_channel=Picon%2F%E3%83%94%E3%82%B3%E3%83%B3OFFICIALCHANNEL',
7+
// 'https://www.youtube.com/watch?v=SXC2wO1XdMI&ab_channel=Picon%2F%E3%83%94%E3%82%B3%E3%83%B3OFFICIALCHANNEL',
88
]
99
const testUrl = testUrls[0]
1010

e2e/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ type EvaluateType<T> = T extends {
4141
// : never
4242
export async function evaluate<
4343
T extends {
44-
evaluate: (...args: any) => any
44+
evaluate: (...args: any) => Promise<Result>
4545
},
4646
Arg extends any[],
4747
Arg0 = Parameters<Parameters<T['evaluate']>[0]>[0],
48+
Result = ReturnType<Parameters<T['evaluate']>[0]>,
4849
// Fn = EvaluateType<T>,
49-
>(tar: T, fn: (arg0: Arg0, args: Arg) => any, args?: readonly [...Arg]) {
50+
>(tar: T, fn: (arg0: Arg0, args: Arg) => Result, args?: readonly [...Arg]) {
5051
return tar.evaluate(
5152
(arg0: any, args: any) => {
5253
const isArray = (val: any): val is Array<any> => val instanceof Array

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"sizetest": "pnpm build && pnpm archive --size-test",
2929
"translate": "tsx ./scripts/auto-translate.ts",
3030
"eslint": "npx eslint",
31+
"test": "playwright test",
3132
"update-deps": "pnpm update --depth Infinity",
3233
"auto-use-node": "sh ./scripts/nvm-auto-use.sh"
3334
},
@@ -36,7 +37,7 @@
3637
"@babel/plugin-proposal-decorators": "^7.28.0",
3738
"@babel/plugin-transform-react-jsx": "^7.27.1",
3839
"@chialab/esbuild-plugin-meta-url": "^0.18.2",
39-
"@playwright/test": "^1.57.0",
40+
"@playwright/test": "1.52.0",
4041
"@preact/preset-vite": "^2.10.2",
4142
"@types/chrome": "0.1.27",
4243
"@types/color": "^4.2.0",

0 commit comments

Comments
 (0)