0

I am writing a chrome extension - my code below :

content scripts

chrome.runtime.sendMessage('someId', proportion, function () {
    console.log('called!');
});

background script

chrome.runtime.onMessage.addListener(function (proportion, sender, callBack) {

    chrome.tabs.setZoom(sender.tab.id, proportion, function () {
        callBack();
    });
});

The callBack should be called after setZoom is done, but it didn't.

If I change background script code like this:

chrome.runtime.onMessage.addListener(function (proportion, sender, callBack) {

    chrome.tabs.setZoom(sender.tab.id, proportion, function () {
    });
    callBack();
});

The callBack has been called, and console output called!.

amdixon
  • 3,814
  • 8
  • 25
  • 34
LiBook
  • 11
  • 2

0 Answers0