Component unavailable exception when re-executing window object properties

I am trying to convert a Google Chrome extension to Firefox using the Addon SDK (Jetpack). The following code (runs as a content script)

var property, winProperties = {}; for (property in window) { winProperties[property] = true; } 

throws this exception on startup in Firefox 5.0 and 6.0:

 Traceback (most recent call last): File "sfc-bgcore.js", line 299, in null File "resource://jid1-q4cqhvcl3sc4vq-at-jetpack-api-utils-lib/content/content-proxy.js", line 519, in null for each (name in Object.keys(obj)) { [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource://jid1-q4cqhvcl3sc4vq-at-jetpack-api-utils-lib/securable-module.js -> resource://jid1-q4cqhvcl3sc4vq-at-jetpack-api-utils-lib/content/content-proxy.js :: <TOP_LEVEL> :: line 519" data: no] 

Does anyone know how to catch this exception or how to avoid the "problem" property and continue the loop?

Note that I cannot just put the try-catch statement in the body of the loop, since even this causes an error:

 for (var property in window) {}; 

However, if I execute the same or similar expression in Firefox "Web Console", then it works fine:

 for (var property in window) { console.log(property); }; 
+4
source share
1 answer

I could not reproduce this with the extension of the test suite , installing it using the Test button, and then visiting http://example.org/ - some properties were printed on the console, after which the message "done" appeared, without errors.

Stock code:

 exports.main = function(options, callbacks) { var pageMod = require("page-mod"); pageMod.PageMod({ include: "*.org", contentScript: 'for (property in window) {console.log(property)}; console.log("done");' }); }; 
+1
source

All Articles