James Baxter
James Baxter

Reputation: 139

How to debug a page_action chrome extension

I am trying to create a page action chrome extension. It installs fine and I get the icon working when it's a browser action, however not with page action. So how do I debug it when I cannot right-click "inspect popup".

Added the following to the manifest and removed browser action:

"page_action": {
  "default_icon":  "icons/icon19.png", // optional
  "default_title": "Switch",     // optional; shown in tooltip
  "default_popup": "src/popup.html"    // optional
},

Thanks

Upvotes: 4

Views: 488

Answers (1)

Xan
Xan

Reputation: 77531

The difference between a page action and a browser action:

Browser action is always displayed, while a page action is only displayed on some pages where it makes sense.

Therefore, after declaring your page action in the manifest, you have to actually show it in a given tab with chrome.pageAction.show(tabId) (from the background script).

// Most primitive way to show the page action - on every tab update
chrome.tabs.onUpdated.addListener( function(tabId) {
  chrome.pageAction.show(tabId);
});

If the icon is shown, you can debug its popup as normally - Inspect Popup will be available.

Upvotes: 4

Related Questions