Chrome plugin does not initialize properly

I am trying to write a chrome plugin that I defined with the following manifest:

{
  "name": "test",
  "version": "1.0",
  "background": { "scripts": ["background.js"] },
  "permissions": [
    "tabs", "http://*/*"
  ],
  "browser_action": {
    "name": "test",
    "icons": ["icon.png"]
  },
  "manifest_version": 2
}

my background.jsfile looks like this:

chrome.app.runtime.onLaunched.addListener(function() { 
    console.log('details', chrome.app.getDetails());
});

When it loads, I see this error on the console:

Uncaught TypeError: Cannot read property 'onLaunched' of undefined 

I can’t understand why I don’t see correctly initialized chrome.app.runtime.

How do I debug this?

Gene

UPDATE:

When I run the following code:

console.log("before connection");
chrome.extension.onConnect.addListener(function(port) {
    console.log("connected");
});

I see the first log output ( before connection), but not the second; Does this mean that it cannot connect to the browser?

+2
source share
1 answer

chrome.app - undefined because you do not define the extension as an application.

Chrome : browser_action, page_action, theme app.

.

, .

0

All Articles