diff --git a/lib/browser/api/extensions.js b/lib/browser/api/extensions.js index abc11a82a..759f4fc5e 100644 --- a/lib/browser/api/extensions.js +++ b/lib/browser/api/extensions.js @@ -2,6 +2,7 @@ const {app, BrowserWindow, ipcMain, webContents, session} = require('electron') const path = require('path') const browserActions = require('./browser-actions') const assert = require('assert') +const deepEqual = require('../../common/deep-equal') // List of currently active background pages by extensionId var backgroundPages = {} @@ -288,7 +289,7 @@ const chromeTabsUpdated = function (tabId) { let changeInfo = {} for (var key in tabValue) { - if (tabValue[key] !== oldTabInfo[key]) { + if (!deepEqual(tabValue[key], oldTabInfo[key])) { changeInfo[key] = tabValue[key] } } diff --git a/lib/common/deep-equal.js b/lib/common/deep-equal.js new file mode 100644 index 000000000..551d04dde --- /dev/null +++ b/lib/common/deep-equal.js @@ -0,0 +1,27 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const deepEqual = (x, y) => { + if (typeof x !== typeof y) { + return false + } + if (typeof x !== 'object') { + return x === y + } + const xKeys = Object.keys(x) + const yKeys = Object.keys(y) + if (xKeys.length !== yKeys.length) { + return false + } + for (let prop in x) { + if (x.hasOwnProperty(prop)) { + if (!deepEqual(x[prop], y[prop])) { + return false + } + } + } + return true +} + +module.exports = deepEqual