From d8e0557d1859b7de7bcc7129db9f4f63d6c94506 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Thu, 21 May 2020 15:36:59 +0100 Subject: [PATCH] chore: update Travis to run latest macOS and fix HTTPS test (#5903) * chore: fix invalid SSL assertion on Catalina The error Chrome gives with an invalid cert changes between older Mac versions and Catalina as detailed here: https://support.google.com/chrome/thread/18125056?hl=en. This PR changes Travis to run Catalina (and we think most devs run up to date OS versions) so this fix ensures the test behaviour is consistent locally and on Travis. For those on older Mac versions I've left a comment by the tests to hopefully save them debugging! Co-authored-by: Mathias Bynens --- .travis.yml | 1 + test/navigation.spec.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 736e293259a..bb54d7af9df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ jobs: - os: "osx" name: 'Unit tests: macOS/Chromium' node_js: "10.19.0" + osx_image: xcode11.4 env: - CHROMIUM=true before_install: diff --git a/test/navigation.spec.js b/test/navigation.spec.js index 2d45d322b5f..694f34a20a6 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -21,6 +21,7 @@ const { setupTestBrowserHooks, setupTestPageAndContextHooks, } = require('./mocha-utils'); +const os = require('os'); describe('navigation', function () { setupTestBrowserHooks(); @@ -146,6 +147,17 @@ describe('navigation', function () { expect(error.message).toContain('Cannot navigate to invalid URL'); else expect(error.message).toContain('Invalid url'); }); + + /* If you are running this on pre-Catalina versions of macOS this will fail locally. + /* Mac OSX Catalina outputs a different message than other platforms. + * See https://support.google.com/chrome/thread/18125056?hl=en for details. + * If you're running pre-Catalina Mac OSX this test will fail locally. + */ + const EXPECTED_SSL_CERT_MESSAGE = + os.platform() === 'darwin' + ? 'net::ERR_CERT_INVALID' + : 'net::ERR_CERT_AUTHORITY_INVALID'; + itFailsFirefox('should fail when navigating to bad SSL', async () => { const { page, httpsServer, isChrome } = getTestState(); @@ -158,8 +170,7 @@ describe('navigation', function () { await page .goto(httpsServer.EMPTY_PAGE) .catch((error_) => (error = error_)); - if (isChrome) - expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID'); + if (isChrome) expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE); else expect(error.message).toContain('SSL_ERROR_UNKNOWN'); }); itFailsFirefox( @@ -174,7 +185,7 @@ describe('navigation', function () { .goto(httpsServer.PREFIX + '/redirect/1.html') .catch((error_) => (error = error_)); if (isChrome) - expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID'); + expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE); else expect(error.message).toContain('SSL_ERROR_UNKNOWN'); } );