1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
8 * Test the use of Components.returnCode
10 * This ("parent") interface defines a method that in-turn calls another
11 * ("child") interface implemented in JS, and returns the nsresult from that
12 * child interface. The child interface manages the return code by way of
13 * Components.returnCode.
16 #include
"nsISupports.idl"
19 [scriptable
, uuid(479e4532
-95cf
-48b8
-a99b
-8a5881e47138
)]
20 interface nsIXPCTestReturnCodeParent
: nsISupports
{
21 // Calls the "child" interface with the specified behavior flag. Returns
22 // the NSRESULT from the child interface.
23 nsresult callChild
(in long childBehavior
);
26 [scriptable
, uuid(672cfd34
-1fd1
-455d
-9901-d879fa6fdb95
)]
27 interface nsIXPCTestReturnCodeChild
: nsISupports
{
28 void doIt
(in long behavior
);
30 // Flags to control that the child does.
31 // child will throw a JS exception
32 const long CHILD_SHOULD_THROW
= 0;
34 // child will just return normally
35 const long CHILD_SHOULD_RETURN_SUCCESS
= 1;
37 // child will return after setting Components.returnCode to NS_ERROR_FAILURE
38 const long CHILD_SHOULD_RETURN_RESULTCODE
= 2;
40 // child will set Components.returnCode to NS_ERROR_UNEXPECTED, then create
41 // a new component that sets Components.returnCode to NS_ERROR_FAILURE.
42 // Our caller should see the NS_ERROR_UNEXPECTED we set rather than the
43 // value set later by the "inner" child.
44 const long CHILD_SHOULD_NEST_RESULTCODES
= 3;