From 602f1aa2cd5439c7c0a90cd7a09c1580a9e5a187 Mon Sep 17 00:00:00 2001 From: yan Date: Wed, 12 Sep 2018 16:35:25 -0700 Subject: [PATCH] Fix about:blank appearing on new tab in new windows fix https://github.com/brave/browser-laptop/issues/15162 openableByContextMenu returned false if URL is empty for paranoia reasons, but it turns out this breaks some edge cases. See https://github.com/brave/browser-laptop/pull/15061 for instance. Test Plan: 1. unit tests pass 2. on MacOS, close all windows 3. click 'open in new tab' 4. new window should appear and show the new tab page 5. repeat step 3 and 4 with private tab, tor tab, session tab --- js/lib/urlutil.js | 2 +- test/unit/lib/urlutilTestComponents.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 9518f85b494..7e101677dcd 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -437,7 +437,7 @@ const UrlUtil = { */ openableByContextMenu: function (url) { if (!url) { - return false + return true } const protocol = urlParse(url).protocol // file: is untrusted but handled in a separate check diff --git a/test/unit/lib/urlutilTestComponents.js b/test/unit/lib/urlutilTestComponents.js index 04bc695d94f..5486276c2d1 100644 --- a/test/unit/lib/urlutilTestComponents.js +++ b/test/unit/lib/urlutilTestComponents.js @@ -359,6 +359,9 @@ module.exports = { }, 'is about:blank': (test) => { test.equal(urlUtil().openableByContextMenu('about:blank'), true) + }, + 'is empty': (test) => { + test.equal(urlUtil().openableByContextMenu(), true) } }, 'returns false when input:': { @@ -367,9 +370,6 @@ module.exports = { }, 'is ssh:': (test) => { test.equal(urlUtil().openableByContextMenu('ssh://test@127.0.0.1'), false) - }, - 'is null': (test) => { - test.equal(urlUtil().openableByContextMenu(null), false) } } },