-
Notifications
You must be signed in to change notification settings - Fork 74
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 dev
- Loading branch information
Showing
5 changed files
with
709 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,44 @@ | ||
name: Lockdown Canary | ||
## detects lockdown issues on latest chrome | ||
|
||
on: | ||
push: | ||
branches: | ||
- lockdown-canary | ||
schedule: | ||
- cron: '0 0 * * *' # Runs every day at midnight | ||
|
||
jobs: | ||
chrome-dev: | ||
runs-on: ubuntu-latest | ||
# runs-on: macos-latest | ||
## chrome-canary is not supported on linux o_O | ||
## but canary on mac won't connect | ||
|
||
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@v1 | ||
id: setup-chrome | ||
with: | ||
chrome-version: 'dev' | ||
|
||
- name: build ses | ||
run: | | ||
cd ./packages/ses/ | ||
yarn | ||
- name: install dependencies | ||
run: | | ||
cd ./packages/ses/smoke-test/ | ||
yarn install | ||
- name: Run tests | ||
run: | | ||
${{ steps.setup-chrome.outputs.chrome-path }} --version | ||
node ./packages/ses/smoke-test/index.js ${{ steps.setup-chrome.outputs.chrome-path }} |
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,56 @@ | ||
/* eslint-disable @endo/no-polymorphic-call */ | ||
/* global process */ | ||
|
||
import puppeteer from 'puppeteer-core'; | ||
import assert from 'assert'; | ||
|
||
const chromePath = process.argv[2]; | ||
console.log(`chromePath ${chromePath}`); | ||
|
||
let browser; | ||
|
||
async function runTests() { | ||
// Launch the browser | ||
browser = await puppeteer.launch({ | ||
headless: 'new', | ||
executablePath: chromePath, | ||
protocolTimeout: 30000, | ||
}); | ||
|
||
// 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; | ||
console.log(`opening ${pathToIndex}`); | ||
|
||
await page.goto(pathToIndex, { waitUntil: 'domcontentloaded' }); | ||
// await page.goto(pathToIndex); | ||
// await page.goto(pathToIndex, { waitUntil: 'load' }); | ||
|
||
assert.equal( | ||
await page.evaluate(`typeof lockdown;`), | ||
'function', | ||
'lockdown is not a function. did you build and include SES?', | ||
); | ||
const result = await page.evaluate(` | ||
try { | ||
lockdown(); | ||
'success'; | ||
} | ||
catch (e) { | ||
e.toString(); | ||
} | ||
`); | ||
assert.equal(result, 'success', 'lockdown failed'); | ||
|
||
await browser.close(); | ||
} | ||
|
||
runTests().catch(error => { | ||
console.error(error); | ||
browser && 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.