Skip to content

Commit

Permalink
fix: collect header order for all browsers (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin authored Apr 6, 2023
1 parent 62a1257 commit fa8a62a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 84 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/model-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,37 @@ jobs:
with:
node-version: 16

- name: Cache Node Modules
- name: Cache node modules + browsers
uses: actions/cache@v3
with:
path: |
node_modules
key: cache-${{ github.run_id }}
path: |
~/.npm
~/.cache/ms-playwright
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install Dependencies
run: npm ci

- name: Install Playwright browsers and collect HTTP header orders
- name: Install Playwright deps
run: npx playwright install

- name: Install xvfb
run: |
sudo apt-get update
sudo apt-get -y install xvfb
- name: Install Playwright browsers
run: |
npx playwright install
npx playwright install webkit
npx playwright install chrome
npx playwright install msedge
xvfb-run --auto-servernum -- node ./packages/header-order-collector/collector.js > ./packages/header-generator/src/data_files/headers_order.json
- name: Install Playwright deps v2
run: npx playwright install-deps

- name: Collect HTTP header orders
run: |
xvfb-run -- node ./packages/header-order-collector/collector.js | tee ./packages/header-generator/src/data_files/headers-order.json
- name: Generate model and update versions
run: |
Expand Down
69 changes: 0 additions & 69 deletions packages/header-generator/src/data_files/headers_order.json

This file was deleted.

22 changes: 14 additions & 8 deletions packages/header-order-collector/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,30 @@ async function getHeadersFor(launcher, httpVersion) {
} else {
await page.goto(`https://localhost:${HTTP2port}/`);
}
await page.click('a');

const headerNames = await page.evaluate(() => {
return JSON.parse(document.body.innerText);
});
await browser.close();
return headerNames;
try {
await page.click('a', { timeout: 1000 });

const headerNames = await page.evaluate(() => {
return JSON.parse(document.body.innerText);
});
await browser.close();
return headerNames;
} catch (e) {
// Webkit on Linux does not support http2
return [];
}
}

(async () => {
v1(HTTP1port);
v2(HTTP2port);

const browserTypes = {
safari: () => playwright.webkit.launch(),
safari: (p) => playwright.webkit.launch(p),
chrome: (p) => playwright.chromium.launch(p),
firefox: (p) => playwright.firefox.launch(p),
edge: () => playwright.chromium.launch({ channel: 'msedge' }),
edge: (p) => playwright.chromium.launch({...p, channel: 'msedge' }),
};

try {
Expand Down

0 comments on commit fa8a62a

Please sign in to comment.