xpccomponents.idl 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. %{C++
  7. #include "jspubtd.h"
  8. %}
  9. interface xpcIJSWeakReference;
  10. interface nsIAddonInterposition;
  11. interface nsIClassInfo;
  12. interface nsIComponentManager;
  13. interface nsICycleCollectorListener;
  14. interface nsIJSCID;
  15. interface nsIJSIID;
  16. interface nsIPrincipal;
  17. interface nsIStackFrame;
  18. /**
  19. * interface of Components.interfacesByID
  20. * (interesting stuff only reflected into JavaScript)
  21. */
  22. [scriptable, uuid(f235ef76-9919-478b-aa0f-282d994ddf76)]
  23. interface nsIXPCComponents_InterfacesByID : nsISupports
  24. {
  25. };
  26. /**
  27. * interface of Components.interfaces
  28. * (interesting stuff only reflected into JavaScript)
  29. */
  30. [scriptable, uuid(b8c31bba-79db-4a1d-930d-4cdd68713f9e)]
  31. interface nsIXPCComponents_Interfaces : nsISupports
  32. {
  33. };
  34. /**
  35. * interface of Components.classes
  36. * (interesting stuff only reflected into JavaScript)
  37. */
  38. [scriptable, uuid(978ff520-d26c-11d2-9842-006008962422)]
  39. interface nsIXPCComponents_Classes : nsISupports
  40. {
  41. };
  42. /**
  43. * interface of Components.classesByID
  44. * (interesting stuff only reflected into JavaScript)
  45. */
  46. [scriptable, uuid(336a9590-4d19-11d3-9893-006008962422)]
  47. interface nsIXPCComponents_ClassesByID : nsISupports
  48. {
  49. };
  50. /**
  51. * interface of Components.results
  52. * (interesting stuff only reflected into JavaScript)
  53. */
  54. [scriptable, uuid(2fc229a0-5860-11d3-9899-006008962422)]
  55. interface nsIXPCComponents_Results : nsISupports
  56. {
  57. };
  58. /**
  59. * interface of Components.ID
  60. * (interesting stuff only reflected into JavaScript)
  61. */
  62. [scriptable, uuid(7994a6e0-e028-11d3-8f5d-0010a4e73d9a)]
  63. interface nsIXPCComponents_ID : nsISupports
  64. {
  65. };
  66. /**
  67. * interface of Components.Exception
  68. * (interesting stuff only reflected into JavaScript)
  69. */
  70. [scriptable, uuid(5bf039c0-e028-11d3-8f5d-0010a4e73d9a)]
  71. interface nsIXPCComponents_Exception : nsISupports
  72. {
  73. };
  74. /**
  75. * interface of Components.Constructor
  76. * (interesting stuff only reflected into JavaScript)
  77. */
  78. [scriptable, uuid(88655640-e028-11d3-8f5d-0010a4e73d9a)]
  79. interface nsIXPCComponents_Constructor : nsISupports
  80. {
  81. };
  82. /**
  83. * interface of object returned by Components.Constructor
  84. * (additional interesting stuff only reflected into JavaScript)
  85. */
  86. [scriptable, uuid(c814ca20-e0dc-11d3-8f5f-0010a4e73d9a)]
  87. interface nsIXPCConstructor : nsISupports
  88. {
  89. readonly attribute nsIJSCID classID;
  90. readonly attribute nsIJSIID interfaceID;
  91. readonly attribute string initializer;
  92. };
  93. /**
  94. * interface of object returned by Components.utils.Sandbox.
  95. */
  96. [scriptable, uuid(4f8ae0dc-d266-4a32-875b-6a9de71a8ce9)]
  97. interface nsIXPCComponents_utils_Sandbox : nsISupports
  98. {
  99. };
  100. /**
  101. * interface for callback to be passed to Cu.schedulePreciseGC
  102. */
  103. [scriptable, function, uuid(71000535-b0fd-44d1-8ce0-909760e3953c)]
  104. interface ScheduledGCCallback : nsISupports
  105. {
  106. void callback();
  107. };
  108. /**
  109. * interface of Components.utils
  110. */
  111. [scriptable, uuid(a6e66965-4b9a-4846-8985-985e71aaf549)]
  112. interface nsIXPCComponents_Utils : nsISupports
  113. {
  114. /* reportError is designed to be called from JavaScript only.
  115. *
  116. * It will report a JS Error object to the JS console, and return. It
  117. * is meant for use in exception handler blocks which want to "eat"
  118. * an exception, but still want to report it to the console.
  119. *
  120. * It must be called with one param, usually an object which was caught by
  121. * an exception handler. If it is not a JS error object, the parameter
  122. * is converted to a string and reported as a new error.
  123. */
  124. [implicit_jscontext] void reportError(in jsval error);
  125. readonly attribute nsIXPCComponents_utils_Sandbox Sandbox;
  126. /*
  127. * evalInSandbox is designed to be called from JavaScript only.
  128. *
  129. * evalInSandbox evaluates the provided source string in the given sandbox.
  130. * It returns the result of the evaluation to the caller.
  131. *
  132. * var s = new C.u.Sandbox("http://www.mozilla.org");
  133. * var res = C.u.evalInSandbox("var five = 5; 2 + five", s);
  134. * var outerFive = s.five;
  135. * s.seven = res;
  136. * var thirtyFive = C.u.evalInSandbox("five * seven", s);
  137. */
  138. [implicit_jscontext,optional_argc]
  139. jsval evalInSandbox(in AString source, in jsval sandbox,
  140. [optional] in jsval version,
  141. [optional] in AUTF8String filename,
  142. [optional] in long lineNo);
  143. /*
  144. * getSandboxAddonId is designed to be called from JavaScript only.
  145. *
  146. * getSandboxAddonId retrieves the add-on ID associated with
  147. * a sandbox object. It will return undefined if there
  148. * is no add-on ID attached to the sandbox.
  149. *
  150. * var s = C.u.Sandbox(..., { addonId: "123" });
  151. * var id = C.u.getSandboxAddonId(s);
  152. */
  153. [implicit_jscontext]
  154. jsval getSandboxAddonId(in jsval sandbox);
  155. /*
  156. * getSandboxMetadata is designed to be called from JavaScript only.
  157. *
  158. * getSandboxMetadata retrieves the metadata associated with
  159. * a sandbox object. It will return undefined if there
  160. * is no metadata attached to the sandbox.
  161. *
  162. * var s = C.u.Sandbox(..., { metadata: "metadata" });
  163. * var metadata = C.u.getSandboxMetadata(s);
  164. */
  165. [implicit_jscontext]
  166. jsval getSandboxMetadata(in jsval sandbox);
  167. /*
  168. * setSandboxMetadata is designed to be called from JavaScript only.
  169. *
  170. * setSandboxMetadata sets the metadata associated with
  171. * a sandbox object.
  172. *
  173. * Note that the metadata object will be copied before being used.
  174. * The copy will be performed using the structured clone algorithm.
  175. * Note that this algorithm does not support reflectors and
  176. * it will throw if it encounters them.
  177. */
  178. [implicit_jscontext]
  179. void setSandboxMetadata(in jsval sandbox, in jsval metadata);
  180. /*
  181. * import is designed to be called from JavaScript only.
  182. *
  183. * Synchronously loads and evaluates the js file located at
  184. * 'registryLocation' with a new, fully privileged global object.
  185. *
  186. * If 'targetObj' is specified and equal to null, returns the
  187. * module's global object. Otherwise (if 'targetObj' is not
  188. * specified, or 'targetObj' is != null) looks for a property
  189. * 'EXPORTED_SYMBOLS' on the new global object. 'EXPORTED_SYMBOLS'
  190. * is expected to be an array of strings identifying properties on
  191. * the global object. These properties will be installed as
  192. * properties on 'targetObj', or, if 'targetObj' is not specified,
  193. * on the caller's global object. If 'EXPORTED_SYMBOLS' is not
  194. * found, an error is thrown.
  195. *
  196. * @param resourceURI A resource:// URI string to load the module from.
  197. * @param targetObj the object to install the exported properties on.
  198. * If this parameter is a primitive value, this method throws
  199. * an exception.
  200. * @returns the module code's global object.
  201. *
  202. * The implementation maintains a hash of registryLocation->global obj.
  203. * Subsequent invocations of importModule with 'registryLocation'
  204. * pointing to the same file will not cause the module to be re-evaluated,
  205. * but the symbols in EXPORTED_SYMBOLS will be exported into the
  206. * specified target object and the global object returned as above.
  207. *
  208. * (This comment is duplicated from xpcIJSModuleLoader.)
  209. */
  210. [implicit_jscontext,optional_argc]
  211. jsval import(in AUTF8String aResourceURI, [optional] in jsval targetObj);
  212. /**
  213. * Returns true if the js file located at 'registryLocation' location has
  214. * been loaded previously via the import method above. Returns false
  215. * otherwise.
  216. *
  217. * @param resourceURI A resource:// URI string representing the location of
  218. * the js file to be checked if it is already loaded or not.
  219. * @returns boolean, true if the js file has been loaded via import. false
  220. * otherwise
  221. */
  222. boolean isModuleLoaded(in AUTF8String aResourceURI);
  223. /*
  224. * Unloads the JS module at 'registryLocation'. Existing references to the
  225. * module will continue to work but any subsequent import of the module will
  226. * reload it and give new reference. If the JS module hasn't yet been
  227. * imported then this method will do nothing.
  228. *
  229. * @param resourceURI A resource:// URI string to unload the module from.
  230. */
  231. void unload(in AUTF8String registryLocation);
  232. /*
  233. * Imports global properties (like DOM constructors) into the scope, defining
  234. * them on the caller's global. aPropertyList should be an array of property
  235. * names.
  236. *
  237. * See xpc::GlobalProperties::Parse for the current list of supported
  238. * properties.
  239. */
  240. [implicit_jscontext]
  241. void importGlobalProperties(in jsval aPropertyList);
  242. /*
  243. * To be called from JS only.
  244. *
  245. * Return a weak reference for the given JS object.
  246. */
  247. [implicit_jscontext]
  248. xpcIJSWeakReference getWeakReference(in jsval obj);
  249. /*
  250. * To be called from JS only.
  251. *
  252. * Force an immediate garbage collection cycle.
  253. */
  254. void forceGC();
  255. /*
  256. * To be called from JS only.
  257. *
  258. * Force an immediate cycle collection cycle.
  259. */
  260. void forceCC([optional] in nsICycleCollectorListener aListener);
  261. /*
  262. * To be called from JS only.
  263. *
  264. * If any incremental CC is in progress, finish it. For testing.
  265. */
  266. void finishCC();
  267. /*
  268. * To be called from JS only.
  269. *
  270. * Do some cycle collector work, with the given work budget.
  271. * The cost of calling Traverse() on a single object is set as 1.
  272. * For testing.
  273. */
  274. void ccSlice(in long long budget);
  275. /*
  276. * To be called from JS only.
  277. *
  278. * Return the longest cycle collector slice time since the last
  279. * time clearMaxCCTime() was called.
  280. */
  281. long getMaxCCSliceTimeSinceClear();
  282. /*
  283. * To be called from JS only.
  284. *
  285. * Reset the internal max slice time value used for
  286. * getMaxCCSliceTimeSinceClear().
  287. */
  288. void clearMaxCCTime();
  289. /*
  290. * To be called from JS only.
  291. *
  292. * Force an immediate shrinking garbage collection cycle.
  293. */
  294. void forceShrinkingGC();
  295. /*
  296. * Schedule a garbage collection cycle for a point in the future when no JS
  297. * is running. Call the provided function once this has occurred.
  298. */
  299. void schedulePreciseGC(in ScheduledGCCallback callback);
  300. /*
  301. * Schedule a shrinking garbage collection cycle for a point in the future
  302. * when no JS is running. Call the provided function once this has occured.
  303. */
  304. void schedulePreciseShrinkingGC(in ScheduledGCCallback callback);
  305. /*
  306. * In a debug build, unlink any ghost windows. This is only for debugging
  307. * leaks, and can cause bad things to happen if called.
  308. */
  309. void unlinkGhostWindows();
  310. [implicit_jscontext]
  311. jsval getJSTestingFunctions();
  312. /*
  313. * To be called from JS only.
  314. *
  315. * Call 'function', using the provided stack as the async stack responsible
  316. * for the call, and propagate its return value or the exception it throws.
  317. * The function is called with no arguments, and 'this' is 'undefined'.
  318. *
  319. * The code in the function will see the given stack frame as the
  320. * asyncCaller of its own stack frame, instead of the current caller.
  321. */
  322. [implicit_jscontext]
  323. jsval callFunctionWithAsyncStack(in jsval function, in nsIStackFrame stack,
  324. in AString asyncCause);
  325. /*
  326. * To be called from JS only.
  327. *
  328. * Returns the global object with which the given object is associated.
  329. *
  330. * @param obj The JavaScript object whose global is to be gotten.
  331. * @return the corresponding global.
  332. */
  333. [implicit_jscontext]
  334. jsval getGlobalForObject(in jsval obj);
  335. /*
  336. * To be called from JS only.
  337. *
  338. * Returns the true if the object is a (scripted) proxy.
  339. * NOTE: Security wrappers are unwrapped first before the check.
  340. */
  341. [implicit_jscontext]
  342. boolean isProxy(in jsval vobject);
  343. /*
  344. * To be called from JS only.
  345. *
  346. * Instead of simply wrapping a function into another compartment,
  347. * this helper function creates a native function in the target
  348. * compartment and forwards the call to the original function.
  349. * That call will be different than a regular JS function call in
  350. * that, the |this| is left unbound, and all the non-native JS
  351. * object arguments will be cloned using the structured clone
  352. * algorithm.
  353. * The return value is the new forwarder function, wrapped into
  354. * the caller's compartment.
  355. * The 3rd argument is an optional options object:
  356. * - defineAs: the name of the property that will
  357. * be set on the target scope, with
  358. * the forwarder function as the value.
  359. */
  360. [implicit_jscontext]
  361. jsval exportFunction(in jsval vfunction, in jsval vscope, [optional] in jsval voptions);
  362. /*
  363. * To be called from JS only.
  364. *
  365. * Returns an object created in |vobj|'s compartment.
  366. * If defineAs property on the options object is a non-null ID,
  367. * the new object will be added to vobj as a property. Also, the
  368. * returned new object is always automatically waived (see waiveXrays).
  369. */
  370. [implicit_jscontext]
  371. jsval createObjectIn(in jsval vobj, [optional] in jsval voptions);
  372. /*
  373. * To be called from JS only.
  374. *
  375. * Ensures that all functions come from vobj's scope (and aren't cross
  376. * compartment wrappers).
  377. */
  378. [implicit_jscontext]
  379. void makeObjectPropsNormal(in jsval vobj);
  380. /**
  381. * Determines whether this object is backed by a DeadObjectProxy.
  382. *
  383. * Dead-wrapper objects hold no other objects alive (they have no outgoing
  384. * reference edges) and will throw if you touch them (e.g. by
  385. * reading/writing a property).
  386. */
  387. bool isDeadWrapper(in jsval obj);
  388. /**
  389. * Determines whether this object is a cross-process wrapper.
  390. */
  391. bool isCrossProcessWrapper(in jsval obj);
  392. /**
  393. * CPOWs can have user data attached to them. This data originates
  394. * in the local process via the
  395. * nsIRemoteTagService.getRemoteObjectTag method. It's sent along
  396. * with the CPOW to the remote process, where it can be fetched
  397. * with this function, getCrossProcessWrapperTag.
  398. */
  399. ACString getCrossProcessWrapperTag(in jsval obj);
  400. /**
  401. * If CPOWs are disabled for browser code via the
  402. * dom.ipc.cpows.forbid-unsafe-from-browser preferences, then only
  403. * add-ons can use CPOWs. This function allows a non-addon scope
  404. * to opt into CPOWs. It's necessary for the implementation of
  405. * RemoteAddonsParent.jsm.
  406. */
  407. void permitCPOWsInScope(in jsval obj);
  408. /*
  409. * To be called from JS only. This is for Gecko internal use only, and may
  410. * disappear at any moment.
  411. *
  412. * Forces a recomputation of all wrappers in and out of the compartment
  413. * containing |vobj|. If |vobj| is not an object, all wrappers system-wide
  414. * are recomputed.
  415. */
  416. [implicit_jscontext]
  417. void recomputeWrappers([optional] in jsval vobj);
  418. /*
  419. * To be called from JS only. This is for Gecko internal use only, and may
  420. * disappear at any moment.
  421. *
  422. * Enables Xray vision for same-compartment access for the compartment
  423. * indicated by |vscope|. All outgoing wrappers are recomputed.
  424. */
  425. [implicit_jscontext]
  426. void setWantXrays(in jsval vscope);
  427. /*
  428. * For gecko internal automation use only. Calling this in production code
  429. * would result in security vulnerabilities, so it will crash if used outside
  430. * of automation.
  431. */
  432. [implicit_jscontext]
  433. void forcePermissiveCOWs();
  434. /*
  435. * Forces the usage of a privileged |Components| object for a potentially-
  436. * unprivileged scope. This will crash if used outside of automation.
  437. */
  438. [implicit_jscontext]
  439. void forcePrivilegedComponentsForScope(in jsval vscope);
  440. /*
  441. * This seemingly-paradoxical API allows privileged code to explicitly give
  442. * unprivileged code a reference to its own Components object (whereas it's
  443. * normally hidden away on a scope chain visible only to XBL methods). See
  444. * also SpecialPowers.getComponents.
  445. */
  446. [implicit_jscontext]
  447. jsval getComponentsForScope(in jsval vscope);
  448. /*
  449. * Dispatches a runnable to the current/main thread. If |scope| is passed,
  450. * the runnable will be dispatch in the compartment of |scope|, which
  451. * affects which error reporter gets called.
  452. */
  453. [implicit_jscontext]
  454. void dispatch(in jsval runnable, [optional] in jsval scope);
  455. /*
  456. * To be called from JS only.
  457. *
  458. * These are the set of JSContext options that privileged script
  459. * is allowed to control for the purposes of testing. These
  460. * options should be kept in sync with what's controllable in the
  461. * jsshell and by setting prefs in nsJSEnvironment.
  462. *
  463. * NB: Assume that getting any of these attributes is relatively
  464. * cheap, but setting any of them is relatively expensive.
  465. */
  466. [implicit_jscontext]
  467. attribute boolean strict;
  468. [implicit_jscontext]
  469. attribute boolean werror;
  470. [implicit_jscontext]
  471. attribute boolean strict_mode;
  472. [implicit_jscontext]
  473. attribute boolean ion;
  474. [implicit_jscontext]
  475. void nukeSandbox(in jsval obj);
  476. /*
  477. * API to dynamically block script for a given global. This takes effect
  478. * immediately, unlike other APIs that only affect newly-created globals.
  479. *
  480. * The machinery here maintains a counter, and allows script only if each
  481. * call to blockScriptForGlobal() has been matched with a call to
  482. * unblockScriptForGlobal(). The caller _must_ make sure never to call
  483. * unblock() more times than it calls block(), since that could potentially
  484. * interfere with another consumer's script blocking.
  485. */
  486. [implicit_jscontext]
  487. void blockScriptForGlobal(in jsval global);
  488. [implicit_jscontext]
  489. void unblockScriptForGlobal(in jsval global);
  490. /**
  491. * Check whether the given object is an XrayWrapper.
  492. */
  493. bool isXrayWrapper(in jsval obj);
  494. /**
  495. * Waive Xray on a given value. Identity op for primitives.
  496. */
  497. [implicit_jscontext]
  498. jsval waiveXrays(in jsval aVal);
  499. /**
  500. * Strip off Xray waivers on a given value. Identity op for primitives.
  501. */
  502. [implicit_jscontext]
  503. jsval unwaiveXrays(in jsval aVal);
  504. /**
  505. * Gets the name of the JSClass of the object.
  506. *
  507. * if |aUnwrap| is true, all wrappers are unwrapped first. Unless you're
  508. * specifically trying to detect whether the object is a proxy, this is
  509. * probably what you want.
  510. */
  511. [implicit_jscontext]
  512. string getClassName(in jsval aObj, in bool aUnwrap);
  513. /**
  514. * Get a DOM classinfo for the given classname. Only some class
  515. * names are supported.
  516. */
  517. nsIClassInfo getDOMClassInfo(in AString aClassName);
  518. /**
  519. * Gets the incument global for the execution of this function. For internal
  520. * and testing use only.
  521. *
  522. * If |callback| is passed, it is invoked with the incumbent global as its
  523. * sole argument. This allows the incumbent global to be measured in callback
  524. * environments with no scripted frames on the stack.
  525. */
  526. [implicit_jscontext]
  527. jsval getIncumbentGlobal([optional] in jsval callback);
  528. /**
  529. * Forces the generation of an XPCWrappedJS for a given object. For internal
  530. * and testing use only. This is only useful to set up wrapper map conditions
  531. * for a testcase. The return value is not an XPCWrappedJS itself, but an
  532. * opaque nsISupports holder that keeps the underlying XPCWrappedJS alive.
  533. *
  534. * if |scope| is passed, the XPCWrappedJS is generated in the scope of that object.
  535. */
  536. [implicit_jscontext]
  537. nsISupports generateXPCWrappedJS(in jsval obj, [optional] in jsval scope);
  538. /**
  539. * Retrieve the last time, in microseconds since epoch, that a given
  540. * watchdog-related event occured.
  541. *
  542. * Valid categories:
  543. * "ContextStateChange" - Context switching between active and inactive states
  544. * "WatchdogWakeup" - Watchdog waking up from sleeping
  545. * "WatchdogHibernateStart" - Watchdog begins hibernating
  546. * "WatchdogHibernateStop" - Watchdog stops hibernating
  547. */
  548. PRTime getWatchdogTimestamp(in AString aCategory);
  549. [implicit_jscontext]
  550. jsval getJSEngineTelemetryValue();
  551. /*
  552. * Clone an object into a scope.
  553. * The 3rd argument is an optional options object:
  554. * - cloneFunctions: boolean. If true, functions in the value are
  555. * wrapped in a function forwarder that appears to be a native function in
  556. * the content scope. Defaults to false.
  557. * - wrapReflectors: boolean. If true, DOM objects are passed through the
  558. * clone directly with cross-compartment wrappers. Otherwise, the clone
  559. * fails when such an object is encountered. Defaults to false.
  560. */
  561. [implicit_jscontext]
  562. jsval cloneInto(in jsval value, in jsval scope, [optional] in jsval options);
  563. /*
  564. * When C++-Implemented code does security checks, it can generally query
  565. * the subject principal (i.e. the principal of the most-recently-executed
  566. * script) in order to determine the responsible party. However, when an API
  567. * is implemented in JS, this doesn't work - the most-recently-executed
  568. * script is always the System-Principaled API implementation. So we need
  569. * another mechanism.
  570. *
  571. * Hence the notion of the "WebIDL Caller". If the current Entry Script on
  572. * the Script Settings Stack represents the invocation of JS-implemented
  573. * WebIDL, this API returns the principal of the caller at the time
  574. * of invocation. Otherwise (i.e. outside of JS-implemented WebIDL), this
  575. * function throws. If it throws, you probably shouldn't be using it.
  576. */
  577. nsIPrincipal getWebIDLCallerPrincipal();
  578. /*
  579. * Gets the principal of a script object, after unwrapping any cross-
  580. * compartment wrappers.
  581. */
  582. [implicit_jscontext]
  583. nsIPrincipal getObjectPrincipal(in jsval obj);
  584. /*
  585. * Gets the URI or identifier string associated with an object's
  586. * compartment (the same one used by the memory reporter machinery).
  587. *
  588. * Unwraps cross-compartment wrappers first.
  589. *
  590. * The string formats and values may change at any time. Do not depend on
  591. * this from addon code.
  592. */
  593. [implicit_jscontext]
  594. ACString getCompartmentLocation(in jsval obj);
  595. [implicit_jscontext]
  596. void setAddonInterposition(in ACString addonId, in nsIAddonInterposition interposition);
  597. /*
  598. * Enables call interpositions from addon scopes to any functions in the scope of |target|.
  599. */
  600. [implicit_jscontext]
  601. void setAddonCallInterposition(in jsval target);
  602. [implicit_jscontext]
  603. void allowCPOWsInAddon(in ACString addonId, in bool allow);
  604. /*
  605. * Return a fractional number of milliseconds from process
  606. * startup, measured with a monotonic clock.
  607. */
  608. double now();
  609. };
  610. /**
  611. * Interface for the 'Components' object.
  612. *
  613. * The first interface contains things that are available to non-chrome XBL code
  614. * that runs in a scope with an nsExpandedPrincipal. The second interface
  615. * includes members that are only exposed to chrome.
  616. */
  617. [scriptable, uuid(eeeada2f-86c0-4609-b2bf-4bf2351b1ce6)]
  618. interface nsIXPCComponentsBase : nsISupports
  619. {
  620. readonly attribute nsIXPCComponents_Interfaces interfaces;
  621. readonly attribute nsIXPCComponents_InterfacesByID interfacesByID;
  622. readonly attribute nsIXPCComponents_Results results;
  623. boolean isSuccessCode(in nsresult result);
  624. };
  625. [scriptable, uuid(aa28aaf6-70ce-4b03-9514-afe43c7dfda8)]
  626. interface nsIXPCComponents : nsIXPCComponentsBase
  627. {
  628. readonly attribute nsIXPCComponents_Classes classes;
  629. readonly attribute nsIXPCComponents_ClassesByID classesByID;
  630. // Will return null if there is no JS stack right now.
  631. readonly attribute nsIStackFrame stack;
  632. readonly attribute nsIComponentManager manager;
  633. readonly attribute nsIXPCComponents_Utils utils;
  634. readonly attribute nsIXPCComponents_ID ID;
  635. readonly attribute nsIXPCComponents_Exception Exception;
  636. readonly attribute nsIXPCComponents_Constructor Constructor;
  637. [implicit_jscontext]
  638. // A javascript component can set |returnCode| to specify an nsresult to
  639. // be returned without throwing an exception.
  640. attribute jsval returnCode;
  641. /* @deprecated Use Components.utils.reportError instead. */
  642. [deprecated, implicit_jscontext] void reportError(in jsval error);
  643. };