reject-importGlobalProperties

Rejects calls to Cu.importGlobalProperties or XPCOMUtils.defineLazyGlobalGetters.

In system modules all the required properties should already be available. In non-module code or non-system modules, webidl defined interfaces should already be available and hence do not need importing.

For sjs test files, if the relevant global is not already available, then consider extending the list of globals available from the httpd server.

Options

  • “everything”: Disallows using the import/getters completely.

  • “allownonwebidl”: Disallows using the import functions for webidl symbols. Allows other symbols.

everything

Incorrect code for this option:

Cu.importGlobalProperties(['TextEncoder']);
XPCOMUtils.defineLazyGlobalGetters(this, ['TextEncoder']);

allownonwebidl

Incorrect code for this option:

// AnimationEffect is a webidl property.
Cu.importGlobalProperties(['AnimationEffect']);
XPCOMUtils.defineLazyGlobalGetters(this, ['AnimationEffect']);

Correct code for this option:

// TextEncoder is not defined by webidl.
Cu.importGlobalProperties(['TextEncoder']);
XPCOMUtils.defineLazyGlobalGetters(this, ['TextEncoder']);