chrome bug: onCommitted is fired twice
This commit is contained in:
parent
c41a5f92c3
commit
24a0077783
|
@ -1,4 +1,4 @@
|
||||||
/* global CHROME FIREFOX URLS ignoreChromeError */// toolbox.js
|
/* global CHROME FIREFOX URLS deepEqual ignoreChromeError */// toolbox.js
|
||||||
/* global bgReady */// common.js
|
/* global bgReady */// common.js
|
||||||
/* global msg */
|
/* global msg */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -6,6 +6,7 @@
|
||||||
/* exported navMan */
|
/* exported navMan */
|
||||||
const navMan = (() => {
|
const navMan = (() => {
|
||||||
const listeners = new Set();
|
const listeners = new Set();
|
||||||
|
let prevData = {};
|
||||||
|
|
||||||
chrome.webNavigation.onCommitted.addListener(onNavigation.bind('committed'));
|
chrome.webNavigation.onCommitted.addListener(onNavigation.bind('committed'));
|
||||||
chrome.webNavigation.onHistoryStateUpdated.addListener(onFakeNavigation.bind('history'));
|
chrome.webNavigation.onHistoryStateUpdated.addListener(onFakeNavigation.bind('history'));
|
||||||
|
@ -20,6 +21,10 @@ const navMan = (() => {
|
||||||
|
|
||||||
/** @this {string} type */
|
/** @this {string} type */
|
||||||
async function onNavigation(data) {
|
async function onNavigation(data) {
|
||||||
|
if (CHROME && data.timeStamp === prevData.timeStamp && deepEqual(data, prevData)) {
|
||||||
|
return; // Chrome bug: listener is called twice with identical data
|
||||||
|
}
|
||||||
|
prevData = data;
|
||||||
if (CHROME &&
|
if (CHROME &&
|
||||||
URLS.chromeProtectsNTP &&
|
URLS.chromeProtectsNTP &&
|
||||||
data.url.startsWith('https://www.google.') &&
|
data.url.startsWith('https://www.google.') &&
|
||||||
|
|
Loading…
Reference in New Issue
Block a user