browser.runtime.onMessage.addListener in Popup broke communication between content and background scripts

Fixed Issue #8473140


Ilia L.
Aug 12, 2016
This issue is public.
Found in
  • Microsoft Edge
Found in build #
Fixed in build #
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

I’m developing edge browser extension. I have popup, persistent background page and content script. I want to send messages from content script to background. I also want to send messages between background and popup (for example to update UI when server load complete etc.) Communication is made with


Looks like adding onMessage listener in Popup broke communication between content and background scripts.

This is the example code to reproduce the problem:


    "name": "TEST",
    "short_name": "TEST",
    "author": "TEST",
    "version": "0.1",
    "manifest_version": 2,
    "background": {
        "page": "background.html",
        "persistent": true
    "permissions": [
    "content_scripts": [
          "all_frames": true,
          "run_at": "document_start",
          "js": [
          "matches": [
    "browser_action": {
        "default_title": "RUN TEST",
        "default_popup": "popup.html"


    <script type="text/javascript" src="js/popup.js"></script>
<body style="min-width: 300px; min-height: 415px;">


console.log("POPUP: start");

window.addEventListener("unload", OnUnload, false);
window.addEventListener("load", OnLoad, false);

function OnLoad() {
    console.log("POPUP: OnLoad");

function OnUnload() {
    console.log("POPUP: Unload");
    window.removeEventListener("unload", OnUnload);
    window.removeEventListener("load", OnLoad);

function OnMessage(request, sender, sendResponse) {
    console.log("POPUP: OnMessage " +;

    if ( === "hi") {
        sendResponse({"message": "Hello from Popup"});


console.log("BG: start");

window.addEventListener("load", OnLoad, true);

function OnLoad() {
    console.log("BG: OnLoad");

function BGOnMessage(request, sender, sendResponse) {
    console.log("BG: BGOnMessage " +;

    if ( === "hi") {
        sendResponse({"message": "Hello from BG"});


console.log("CS: start");

browser.runtime.sendMessage({"name": "hi"}, function (response) {
//chrome.runtime.sendMessage({"name": "hi"}, function (response) {
    if (!response) {
        console.log("Empty response!!!");
    console.log("CS: response message = " + response.message);

It seems to work in Chrome, but in Edge I always receive “Empty response!!!” after opening popup once. If i comment


in popup code all works fine, but adding this listener once broke messages receiving in background. Looks like a bug in extension platform.


1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Brad E.”

    Changed Assigned To to “Sermet I.”

    Changed Assigned To to “Sebastian P.”

    Changed Assigned To to “Akshay P.”

    Changed Assigned To from “Akshay P.” to “Anushree B.”

    Changed Status to “Confirmed”

    Changed Assigned To from “Anushree B.” to “Arif S.”

  • Thanks for filing this bug! We’ve confirmed the issue and plan on addressing it in a future update. In the meantime, you can use the following workaround to avoid this behavior:

    Replace the call to sendResponse() in the background script with a call to browser.tabs.sendMessage() and pass in as the tabId parameter
    In the content script, add a listener to the browser.onMessage event with a callback that performs the same actions that the sendResponse() method does. If you have multiple messages that could fire this callback, you will need to uniquely identify them by adding a new property in the message object being sent back in the previous step.
    Remove the passing of the sendResponse() method in the sendMessage() call in the content script.

    Feel free to let me know if you have any questions! Thanks again!

  • Microsoft Edge Team

    Changed Status from “Confirmed” to “In code review”

    Changed Status from “In code review” to “In progress”

    Changed Status from “In progress” to “Fixed”

    Changed Assigned To to “Akshay P.”

  • Running version:
    Microsoft Edge 39.14986.1000.0
    Microsoft EdgeHTML 15.4986

    And it’s still happening. Has the patch been released?

  • Microsoft Edge Team

    Changed Assigned To from “Akshay P.” to “Snehita P.”

  • Hello,

    Thank you for providing this information about the issue. We are pleased to report this feature is fixed in Edge 15063 and is available in our latest Insider Preview build.

    Best Wishes,
    The MS Edge Team

You need to sign in to your Microsoft account to add a comment.

Sign in