我正在尝试在 mozila sdk builder 中使用第一个块代码。(网络 IDE)
https://developer.mozilla.org/en-US/docs/Code_snippets/Downloading_Files
这是 Mozilla SDK 构建器的代码
var {Cc, components , Cu} = require("chrome");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
const WebBrowserPersist = components.Constructor("@mozilla.org/embedding/browser/nsWebBrowserPersist;1",
"nsIWebBrowserPersist");
var persist = WebBrowserPersist();
var targetFile = Services.dirsvc.get("Desk", Ci.nsIFile);
targetFile.append("file.bin");
// Obtain the privacy context of the browser window that the URL
// we are downloading comes from. If, and only if, the URL is not
// related to a window, null should be used instead.
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
persist.saveURI('https://forums.mozilla.org/addons/styles/ca_gen2/imageset/logo.png', null, null, null, "", 'c:\\temp\\', null);
有了这个错误
An exception occurred.
undefined: Unexpected error in XPConnect undefined 6