reject-importGlobalProperties.rst (1466B)
1 reject-importGlobalProperties 2 ============================= 3 4 Rejects calls to ``Cu.importGlobalProperties`` or 5 ``XPCOMUtils.defineLazyGlobalGetters``. 6 7 In system modules all the required properties should already be available. In 8 non-module code or non-system modules, webidl defined interfaces should already 9 be available and hence do not need importing. 10 11 For sjs test files, if the relevant global is not already available, then consider 12 extending the `list of globals available from the httpd server <https://searchfox.org/mozilla-central/rev/e9b338c2d597067f99e96d5f20769f41f312fa8f/netwerk/test/httpserver/httpd.sys.mjs#2875-2889>`_. 13 14 Options 15 ------- 16 17 * "everything": Disallows using the import/getters completely. 18 * "allownonwebidl": Disallows using the import functions for webidl symbols. Allows 19 other symbols. 20 21 everything 22 ---------- 23 24 Incorrect code for this option: 25 26 .. code-block:: js 27 28 Cu.importGlobalProperties(['TextEncoder']); 29 XPCOMUtils.defineLazyGlobalGetters(this, ['TextEncoder']); 30 31 allownonwebidl 32 -------------- 33 34 Incorrect code for this option: 35 36 .. code-block:: js 37 38 // AnimationEffect is a webidl property. 39 Cu.importGlobalProperties(['AnimationEffect']); 40 XPCOMUtils.defineLazyGlobalGetters(this, ['AnimationEffect']); 41 42 Correct code for this option: 43 44 .. code-block:: js 45 46 // TextEncoder is not defined by webidl. 47 Cu.importGlobalProperties(['TextEncoder']); 48 XPCOMUtils.defineLazyGlobalGetters(this, ['TextEncoder']);