user984003
user984003

Reputation: 29597

Chrome extension: debug content script before packaging

I am developing a Chrome extension. It sets/reads local storage, reads the DOM, and sends an Ajax message. But sometimes it never reaches the server and I don't know where it gets stuck. Reloading the page doesn't work, although the extension works if I load another page in the same tab, and the original page will work if I load it in another tab. I use activeTab permission.

How can I debug this? The Chrome tutorial http://developer.chrome.com/extensions/tut_debugging.html only mentions a popup, which I do not have. (I right-click the icon and "Inspect popup" is not visible.)

I have tried plain old F12/sources, but I don't see my extension there, even when it works.

I am on localhost and the extension is not packaged. I am still working in developer mode.

Upvotes: 0

Views: 2576

Answers (1)

user984003
user984003

Reputation: 29597

The extension does not show up in developer tools>Sources>Content scripts, maybe because it isn't packaged. I can see the content script from another regular extension.

To see mine I:

Wrote the following as the first line in my script:

debugger;

Before pressing the extension icon, I bring up the developer tools: F12

Now, when I click the extension icon, my script opens under sources/program. It does not do this if the developer tools is not open.

Upvotes: 2

Related Questions