browser.runtime.sendMessage does not work unless F12 Developer Tools is open

Not reproducible Issue #10626899

Details

Author
Brian B.
Created
Jan 23, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Chrome
Found in build #
14.14393
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

Trying to bring another browser’s extension to edge and found some issues with runtime.sendMessage.

This extension uses the sendMessage to send javascript to the content script. For those reading this having similar problems. I had an issue with chrome.runtime.sendmessage, but browser.runtime.sendMessage works. Also I couldn’t send a message from the background script to the content script, but I could send a message from content script to background and have the background respond with the javascript.

The issue I have that I couldn’t find a work around is the message from the content script only works when the F12 Developer Tools is open. When I close it, none of the inserted javascript works.


background

browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    //after running events, check if lastError was set
    console.log("onCommitted(): content script sent message %o", request);
        sendResponse({'events':lupEvents, 'flags':lupFlags});
        if (browser.runtime.lastError) console.error(browser.runtime.lastError);
});

content script

browser.runtime.sendMessage({greeting: "ready for javascript"}, function(response) {
    console.log("content_script: Got message from extension %o", response);
    
    if(!response || !response.events) return; //malformed requests get ignored  
    if (typeof compileFilter !== "undefined") {
        //compile the events and echo the results back to the extension
        console.log("content_script: Going to compile events");
        compileFilter(response.events, response.flags)
        //sendResponse({response: compileFilter(request.events, request.flags)});
    } else {
        console.log("content_script: script.js isn't ready yet");
        data = response.events;
        flags = response.flags;
    }
});

Attachments

1 attachment

Comments and activity

  • I found out today that if I remove call console.log from my extension the sendMessage works without the F12 Developer tools open.

  • Microsoft Edge Team

    Changed Assigned To to “Akshay P.”

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

    Changed Status to “Confirmed”

    Changed Status from “Confirmed” to “Not reproducible”

  • Hello,
    We are unable to repro this with the extension provided. Please provide us with an extension which exhibits the described behavior.

    Best Regards,
    The MS Edge Team

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

Sign in