|
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 |
|
7 #include "nsISupports.idl" |
|
8 |
|
9 interface nsIURI; |
|
10 interface nsIPrincipal; |
|
11 interface nsIObserver; |
|
12 |
|
13 [scriptable, uuid(19533e7b-f321-4ef1-bc59-6e812dc2a733)] |
|
14 interface mozIJSSubScriptLoader : nsISupports |
|
15 { |
|
16 /** |
|
17 * This method should only be called from JS! |
|
18 * In JS, the signature looks like: |
|
19 * rv loadSubScript (url [, obj] [, charset]); |
|
20 * @param url the url of the sub-script, it MUST be either a file:, |
|
21 * resource:, or chrome: url, and MUST be local. |
|
22 * @param obj an optional object to evaluate the script onto, it |
|
23 * defaults to the global object of the caller. |
|
24 * @param charset optionally specifies the character encoding of |
|
25 * the file. If absent, the file is interpreted |
|
26 * as ASCII. |
|
27 * @retval rv the value returned by the sub-script |
|
28 */ |
|
29 [implicit_jscontext] |
|
30 jsval loadSubScript(in AString url, [optional] in jsval obj, [optional] in AString charset); |
|
31 |
|
32 /** |
|
33 * This method should only be called from JS! |
|
34 * In JS, the signature looks like: |
|
35 * rv = loadSubScript (url, optionsObject) |
|
36 * @param url the url of the sub-script, it MUST be either a file:, |
|
37 * resource:, or chrome: url, and MUST be local. |
|
38 * @param optionsObject an object with parameters. Valid parameters are: |
|
39 * - charset: specifying the character encoding of the file (default: ASCII) |
|
40 * - target: an object to evaluate onto (default: global object of the caller) |
|
41 * - ignoreCache: if set to true, will bypass the cache for reading the file. |
|
42 * @retval rv the value returned by the sub-script |
|
43 */ |
|
44 [implicit_jscontext] |
|
45 jsval loadSubScriptWithOptions(in AString url, in jsval options); |
|
46 |
|
47 /* |
|
48 * Compiles a JS script off the main thread and calls back the |
|
49 * observer once it's done. |
|
50 * The script will be cached in temporary or persistent storage depending |
|
51 * on the principal used. |
|
52 * We fire the notification callback in all cases - there is no fatal |
|
53 * error there. |
|
54 * @param uri the uri of the script to load. |
|
55 * @param principal the principal from which we get the app id if any. |
|
56 * @param observer this observer will be called once the script has |
|
57 * been precompiled. The notification topic will be |
|
58 * 'script-precompiled' and the subject the uri of the |
|
59 * script as a nsIURI. |
|
60 */ |
|
61 void precompileScript(in nsIURI uri, |
|
62 in nsIPrincipal principal, |
|
63 in nsIObserver observer); |
|
64 }; |