|
21 | 21 | await controls.goto(`chrome-extension://${id}/options.html`); |
22 | 22 | const message = (type, on) => controls.evaluate( |
23 | 23 | ({ type, on }) => chrome.runtime.sendMessage({ type, on }), { type, on }); |
| 24 | + // Certificate rejection can commit chrome-error:// after goto rejects. Keep |
| 25 | + // that late navigation out of the tab used for subsequent routing checks. |
| 26 | + const rejectUntrusted = async (url, { screenshotPath, timeout = 45000 } = {}) => { |
| 27 | + const invalid = await context.newPage(); |
| 28 | + try { |
| 29 | + await assert.rejects(invalid.goto(url, { |
| 30 | + waitUntil: 'domcontentloaded', timeout, |
| 31 | + }), /ERR_CERT_AUTHORITY_INVALID/); |
| 32 | + if (screenshotPath) { |
| 33 | + await invalid.waitForFunction(() => Boolean(document.body?.innerText.trim()), null, { timeout: 5000 }); |
| 34 | + await invalid.screenshot({ path: screenshotPath }); |
| 35 | + } |
| 36 | + } catch (error) { |
| 37 | + await invalid.screenshot({ path: path.join(evidence, `${phase}-invalid-tls-failure.png`) }).catch(() => {}); |
| 38 | + throw error; |
| 39 | + } finally { |
| 40 | + await invalid.close().catch(() => {}); |
| 41 | + } |
| 42 | + }; |
24 | 43 |
|
25 | 44 | const deadline = Date.now() + 5000; |
26 | 45 | let initial, initialProxy; |
|
51 | 70 | check('HTTP Moshpit name resolves through the browser'); |
52 | 71 |
|
53 | 72 | if (phase === 'before-trust' || phase === 'after-removal') { |
54 | | - await assert.rejects(page.goto('https://profullstack.agent/', { |
55 | | - waitUntil: 'domcontentloaded', timeout: 45000, |
56 | | - }), /ERR_CERT_AUTHORITY_INVALID/); |
57 | | - await page.screenshot({ path: path.join(evidence, `${phase}.png`) }); |
| 73 | + await rejectUntrusted('https://profullstack.agent/', { screenshotPath: path.join(evidence, `${phase}.png`) }); |
58 | 74 | check('registry HTTPS is rejected without root trust'); |
59 | 75 | } else { |
60 | 76 | const response = await page.goto('https://profullstack.agent/', { |
|
70 | 86 | check('registry HTTPS succeeds with normal browser certificate verification'); |
71 | 87 | } |
72 | 88 |
|
73 | | - await assert.rejects(page.goto(invalidTlsUrl, { |
74 | | - waitUntil: 'domcontentloaded', timeout: 15000, |
75 | | - }), /ERR_CERT_AUTHORITY_INVALID/); |
| 89 | + await rejectUntrusted(invalidTlsUrl, { timeout: 15000 }); |
76 | 90 | check('unrelated self-signed HTTPS remains rejected'); |
77 | 91 |
|
78 | 92 | assert.equal((await message('pit-set', false)).enabled, false); |
|
0 commit comments