Message Passing between Background and Popup [Chromium: 127.0.6533.119 – ]

  Kiến thức lập trình

I have a working message passing extension as follows:

//manifest.json

{
    "manifest_version": 3,
    "name": "B2P",
    "version": "1.0.0",
    "description": "Check B2P",
    "action": {
        "default_popup": "popup.html"
    },
    "background": {
        "service_worker" : "background.js"
    }
}

// popup.html

<html style="min-width:200px;">
<head>
</head>
  <body>
    Say Hi
  <script src="./popup.js"></script>
  </body>
</html>

// popup.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.msg === "B2P") {
            //  To do something
            console.log(request.data.subject);
            console.log(request.data.content);
            sendResponse({login:'initiated'});
        }
    }
)

// background.js

chrome.runtime.sendMessage({
    msg: "B2P", 
    data: {
        subject: "Background to popup",
        content: "Failed!"
    }
}, function(response) {console.log(response);});

Suddenly after an update to Chromium: 127.0.6533.119 onwards on ubuntu, this message passing has stopped working… And it flash error Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. in background.js.

Am I doing anything wrong?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

Message Passing between Background and Popup [Chromium: 127.0.6533.119 – ]

I have a working message passing extension as follows:

//manifest.json

{
    "manifest_version": 3,
    "name": "B2P",
    "version": "1.0.0",
    "description": "Check B2P",
    "action": {
        "default_popup": "popup.html"
    },
    "background": {
        "service_worker" : "background.js"
    }
}

// popup.html

<html style="min-width:200px;">
<head>
</head>
  <body>
    Say Hi
  <script src="./popup.js"></script>
  </body>
</html>

// popup.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.msg === "B2P") {
            //  To do something
            console.log(request.data.subject);
            console.log(request.data.content);
            sendResponse({login:'initiated'});
        }
    }
)

// background.js

chrome.runtime.sendMessage({
    msg: "B2P", 
    data: {
        subject: "Background to popup",
        content: "Failed!"
    }
}, function(response) {console.log(response);});

Suddenly after an update to Chromium: 127.0.6533.119 onwards on ubuntu, this message passing has stopped working… And it flash error Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. in background.js.

Am I doing anything wrong?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

Message Passing between Background and Popup [Chromium: 127.0.6533.119 – ]

I have a working message passing extension as follows:

//manifest.json

{
    "manifest_version": 3,
    "name": "B2P",
    "version": "1.0.0",
    "description": "Check B2P",
    "action": {
        "default_popup": "popup.html"
    },
    "background": {
        "service_worker" : "background.js"
    }
}

// popup.html

<html style="min-width:200px;">
<head>
</head>
  <body>
    Say Hi
  <script src="./popup.js"></script>
  </body>
</html>

// popup.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.msg === "B2P") {
            //  To do something
            console.log(request.data.subject);
            console.log(request.data.content);
            sendResponse({login:'initiated'});
        }
    }
)

// background.js

chrome.runtime.sendMessage({
    msg: "B2P", 
    data: {
        subject: "Background to popup",
        content: "Failed!"
    }
}, function(response) {console.log(response);});

Suddenly after an update to Chromium: 127.0.6533.119 onwards on ubuntu, this message passing has stopped working… And it flash error Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. in background.js.

Am I doing anything wrong?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

Message Passing between Background and Popup [Chromium: 127.0.6533.119 – ]

I have a working message passing extension as follows:

//manifest.json

{
    "manifest_version": 3,
    "name": "B2P",
    "version": "1.0.0",
    "description": "Check B2P",
    "action": {
        "default_popup": "popup.html"
    },
    "background": {
        "service_worker" : "background.js"
    }
}

// popup.html

<html style="min-width:200px;">
<head>
</head>
  <body>
    Say Hi
  <script src="./popup.js"></script>
  </body>
</html>

// popup.js

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.msg === "B2P") {
            //  To do something
            console.log(request.data.subject);
            console.log(request.data.content);
            sendResponse({login:'initiated'});
        }
    }
)

// background.js

chrome.runtime.sendMessage({
    msg: "B2P", 
    data: {
        subject: "Background to popup",
        content: "Failed!"
    }
}, function(response) {console.log(response);});

Suddenly after an update to Chromium: 127.0.6533.119 onwards on ubuntu, this message passing has stopped working… And it flash error Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. in background.js.

Am I doing anything wrong?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT