michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIURI; michael@0: interface nsIPrincipal; michael@0: interface nsIObserver; michael@0: michael@0: [scriptable, uuid(19533e7b-f321-4ef1-bc59-6e812dc2a733)] michael@0: interface mozIJSSubScriptLoader : nsISupports michael@0: { michael@0: /** michael@0: * This method should only be called from JS! michael@0: * In JS, the signature looks like: michael@0: * rv loadSubScript (url [, obj] [, charset]); michael@0: * @param url the url of the sub-script, it MUST be either a file:, michael@0: * resource:, or chrome: url, and MUST be local. michael@0: * @param obj an optional object to evaluate the script onto, it michael@0: * defaults to the global object of the caller. michael@0: * @param charset optionally specifies the character encoding of michael@0: * the file. If absent, the file is interpreted michael@0: * as ASCII. michael@0: * @retval rv the value returned by the sub-script michael@0: */ michael@0: [implicit_jscontext] michael@0: jsval loadSubScript(in AString url, [optional] in jsval obj, [optional] in AString charset); michael@0: michael@0: /** michael@0: * This method should only be called from JS! michael@0: * In JS, the signature looks like: michael@0: * rv = loadSubScript (url, optionsObject) michael@0: * @param url the url of the sub-script, it MUST be either a file:, michael@0: * resource:, or chrome: url, and MUST be local. michael@0: * @param optionsObject an object with parameters. Valid parameters are: michael@0: * - charset: specifying the character encoding of the file (default: ASCII) michael@0: * - target: an object to evaluate onto (default: global object of the caller) michael@0: * - ignoreCache: if set to true, will bypass the cache for reading the file. michael@0: * @retval rv the value returned by the sub-script michael@0: */ michael@0: [implicit_jscontext] michael@0: jsval loadSubScriptWithOptions(in AString url, in jsval options); michael@0: michael@0: /* michael@0: * Compiles a JS script off the main thread and calls back the michael@0: * observer once it's done. michael@0: * The script will be cached in temporary or persistent storage depending michael@0: * on the principal used. michael@0: * We fire the notification callback in all cases - there is no fatal michael@0: * error there. michael@0: * @param uri the uri of the script to load. michael@0: * @param principal the principal from which we get the app id if any. michael@0: * @param observer this observer will be called once the script has michael@0: * been precompiled. The notification topic will be michael@0: * 'script-precompiled' and the subject the uri of the michael@0: * script as a nsIURI. michael@0: */ michael@0: void precompileScript(in nsIURI uri, michael@0: in nsIPrincipal principal, michael@0: in nsIObserver observer); michael@0: };