From f0fb8061ce5ac4c23ea1a2cbf94c4aa1a3f33897 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Fri, 11 May 2018 13:56:43 -0400 Subject: Correct tab and badge initialization to prevent race conditions --- main_background.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'main_background.js') diff --git a/main_background.js b/main_background.js index de24a4a..ada6230 100644 --- a/main_background.js +++ b/main_background.js @@ -993,16 +993,7 @@ function get_script(response,url,tabid,wl,index=-1){ webex.browserAction.setBadgeBackgroundColor({ color: "red", tabId: tabid - }); - } else{ - webex.browserAction.setBadgeText({ - text: "✓", - tabId: tabid }); - webex.browserAction.setBadgeBackgroundColor({ - color: "green", - tabId: tabid - }); } if(verdict == true){ @@ -1276,7 +1267,6 @@ function read_document(a){ if(GA != false){ return GA; } - delete unused_data[a["tabId"]]; var str = ""; var filter = webex.webRequest.filterResponseData(a.requestId); var decoder = new TextDecoder("utf-8"); @@ -1285,6 +1275,15 @@ function read_document(a){ dbg_print("%c Error in getting document","color:red"); } filter.onstop = event => { + delete unused_data[a["tabId"]]; + webex.browserAction.setBadgeText({ + text: "✓", + tabId: a["tabId"] + }); + webex.browserAction.setBadgeBackgroundColor({ + color: "green", + tabId: a["tabId"] + }); var test = new ArrayBuffer(); var res = test_url_whitelisted(a.url); res.then(function(whitelisted){ -- cgit v1.2.3