зеркало из https://github.com/mozilla/gecko-dev.git
Bug 693341 - Introduce a few test interfaces. r=khuey
This commit is contained in:
Родитель
bbb216546b
Коммит
8e9a55d1d8
|
@ -50,6 +50,7 @@ NO_DIST_INSTALL = 1
|
|||
|
||||
JS_FILES = \
|
||||
xpctest_attributes.js \
|
||||
xpctest_interfaces.js \
|
||||
xpctest_params.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -7,4 +7,10 @@ contract @mozilla.org/js/xpc/test/js/ObjectReadOnly;1 {916c4247-253d-4ed0-a425-a
|
|||
component {e3b86f4e-49c0-487c-a2b0-3a986720a044} xpctest_params.js
|
||||
contract @mozilla.org/js/xpc/test/js/Params;1 {e3b86f4e-49c0-487c-a2b0-3a986720a044}
|
||||
|
||||
component {3c8fd2f5-970c-42c6-b5dd-cda1c16dcfd8} xpctest_interfaces.js
|
||||
contract @mozilla.org/js/xpc/test/js/InterfaceA;1 {3c8fd2f5-970c-42c6-b5dd-cda1c16dcfd8}
|
||||
|
||||
component {ff528c3a-2410-46de-acaa-449aa6403a33} xpctest_interfaces.js
|
||||
contract @mozilla.org/js/xpc/test/js/InterfaceB;1 {ff528c3a-2410-46de-acaa-449aa6403a33}
|
||||
|
||||
interfaces xpctest.xpt
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is XPConnect Test Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bobby Holley <bobbyholley@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
|
||||
|
||||
function TestInterfaceA() {}
|
||||
TestInterfaceA.prototype = {
|
||||
|
||||
/* Boilerplate */
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces["nsIXPCTestInterfaceA"]]),
|
||||
contractID: "@mozilla.org/js/xpc/test/js/TestInterfaceA;1",
|
||||
classID: Components.ID("{3c8fd2f5-970c-42c6-b5dd-cda1c16dcfd8}"),
|
||||
|
||||
/* nsIXPCTestInterfaceA */
|
||||
name: "TestInterfaceADefaultName"
|
||||
};
|
||||
|
||||
function TestInterfaceB() {}
|
||||
TestInterfaceB.prototype = {
|
||||
|
||||
/* Boilerplate */
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces["nsIXPCTestInterfaceB"]]),
|
||||
contractID: "@mozilla.org/js/xpc/test/js/TestInterfaceB;1",
|
||||
classID: Components.ID("{ff528c3a-2410-46de-acaa-449aa6403a33}"),
|
||||
|
||||
/* nsIXPCTestInterfaceA */
|
||||
name: "TestInterfaceADefaultName"
|
||||
};
|
||||
|
||||
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([TestInterfaceA, TestInterfaceB]);
|
|
@ -47,6 +47,7 @@ MODULE = xpctest
|
|||
|
||||
XPIDLSRCS = \
|
||||
xpctest_attributes.idl \
|
||||
xpctest_interfaces.idl \
|
||||
xpctest_params.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is XPConnect Test Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bobby Holley <bobbyholley@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Very simple test interfaces.
|
||||
*
|
||||
* This is used by the other test functionality when it needs to play around with
|
||||
* interface pointers.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(3c8fd2f5-970c-42c6-b5dd-cda1c16dcfd8)]
|
||||
interface nsIXPCTestInterfaceA : nsISupports {
|
||||
attribute string name;
|
||||
};
|
||||
|
||||
[scriptable, uuid(ff528c3a-2410-46de-acaa-449aa6403a33)]
|
||||
interface nsIXPCTestInterfaceB : nsISupports {
|
||||
attribute string name;
|
||||
};
|
|
@ -124,6 +124,10 @@ function test_component(contractid) {
|
|||
doTestWorkaround("testACString", "Just a regular C string.");
|
||||
doTest("testJsval", {aprop: 12, bprop: "str"}, 4.22);
|
||||
|
||||
// Helpers to instantiate various test XPCOM objects.
|
||||
function makeA() { return Cc["@mozilla.org/js/xpc/test/js/InterfaceA;1"].createInstance(Ci['nsIXPCTestInterfaceA']); };
|
||||
function makeB() { return Cc["@mozilla.org/js/xpc/test/js/InterfaceB;1"].createInstance(Ci['nsIXPCTestInterfaceB']); };
|
||||
|
||||
// Test arrays.
|
||||
doIsTest("testShortArray", [2, 4, 6], 3, [1, 3, 5, 7], 4, arrayComparator);
|
||||
doIsTest("testLongLongArray", [-10000000000], 1, [1, 3, 1234511234551], 3, arrayComparator);
|
||||
|
|
Загрузка…
Ссылка в новой задаче