extension sanity checks

This commit is contained in:
ivan grachev 2023-12-12 18:11:09 +03:00
parent 35f525ca0b
commit 710a7544ae
4 changed files with 9 additions and 5 deletions

View File

@ -107,6 +107,7 @@ window.addEventListener("message", event => {
browser.runtime.sendMessage(disconnectRequest);
}
}
return true;
});
function getFavicon() {

View File

@ -136,6 +136,7 @@ browser.action.onClicked.addListener(tab => {
if (tab.url == "" && tab.pendingUrl == "") {
justShowApp();
}
return true;
});
function genId() {
@ -260,7 +261,7 @@ function hasVisiblePopup() {
function storePopupRequest(popupRequest) {
getPopupsQueue().then(result => {
if (Array.isArray(result)) {
if (typeof result !== "undefined", Array.isArray(result)) {
result.push(popupRequest);
setPopupsQueue(result);
} else {
@ -272,7 +273,7 @@ function storePopupRequest(popupRequest) {
function getNextStoredPopup() {
return new Promise((resolve) => {
getPopupsQueue().then(result => {
if (Array.isArray(result) && result.length > 0) {
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0) {
resolve(result[0]);
} else {
resolve();
@ -299,7 +300,7 @@ function storeCurrentPopupId(id) {
function cleanupStoredPopup(id) {
getPopupsQueue().then(result => {
if (Array.isArray(result) && result.length > 0 && result[0].id == id) {
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0 && result[0].id == id) {
result.shift();
setPopupsQueue(result);
browser.storage.session.remove("currentPopupId");
@ -323,7 +324,7 @@ function setPopupsQueue(queue) {
function cleanupPopupsQueue() {
getPopupsQueue().then(result => {
if (Array.isArray(result) && result.length > 0) {
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0) {
for (var i = 0; i < result.length; i++) {
cancelPopupRequest(result[i]);
}

View File

@ -4,11 +4,12 @@ function didChangeVisibility() {
if (document.visibilityState === 'visible' && document.pendingRequestsIds.size != 0) {
document.pendingRequestsIds.forEach(id => {
const request = {id: id, subject: "getResponse", host: window.location.host};
browser.runtime.sendMessage(request).then((response) => {
browser.runtime.sendMessage(request).then(response => {
sendToInpage(response, id);
});
});
}
return true;
}
document.addEventListener('visibilitychange', didChangeVisibility);

View File

@ -24,6 +24,7 @@ button.addEventListener('click', () => {
});
browser.runtime.sendMessage({subject: 'POPUP_DID_PROCEED', id: message.id});
setTimeout(window.close, 437);
return true;
});
function setupButton() {