-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ses): add a smoke test for SES lockdown in chrome canary
- Loading branch information
Showing
5 changed files
with
690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Lockdown Canary | ||
## detects lockdown issues on latest chrome | ||
|
||
on: | ||
push: | ||
branches: | ||
- lockdown-canary | ||
schedule: | ||
- cron: '0 0 * * *' # Runs every day at midnight | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js stable | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Setup Chrome | ||
uses: browser-actions/setup-chrome@latest | ||
with: | ||
chrome-version: 'canary' | ||
|
||
- name: install dependencies | ||
run: | | ||
cd ./packages/ses/smoke-test/ | ||
yarn install | ||
- name: Run tests | ||
run: | | ||
CHROME_BIN=$(which google-chrome-unstable) node ./packages/ses/smoke-test/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script src="../../dist/lockdown.umd.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable @endo/no-polymorphic-call */ | ||
import puppeteer from 'puppeteer-core'; | ||
import assert from 'assert'; | ||
|
||
const chromePath = process.env.CHROME_BIN; | ||
let browser; | ||
|
||
async function runTests() { | ||
// Launch the browser | ||
browser = await puppeteer.launch({ | ||
executablePath: chromePath, | ||
}); | ||
|
||
// Open a new page | ||
const page = await browser.newPage(); | ||
page.on('pageerror', async err => { | ||
console.error(`Page error: ${err.toString()}`); | ||
}); | ||
|
||
const pathToIndex = new URL('./fixture/index.html', import.meta.url).href; | ||
|
||
await page.goto(pathToIndex); | ||
|
||
assert.equal( | ||
await page.evaluate(`typeof lockdown;`), | ||
'function', | ||
'lockdown is not a function', | ||
); | ||
const result = await page.evaluate(` | ||
try { | ||
lockdown(); | ||
'success'; | ||
} | ||
catch (e) { | ||
e; | ||
} | ||
`); | ||
assert.equal(result, 'success', 'lockdown failed'); | ||
|
||
await browser.close(); | ||
} | ||
|
||
runTests().catch(error => { | ||
console.error(error); | ||
browser.close(); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "ses-smoke-test", | ||
"version": "1.0.1", | ||
"description": "Browser smoke test for SES lockdown", | ||
"license": "Apache-2.0", | ||
"type": "module", | ||
"dependencies": { | ||
"puppeteer-core": "^21.7.0" | ||
}, | ||
"private": true | ||
} |
Oops, something went wrong.