Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit 6a3e128

Browse files
bbondybridiver
authored andcommitted
Tab update events should only fire when data has changed
Fix brave/browser-laptop#9313
1 parent 85e25fa commit 6a3e128

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/browser/api/extensions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const {app, BrowserWindow, ipcMain, webContents, session} = require('electron')
22
const path = require('path')
33
const browserActions = require('./browser-actions')
44
const assert = require('assert')
5+
const deepEqual = require('../../common/deep-equal')
56

67
// List of currently active background pages by extensionId
78
var backgroundPages = {}
@@ -288,7 +289,7 @@ const chromeTabsUpdated = function (tabId) {
288289
let changeInfo = {}
289290

290291
for (var key in tabValue) {
291-
if (tabValue[key] !== oldTabInfo[key]) {
292+
if (!deepEqual(tabValue[key], oldTabInfo[key])) {
292293
changeInfo[key] = tabValue[key]
293294
}
294295
}

lib/common/deep-equal.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
const deepEqual = (x, y) => {
6+
if (typeof x !== typeof y) {
7+
return false
8+
}
9+
if (typeof x !== 'object') {
10+
return x === y
11+
}
12+
const xKeys = Object.keys(x)
13+
const yKeys = Object.keys(y)
14+
if (xKeys.length !== yKeys.length) {
15+
return false
16+
}
17+
for (let prop in x) {
18+
if (x.hasOwnProperty(prop)) {
19+
if (!deepEqual(x[prop], y[prop])) {
20+
return false
21+
}
22+
}
23+
}
24+
return true
25+
}
26+
27+
module.exports = deepEqual

0 commit comments

Comments
 (0)