mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 20:49:15 +08:00

* Prepare Electron >=14 upgrade * Replace spectron with playwright * Upgrade Electron to v15 * Fix unit test issue with @electron/remote * Use per day cache directory for E2E tests * Fix code style
34 lines
932 B
JavaScript
34 lines
932 B
JavaScript
const { expect, test } = require('@playwright/test')
|
|
const { launchElectron } = require('./helpers')
|
|
|
|
test.describe('Test XSS Vulnerabilities', async () => {
|
|
let app = null
|
|
let page = null
|
|
|
|
test.beforeAll(async () => {
|
|
const { app: electronApp, page: firstPage } = await launchElectron(['test/e2e/data/xss.md'])
|
|
app = electronApp
|
|
page = firstPage
|
|
|
|
// Wait to parse and render the document.
|
|
await new Promise((resolve) => setTimeout(resolve, 3000))
|
|
})
|
|
|
|
test.afterAll(async () => {
|
|
await app.close()
|
|
})
|
|
|
|
test('Load malicious document', async () => {
|
|
const { isVisible, isCrashed } = await app.evaluate(async process => {
|
|
const mainWindow = process.BrowserWindow.getAllWindows()[0]
|
|
return {
|
|
isVisible: mainWindow.isVisible(),
|
|
isCrashed: mainWindow.webContents.isCrashed()
|
|
}
|
|
})
|
|
|
|
expect(isVisible).toBeTruthy()
|
|
expect(isCrashed).toBeFalsy()
|
|
})
|
|
})
|