~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/js/src/xpconnect/tests/js/multiple.js

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
2
 *
 
3
 * ***** BEGIN LICENSE BLOCK *****
 
4
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
 *
 
6
 * The contents of this file are subject to the Mozilla Public License Version
 
7
 * 1.1 (the "License"); you may not use this file except in compliance with
 
8
 * the License. You may obtain a copy of the License at
 
9
 * http://www.mozilla.org/MPL/
 
10
 *
 
11
 * Software distributed under the License is distributed on an "AS IS" basis,
 
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
13
 * for the specific language governing rights and limitations under the
 
14
 * License.
 
15
 *
 
16
 * The Original Code is Mozilla Communicator client code, released
 
17
 * March 31, 1998.
 
18
 *
 
19
 * The Initial Developer of the Original Code is
 
20
 * Netscape Communications Corporation.
 
21
 * Portions created by the Initial Developer are Copyright (C) 1998
 
22
 * the Initial Developer. All Rights Reserved.
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the terms of
 
27
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 
28
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
30
 * of those above. If you wish to allow use of your version of this file only
 
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
32
 * use your version of this file under the terms of the MPL, indicate your
 
33
 * decision by deleting the provisions above and replace them with the notice
 
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
35
 * the provisions above, a recipient may use your version of this file under
 
36
 * the terms of any one of the MPL, the GPL or the LGPL.
 
37
 *
 
38
 * ***** END LICENSE BLOCK ***** */
 
39
 
 
40
/**
 
41
 *      Test interfaces that inherit from interfaces other than nsISupports
 
42
 *  and classes that inherit from multiple interfaces.
 
43
 *
 
44
 *  See xpctest_multiple.idl and xpctest_multiple.cpp.
 
45
 */
 
46
 
 
47
 
 
48
StartTest( "Interfaces that inherit from interfaces other than nsISupports" );
 
49
SetupTest();
 
50
AddTestData();
 
51
StopTest();
 
52
 
 
53
function SetupTest() {
 
54
try {           
 
55
        iChild = Components.interfaces.nsIXPCTestChild3;
 
56
        iParentOne = Components.interfaces.nsIXPCTestParentOne;
 
57
 
 
58
        CONTRACTID = "@mozilla.org/js/xpc/test/Child3;1";
 
59
        cChild = Components.classes[CONTRACTID].createInstance();
 
60
        CONTRACTID = "@mozilla.org/js/xpc/test/ParentOne;1";
 
61
        cParentOne = Components.classes[CONTRACTID].createInstance();
 
62
 
 
63
        child = cChild.QueryInterface(iChild);
 
64
        parentOne = cParentOne.QueryInterface(iParentOne);
 
65
 
 
66
} catch (e) {
 
67
        WriteLine(e);
 
68
        AddTestCase(
 
69
                "Setting up the test",
 
70
                "PASSED",
 
71
                "FAILED: " + e.message  +" "+ e.location +". ");
 
72
}
 
73
}
 
74
 
 
75
function AddTestData() {
 
76
        // child should have all the properties and methods of parentOne
 
77
 
 
78
        parentOneProps = {};
 
79
        for ( p in parentOne ) parentOneProps[p] = true;
 
80
        for ( p in child ) if ( parentOneProps[p] ) parentOneProps[p] = false;
 
81
 
 
82
        for ( p in parentOneProps ) {
 
83
                print( p );
 
84
 
 
85
                AddTestCase(
 
86
                        "child has property " + p,
 
87
                        true,
 
88
                        (parentOneProps[p] ? false : true ) 
 
89
                );
 
90
 
 
91
                if ( p.match(/Method/) ) {
 
92
                        AddTestCase(
 
93
                                "child."+p+"()",
 
94
                                "@mozilla.org/js/xpc/test/Child3;1 method",
 
95
                                child[p]() );
 
96
 
 
97
                } else if (p.match(/Attribute/)) {
 
98
                        AddTestCase(
 
99
                                "child." +p,
 
100
                                "@mozilla.org/js/xpc/test/Child3;1 attribute",
 
101
                                child[p] );
 
102
                }
 
103
        }
 
104
 
 
105
        var result = true;
 
106
        for ( p in parentOneProps ) {
 
107
                if ( parentOneProps[p] = true )
 
108
                        result == false;
 
109
        }
 
110
 
 
111
        AddTestCase(
 
112
                "child has parentOne properties?",
 
113
                true,
 
114
                result );
 
115
 
 
116
        for ( p in child ) {
 
117
                AddTestCase(
 
118
                        "child has property " + p,
 
119
                        true,
 
120
                        (child[p] ? true : false ) 
 
121
                );
 
122
 
 
123
                if ( p.match(/Method/) ) {
 
124
                        AddTestCase(
 
125
                                "child."+p+"()",
 
126
                                "@mozilla.org/js/xpc/test/Child3;1 method",
 
127
                                child[p]() );
 
128
 
 
129
                } else if (p.match(/Attribute/)) {
 
130
                        AddTestCase(
 
131
                                "child." +p,
 
132
                                "@mozilla.org/js/xpc/test/Child3;1 attribute",
 
133
                                child[p] );
 
134
                }
 
135
        }               
 
136
}
 
137