Unable to get property 'onMessage' of undefined or null reference in Edge extension content script

Not reproducible Issue #9823671

Details

Author
Stefan M.
Created
Nov 16, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

I’m converting an Chrome extension which works well to Edge extension, and I need to have message listener in my content script.

Here is the code in my content script:

browser.runtime.onMessage.addListener(listener);

function listener(message) {
console.log(message);
}

However, each time script executes, I get this error, pointing to first line of my content script code:

Unable to get property ‘onMessage’ of undefined or null reference

I’ve tried changing browser.runtime into chrome.runtime, but nothing changes.

Here I’ve found that Edge supports runtime.onMessage with some minor incompatibilities:

https://developer.microsoft.com/en-us/microsoft-edge/platform/documentation/extensions/api-support/supported-apis/

Attachments

1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Brad E.”

    Changed Assigned To from “Brad E.” to “Akshay P.”

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

    Changed Status to “Confirmed”

    Changed Status from “Confirmed” to “Not reproducible”

  • Tried with the code (mentioned in repro steps) in content script and the scenario worked. Attached sample extension used for testing.

  • Microsoft Edge Team

    Changed Assigned To to “Arif S.”

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

Sign in