JesseTG
JesseTG

Reputation: 2123

Logging a DOM object in a Firefox WebExtension content script prints "<unavailable>"

I'm building a browser extension with the WebExtension API in FireFox. I'm in the middle of writing a content script, and when I pass any DOM object into console.log, it is not printed out. Instead, I just get the string <unavailable>. Observe:

$ console.log(document);
<unavailable>

However, I can still access the object's properties.

$ console.log(document.baseURI);
https://the_base_uri.com

Why does this happen, and what does it mean?

Upvotes: 2

Views: 460

Answers (1)

Andrew Swan
Andrew Swan

Reputation: 1343

That means that the debugger you're using (presumably the add-on debugger in this case) is attached to a different process than the process where the log message was generated (which would be a web content process in this case). The MDN page about debugging discusses this in greater detail: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging

Upvotes: 4

Related Questions