mozIJSSubScriptLoader.idl 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. interface nsIURI;
  8. interface nsIPrincipal;
  9. interface nsIObserver;
  10. [scriptable, uuid(19533e7b-f321-4ef1-bc59-6e812dc2a733)]
  11. interface mozIJSSubScriptLoader : nsISupports
  12. {
  13. /**
  14. * This method should only be called from JS!
  15. * In JS, the signature looks like:
  16. * rv loadSubScript (url [, obj] [, charset]);
  17. * @param url the url of the sub-script, it MUST be either a file:,
  18. * resource:, or chrome: url, and MUST be local.
  19. * @param obj an optional object to evaluate the script onto, it
  20. * defaults to the global object of the caller.
  21. * @param charset optionally specifies the character encoding of
  22. * the file. If absent, the file is interpreted
  23. * as ASCII.
  24. * @retval rv the value returned by the sub-script
  25. */
  26. [implicit_jscontext]
  27. jsval loadSubScript(in AString url, [optional] in jsval obj, [optional] in AString charset);
  28. /**
  29. * This method should only be called from JS!
  30. * In JS, the signature looks like:
  31. * rv = loadSubScript (url, optionsObject)
  32. * @param url the url of the sub-script, it MUST be either a file:,
  33. * resource:, or chrome: url, and MUST be local.
  34. * @param optionsObject an object with parameters. Valid parameters are:
  35. * - charset: specifying the character encoding of the file (default: ASCII)
  36. * - target: an object to evaluate onto (default: global object of the caller)
  37. * - ignoreCache: if set to true, will bypass the cache for reading the file.
  38. * - async: if set to true, the script will be loaded
  39. * asynchronously, and a Promise is returned which
  40. * resolves to its result when execution is complete.
  41. * @retval rv the value returned by the sub-script
  42. */
  43. [implicit_jscontext]
  44. jsval loadSubScriptWithOptions(in AString url, in jsval options);
  45. /*
  46. * Compiles a JS script off the main thread and calls back the
  47. * observer once it's done.
  48. * The script will be cached in temporary or persistent storage depending
  49. * on the principal used.
  50. * We fire the notification callback in all cases - there is no fatal
  51. * error there.
  52. * @param uri the uri of the script to load.
  53. * @param principal the principal from which we get the app id if any.
  54. * @param observer this observer will be called once the script has
  55. * been precompiled. The notification topic will be
  56. * 'script-precompiled' and the subject the uri of the
  57. * script as a nsIURI.
  58. */
  59. void precompileScript(in nsIURI uri,
  60. in nsIPrincipal principal,
  61. in nsIObserver observer);
  62. };