diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 35353070f0..15f34d71fd 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -235,7 +235,14 @@ module.exports = { }, fromId (id) { - const contents = binding.fromId(id) + if (!id) + return + + const parsed = parseInt(id) + if (isNaN(parsed)) + return + + const contents = binding.fromId(parsed) if (contents && !contents.isDestroyed()) { return contents } @@ -248,7 +255,12 @@ module.exports = { fromTabID (tabID) { if (!tabID) return - const contents = binding.fromTabID(tabID) + + const parsed = parseInt(tabID) + if (isNaN(parsed)) + return + + const contents = binding.fromTabID(parsed) if (contents && !contents.isDestroyed()) { return contents }