Closed Bug 825947 Opened 11 years ago Closed 10 years ago

components.Constructor doesn't work - NS_ERROR_XPC_UNEXPECTED

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: mkaply, Unassigned)

Details

The following code fails in jetpack:

const { Ci, Cc, components } = require("chrome");
const DOMParser = new components.Constructor("@mozilla.org/xmlextras/domparser;1", "nsIDOMParser");

with the error:

[Exception... "Unexpected error in XPConnect"  nsresult: "0x80570008 (NS_ERROR_XPC_UNEXPECTED)"  location: "JS frame ::
resource:///modules/XPIProvider.jsm -> jar:file:///c:/users/mikeka~1/appdata/local/temp/tmpvynin2.mozrunner/extensions/jid1-qzSVEz379745SA@jetpack.xpi!/bootstrap.js -> resource://jid1-qzsvez379745sa-at-jetpack/addon-sdk/lib/toolkit/loader.js -> resource://jid1-qzsvez379745sa-at-jetpack/my-addon/lib/main.js :: <TOP_LEVEL> :: line 2"  data: no]

The documentation for Components.Constructor (https://developer.mozilla.org/en-US/docs/Components.Constructor) has a function at the bottom that emulates Components.constructor.

If I use that instead of components.Constructor, it works.
It looks like there is a `CC` export from the chrome module which you can use to access components.Constructor.  See the httpd.js module for an example https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/test/httpd.js
(In reply to Erik Vold [:erikvold] [:ztatic] from comment #1)
> It looks like there is a `CC` export from the chrome module which you can
> use to access components.Constructor.  See the httpd.js module for an
> example
> https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/test/httpd.js

I suggested that too, but that one is already bound to Components, so you cant use it to call Components.Constructor as a constructor.
use `let { CC } = require("chrome")`
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.