From 7d04ed794eee608a2fa44342f8b2b7f37b1462f8 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 17 Apr 2019 14:02:59 -0500 Subject: [PATCH] core(driver): only fail security state if scheme is not cryptographic (#8338) --- lighthouse-core/gather/driver.js | 8 +++++-- lighthouse-core/test/gather/driver-test.js | 26 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/gather/driver.js b/lighthouse-core/gather/driver.js index d0d8176f7677..1c47ed7db2b9 100644 --- a/lighthouse-core/gather/driver.js +++ b/lighthouse-core/gather/driver.js @@ -912,8 +912,12 @@ class Driver { /** * @param {LH.Crdp.Security.SecurityStateChangedEvent} event */ - const securityStateChangedListener = ({securityState, explanations}) => { - if (securityState === 'insecure') { + const securityStateChangedListener = ({ + securityState, + explanations, + schemeIsCryptographic, + }) => { + if (securityState === 'insecure' && schemeIsCryptographic) { cancel(); const insecureDescriptions = explanations .filter(exp => exp.securityState === 'insecure') diff --git a/lighthouse-core/test/gather/driver-test.js b/lighthouse-core/test/gather/driver-test.js index 7d63f3afa2f2..e3afa14fa197 100644 --- a/lighthouse-core/test/gather/driver-test.js +++ b/lighthouse-core/test/gather/driver-test.js @@ -700,6 +700,31 @@ describe('.gotoURL', () => { await loadPromise; }); + it('does not reject when page is insecure but http', async () => { + const secureSecurityState = { + explanations: [], + securityState: 'insecure', + schemeIsCryptographic: false, + }; + + driver.on = driver.once = createMockOnceFn() + .mockEvent('Security.securityStateChanged', secureSecurityState); + + const startUrl = 'https://www.example.com'; + const loadOptions = { + waitForLoad: true, + passContext: { + settings: { + maxWaitForLoad: 1, + }, + }, + }; + + const loadPromise = driver.gotoURL(startUrl, loadOptions); + await flushAllTimersAndMicrotasks(); + await loadPromise; + }); + it('rejects when page is insecure', async () => { const insecureSecurityState = { explanations: [ @@ -717,6 +742,7 @@ describe('.gotoURL', () => { }, ], securityState: 'insecure', + schemeIsCryptographic: true, }; driver.on = driver.once = createMockOnceFn();