Skip to content

Commit

Permalink
core(driver): only fail security state if scheme is not cryptographic (
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce authored and connorjclark committed Apr 30, 2019
1 parent 62d8a7b commit 7d04ed7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lighthouse-core/gather/driver.js
Expand Up @@ -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')
Expand Down
26 changes: 26 additions & 0 deletions lighthouse-core/test/gather/driver-test.js
Expand Up @@ -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: [
Expand All @@ -717,6 +742,7 @@ describe('.gotoURL', () => {
},
],
securityState: 'insecure',
schemeIsCryptographic: true,
};

driver.on = driver.once = createMockOnceFn();
Expand Down

0 comments on commit 7d04ed7

Please sign in to comment.