-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
Copy pathsecurity.test.js
34 lines (30 loc) · 1 KB
/
security.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import docsifyInit from '../helpers/docsify-init.js';
import { test, expect } from './fixtures/docsify-init-fixture.js';
test.describe('Security - Cross Site Scripting (XSS)', () => {
const sharedOptions = {
markdown: {
homepage: '# Hello World',
},
routes: {
'test.md': '# Test Page',
},
};
const slashStrings = ['//', '///'];
for (const slashString of slashStrings) {
const hash = `#${slashString}domain.com/file.md`;
test(`should not load remote content from hash (${hash})`, async ({
page,
}) => {
const mainElm = page.locator('#main');
await docsifyInit(sharedOptions);
await expect(mainElm).toContainText('Hello World');
await page.evaluate(() => (location.hash = '#/test'));
await expect(mainElm).toContainText('Test Page');
await page.evaluate(newHash => {
location.hash = newHash;
}, hash);
await expect(mainElm).toContainText('Hello World');
expect(page.url()).toMatch(/#\/$/);
});
}
});