Firefox’s Assert.jsm

1

According to the MDN docs, Firefox appears to have an Assert.jsm module. Those docs say that you can use Components.utils.import("resource://testing-common/Assert.jsm"); in your extension to use it. However, when I try that I get the following error:

Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) 
[nsIXPCComponents_Utils.import]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"

The docs also says that this module requires Gecko 28. I tried it with Abrowser 33 (which is basically Firefox 33), so that shouldn’t be the problem.

I have succesfully imported other modules:

Components.utils.import('resource://gre/modules/Services.jsm')
Components.utils.import('resource://gre/modules/devtools/Console.jsm')

It might be worth noting that I tried this in a bootrapped extension, that doesn’t use the SDK. I’ve tried a bootstrap.js file with only the Components.utils.import(...) line in it, and the error is still thrown.

If I enter resource://gre/modules/Services.jsm (one of the modules that I managed to import) in the location bar, the source code of that module is shown. If I enter resource://testing-common/Assert.jsm, though, nothing at all happens!

What’s going on here?

(Edit: Since this question was written, the MDN docs linked to have been updated.)

firefox
firefox-addon
asked on Stack Overflow Dec 8, 2014 by lydell • edited Dec 9, 2014 by lydell

1 Answer

2

The primary issue is that the URL resource://testing-common/Assert.jsm does not exist.

In Firefox 33.0 the correct URL for this module is: resource://specialpowers/Assert.jsm

While the Assert.jsm page on MDN claimed that it is available on Firefox 28, I did not find it in the Firefox release until 31.0. As of Firefox 31.0 it was at the resource://specialpowers/Assert.jsm URL.

answered on Stack Overflow Dec 8, 2014 by Makyen

User contributions licensed under CC BY-SA 3.0