Backed out changeset b2b956ba0acd (bug 891107) for xpcshell-test failure

This commit is contained in:
Tooru Fujisawa 2015-04-22 20:08:23 +09:00
parent 4290d2b814
commit d958c4556d
18 changed files with 124 additions and 1162 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@
#include "ffi.h"
#include "jsalloc.h"
#include "jsprf.h"
#include "prlink.h"
#include "ctypes/typedefs.h"
@ -54,32 +53,6 @@ AppendString(Vector<T, N, AP>& v, const char (&array)[ArrayLength])
v[i + vlen] = array[i];
}
template <class T, size_t N, class AP>
void
AppendChars(Vector<T, N, AP>& v, const char c, size_t count)
{
size_t vlen = v.length();
if (!v.resize(vlen + count))
return;
for (size_t i = 0; i < count; ++i)
v[i + vlen] = c;
}
template <class T, size_t N, class AP>
void
AppendUInt(Vector<T, N, AP>& v, unsigned n)
{
char array[16];
size_t alen = JS_snprintf(array, 16, "%u", n);
size_t vlen = v.length();
if (!v.resize(vlen + alen))
return;
for (size_t i = 0; i < alen; ++i)
v[i + vlen] = array[i];
}
template <class T, size_t N, size_t M, class AP>
void
AppendString(Vector<T, N, AP>& v, Vector<T, M, AP>& w)
@ -402,7 +375,6 @@ enum CDataSlot {
SLOT_REFERENT = 1, // JSObject this object must keep alive, if any
SLOT_DATA = 2, // pointer to a buffer containing the binary data
SLOT_OWNS = 3, // JSVAL_TRUE if this CData owns its own buffer
SLOT_FUNNAME = 4, // JSString representing the function name
CDATA_SLOTS
};

View File

@ -321,7 +321,7 @@ Library::Declare(JSContext* cx, unsigned argc, jsval* vp)
void* data;
PRFuncPtr fnptr;
RootedString nameStr(cx, args[0].toString());
JSString* nameStr = args[0].toString();
AutoCString symbol;
if (isFunction) {
// Build the symbol, with mangling if necessary.
@ -352,9 +352,6 @@ Library::Declare(JSContext* cx, unsigned argc, jsval* vp)
if (!result)
return false;
if (isFunction)
JS_SetReservedSlot(result, SLOT_FUNNAME, StringValue(nameStr));
args.rval().setObject(*result);
// Seal the CData object, to prevent modification of the function pointer.

View File

@ -10,25 +10,5 @@
*/
MSG_DEF(CTYPESMSG_PLACEHOLDER_0, 0, JSEXN_NONE, NULL)
MSG_DEF(CTYPESMSG_TYPE_ERROR, 2, JSEXN_TYPEERR, "expected type {0}, got {1}")
/* type conversion */
MSG_DEF(CTYPESMSG_CONV_ERROR_ARG,3, JSEXN_TYPEERR, "can't pass {0} to argument {1} of {2}")
MSG_DEF(CTYPESMSG_CONV_ERROR_ARRAY,3, JSEXN_TYPEERR, "can't convert {0} to element {1} of the type {2}")
MSG_DEF(CTYPESMSG_CONV_ERROR_FIN,2, JSEXN_TYPEERR, "can't convert {0} to the type of argument 1 of {1}")
MSG_DEF(CTYPESMSG_CONV_ERROR_RET,2, JSEXN_TYPEERR, "can't convert {0} to the return type of {1}")
MSG_DEF(CTYPESMSG_CONV_ERROR_SET,2, JSEXN_TYPEERR, "can't convert {0} to the type {1}")
MSG_DEF(CTYPESMSG_CONV_ERROR_STRUCT,5, JSEXN_TYPEERR, "can't convert {0} to the '{1}' field ({2}) of {3}{4}")
MSG_DEF(CTYPESMSG_NON_PRIMITIVE, 1, JSEXN_TYPEERR, ".value only works on character and numeric types, not `{0}`")
MSG_DEF(CTYPESMSG_TYPE_ERROR, 2, JSEXN_TYPEERR, "expected {0}, got {1}")
/* array */
MSG_DEF(CTYPESMSG_ARRAY_MISMATCH,4, JSEXN_TYPEERR, "length of {0} does not match to the length of the type {1} (expected {2}, got {3})")
MSG_DEF(CTYPESMSG_ARRAY_OVERFLOW,4, JSEXN_TYPEERR, "length of {0} does not fit to the length of the type {1} (expected {2} or lower, got {3})")
/* struct */
MSG_DEF(CTYPESMSG_FIELD_MISMATCH,5, JSEXN_TYPEERR, "property count of {0} does not match to field count of the type {1} (expected {2}, got {3}){4}")
MSG_DEF(CTYPESMSG_PROP_NONSTRING,3, JSEXN_TYPEERR, "property name {0} of {1} is not a string{2}")
/* data finalizer */
MSG_DEF(CTYPESMSG_EMPTY_FIN, 1, JSEXN_TYPEERR, "attempting to convert an empty CDataFinalizer{0}")
MSG_DEF(CTYPESMSG_FIN_SIZE_ERROR,2, JSEXN_TYPEERR, "expected an object with the same size as argument 1 of {0}, got {1}")

View File

@ -65,23 +65,3 @@ if (typeof assertNoWarning === 'undefined') {
}
};
}
if (typeof assertTypeErrorMessage === 'undefined') {
var assertTypeErrorMessage = function assertTypeErrorMessage(f, test) {
try {
f();
} catch (e) {
if (!(e instanceof TypeError))
throw new Error("Assertion failed: expected exception TypeError, got " + e);
if (typeof test == "string") {
if (test != e.message)
throw new Error("Assertion failed: expeceted " + test + ", got " + e.message);
} else {
if (!test.test(e.message))
throw new Error("Assertion failed: expeceted " + test.toString() + ", got " + e.message);
}
return;
}
throw new Error("Assertion failed: expected exception TypeError, no exception thrown");
};
}

View File

@ -1,36 +0,0 @@
// Type conversion error should report its type.
load(libdir + 'asserts.js');
function test() {
// constructor
assertTypeErrorMessage(() => { ctypes.int32_t.array()("foo"); },
"can't convert the string \"foo\" to the type ctypes.int32_t.array()");
assertTypeErrorMessage(() => { ctypes.int32_t.array(10)("foo"); },
"can't convert the string \"foo\" to the type ctypes.int32_t.array(10)");
assertTypeErrorMessage(() => { ctypes.char.array(2)("foo"); },
"length of the string \"foo\" does not fit to the length of the type ctypes.char.array(2) (expected 2 or lower, got 3)");
assertTypeErrorMessage(() => { ctypes.char16_t.array(2)("foo"); },
"length of the string \"foo\" does not fit to the length of the type ctypes.char16_t.array(2) (expected 2 or lower, got 3)");
assertTypeErrorMessage(() => { ctypes.int8_t.array(2)(new ArrayBuffer(8)); },
"length of the array buffer ({}) does not match to the length of the type ctypes.int8_t.array(2) (expected 2, got 8)");
assertTypeErrorMessage(() => { ctypes.int8_t.array(2)(new Int8Array(8)); },
"length of the typed array ({0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0}) does not match to the length of the type ctypes.int8_t.array(2) (expected 2, got 8)");
// elem setter
assertTypeErrorMessage(() => { ctypes.int32_t.array(10)()[0] = "foo"; },
"can't convert the string \"foo\" to element 0 of the type ctypes.int32_t.array(10)");
assertTypeErrorMessage(() => { ctypes.int32_t.array(10)()[1] = "foo"; },
"can't convert the string \"foo\" to element 1 of the type ctypes.int32_t.array(10)");
// value setter
assertTypeErrorMessage(() => { ctypes.int32_t.array(1)().value = ["foo"]; },
"can't convert the string \"foo\" to element 0 of the type ctypes.int32_t.array(1)");
assertTypeErrorMessage(() => { ctypes.int32_t.array(1)().value = [2, "foo"]; },
"length of the array [2, \"foo\"] does not match to the length of the type ctypes.int32_t.array(1) (expected 1, got 2)");
assertTypeErrorMessage(() => { ctypes.int32_t.array(2)().value = [2, "foo"]; },
"can't convert the string \"foo\" to element 1 of the type ctypes.int32_t.array(2)");
}
if (typeof ctypes === "object")
test();

View File

@ -1,14 +0,0 @@
load(libdir + 'asserts.js');
function test() {
let obj = {
toSource() {
throw 1;
}
};
assertTypeErrorMessage(() => { ctypes.double().value = obj; },
"can't convert <<error converting value to string>> to the type double");
}
if (typeof ctypes === "object")
test();

View File

@ -1,61 +0,0 @@
load(libdir + 'asserts.js');
function test() {
// non object
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, "foo"); },
"expected _a CData object_ of a function pointer type, got the string \"foo\"");
// non CData object
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, ["foo"]); },
"expected a _CData_ object of a function pointer type, got the array [\"foo\"]");
// a CData which is not a pointer
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, ctypes.int32_t(0)); },
"expected a CData object of a function _pointer_ type, got ctypes.int32_t(0)");
// a pointer CData which is not a function
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, ctypes.int32_t.ptr(0)); },
"expected a CData object of a _function_ pointer type, got ctypes.int32_t.ptr(ctypes.UInt64(\"0x0\"))");
// null function
let func_type = ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t,
[ctypes.int32_t, ctypes.int32_t]).ptr;
let f0 = func_type(0);
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, f0); },
"expected a CData object of a _non-NULL_ function pointer type, got ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t, [ctypes.int32_t, ctypes.int32_t]).ptr(ctypes.UInt64(\"0x0\"))");
// a function with 2 arguments
let f1 = func_type(x => x);
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, f1); },
"expected a function accepting exactly one argument, got ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t, [ctypes.int32_t, ctypes.int32_t])");
// non CData in argument 1
let func_type2 = ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t,
[ctypes.int32_t.ptr]).ptr;
let f2 = func_type2(x => x);
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(0, f2); },
"can't convert the number 0 to the type of argument 1 of ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t, [ctypes.int32_t.ptr]).ptr");
// wrong struct in argument 1
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t }]);
let func_type3 = ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t,
[test_struct]).ptr;
let f3 = func_type3(x => x);
assertTypeErrorMessage(() => { ctypes.CDataFinalizer({ "x": "foo" }, f3); },
"can't convert the string \"foo\" to the 'x' field (int32_t) of test_struct at argument 1 of ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t, [test_struct]).ptr");
// different size in argument 1
let func_type4 = ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t,
[ctypes.int32_t]).ptr;
let f4 = func_type4(x => x);
assertTypeErrorMessage(() => { ctypes.CDataFinalizer(ctypes.int16_t(0), f4); },
"expected an object with the same size as argument 1 of ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.int32_t]).ptr, got ctypes.int16_t(0)");
let fin = ctypes.CDataFinalizer(ctypes.int32_t(0), f4);
fin.dispose();
assertTypeErrorMessage(() => { ctypes.int32_t(0).value = fin; },
"attempting to convert an empty CDataFinalizer");
assertTypeErrorMessage(() => { f4(fin); },
/attempting to convert an empty CDataFinalizer at argument 1 of ctypes\.FunctionType\(ctypes\.default_abi, ctypes\.int32_t, \[ctypes\.int32_t\]\)\.ptr\(ctypes\.UInt64\(\"[x0-9A-Fa-f]+\"\)\)/);
}
if (typeof ctypes === "object")
test();

View File

@ -1,33 +0,0 @@
// Type conversion error should report its type.
load(libdir + 'asserts.js');
function test() {
// Note: js shell cannot handle the exception in return value.
// primitive
let func_type = ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t,
[ctypes.int32_t]).ptr;
let f1 = func_type(function() {});
assertTypeErrorMessage(() => { f1("foo"); },
/can't pass the string "foo" to argument 1 of ctypes\.FunctionType\(ctypes\.default_abi, ctypes\.voidptr_t, \[ctypes\.int32_t\]\)\.ptr\(ctypes\.UInt64\("[x0-9A-Fa-f]+"\)\)/);
// struct
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t }]);
let func_type2 = ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t,
[test_struct]).ptr;
let f2 = func_type2(function() {});
assertTypeErrorMessage(() => { f2({ "x": "foo" }); },
/can't convert the string \"foo\" to the 'x' field \(int32_t\) of test_struct at argument 1 of ctypes\.FunctionType\(ctypes\.default_abi, ctypes.int32_t, \[test_struct\]\)\.ptr\(ctypes\.UInt64\(\"[x0-9A-Fa-f]+\"\)\)/);
assertTypeErrorMessage(() => { f2({ "x": "foo", "y": "bar" }); },
/property count of the object \(\{x:\"foo\", y:\"bar\"\}\) does not match to field count of the type test_struct \(expected 1, got 2\) at argument 1 of ctypes\.FunctionType\(ctypes\.default_abi, ctypes\.int32_t, \[test_struct\]\)\.ptr\(ctypes\.UInt64\(\"[x0-9A-Fa-f]+\"\)\)/);
assertTypeErrorMessage(() => { f2({ 0: "foo" }); },
/property name the number 0 of the object \(\{0:\"foo\"\}\) is not a string at argument 1 of ctypes\.FunctionType\(ctypes\.default_abi, ctypes\.int32_t, \[test_struct\]\)\.ptr\(ctypes\.UInt64\(\"[x0-9A-Fa-f]+\"\)\)/);
// error sentinel
assertTypeErrorMessage(() => { func_type(function() {}, null, "foo"); },
"can't convert the string \"foo\" to the return type of ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t, [ctypes.int32_t])");
}
if (typeof ctypes === "object")
test();

View File

@ -1,20 +0,0 @@
load(libdir + 'asserts.js');
function test() {
assertTypeErrorMessage(() => { ctypes.Int64("0xfffffffffffffffffffffff"); },
"can't pass the string \"0xfffffffffffffffffffffff\" to argument 1 of Int64");
assertTypeErrorMessage(() => { ctypes.Int64.join("foo", 0); },
"can't pass the string \"foo\" to argument 1 of Int64.join");
assertTypeErrorMessage(() => { ctypes.Int64.join(0, "foo"); },
"can't pass the string \"foo\" to argument 2 of Int64.join");
assertTypeErrorMessage(() => { ctypes.UInt64("0xfffffffffffffffffffffff"); },
"can't pass the string \"0xfffffffffffffffffffffff\" to argument 1 of UInt64");
assertTypeErrorMessage(() => { ctypes.UInt64.join("foo", 0); },
"can't pass the string \"foo\" to argument 1 of UInt64.join");
assertTypeErrorMessage(() => { ctypes.UInt64.join(0, "foo"); },
"can't pass the string \"foo\" to argument 2 of UInt64.join");
}
if (typeof ctypes === "object")
test();

View File

@ -1,37 +0,0 @@
// Type conversion error for native function should report its name and type
// in C style.
load(libdir + 'asserts.js');
function test() {
let lib;
try {
lib = ctypes.open(ctypes.libraryName("c"));
} catch (e) {
}
if (!lib)
return;
let func = lib.declare("hypot",
ctypes.default_abi,
ctypes.double,
ctypes.double, ctypes.double);
assertTypeErrorMessage(() => { func(1, "xyzzy"); },
"can't pass the string \"xyzzy\" to argument 2 of double hypot(double, double)");
// test C style source for various types
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t }]);
let test_func = ctypes.FunctionType(ctypes.default_abi, ctypes.voidptr_t,
[ctypes.int32_t]).ptr;
func = lib.declare("hypot",
ctypes.default_abi,
ctypes.double,
ctypes.double, ctypes.int32_t.ptr.ptr.ptr.array(),
test_struct, test_struct.ptr.ptr,
test_func, test_func.ptr.ptr.ptr, "...");
assertTypeErrorMessage(() => { func("xyzzy", 1, 2, 3, 4, 5); },
"can't pass the string \"xyzzy\" to argument 1 of double hypot(double, int32_t****, struct test_struct, struct test_struct**, void* (*)(int32_t), void* (****)(int32_t), ...)");
}
if (typeof ctypes === "object")
test();

View File

@ -1,29 +0,0 @@
// Type conversion error should report its type.
load(libdir + 'asserts.js');
function test() {
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t }]);
let struct_val = test_struct();
// constructor
assertTypeErrorMessage(() => { ctypes.int32_t.ptr("foo"); },
"can't convert the string \"foo\" to the type ctypes.int32_t.ptr");
// value setter
assertTypeErrorMessage(() => { test_struct.ptr().value = "foo"; },
"can't convert the string \"foo\" to the type test_struct.ptr");
assertTypeErrorMessage(() => { test_struct.ptr().value = {}; },
"can't convert the object ({}) to the type test_struct.ptr");
assertTypeErrorMessage(() => { test_struct.ptr().value = [1, 2]; },
"can't convert the array [1, 2] to the type test_struct.ptr");
assertTypeErrorMessage(() => { test_struct.ptr().value = Int8Array([1, 2]); },
"can't convert the typed array ({0:1, 1:2}) to the type test_struct.ptr");
// contents setter
assertTypeErrorMessage(() => { ctypes.int32_t().address().contents = {}; },
"can't convert the object ({}) to the type int32_t");
}
if (typeof ctypes === "object")
test();

View File

@ -1,44 +0,0 @@
// Type conversion error should report its type.
load(libdir + 'asserts.js');
function test() {
// constructor
assertTypeErrorMessage(() => { ctypes.int32_t("foo"); },
"can't convert the string \"foo\" to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t(null); },
"can't convert null to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t(undefined); },
"can't convert undefined to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t({}); },
"can't convert the object ({}) to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t([]); },
"can't convert the array [] to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t(new Int8Array([])); },
"can't convert the typed array ({}) to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t(ctypes.int32_t); },
"can't convert ctypes.int32_t to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t("0xfffffffffffffffffffffff"); },
"can't convert the string \"0xfffffffffffffffffffffff\" to the type int32_t");
if (typeof Symbol === "function") {
assertTypeErrorMessage(() => { ctypes.int32_t(Symbol.iterator); },
"can't convert Symbol.iterator to the type int32_t");
assertTypeErrorMessage(() => { ctypes.int32_t(Symbol("foo")); },
"can't convert Symbol(\"foo\") to the type int32_t");
}
// value setter
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t }]);
let struct_val = test_struct();
assertTypeErrorMessage(() => { ctypes.bool().value = struct_val; },
"can't convert test_struct(0) to the type boolean");
assertTypeErrorMessage(() => { ctypes.char16_t().value = struct_val; },
"can't convert test_struct(0) to the type char16_t");
assertTypeErrorMessage(() => { ctypes.int8_t().value = struct_val; },
"can't convert test_struct(0) to the type int8_t");
assertTypeErrorMessage(() => { ctypes.double().value = struct_val; },
"can't convert test_struct(0) to the type double");
}
if (typeof ctypes === "object")
test();

View File

@ -1,36 +0,0 @@
// Type conversion error should report its type.
load(libdir + 'asserts.js');
function test() {
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.int32_t },
{ "bar": ctypes.int32_t }]);
// constructor
assertTypeErrorMessage(() => { new test_struct("foo"); },
"can't convert the string \"foo\" to the type test_struct");
assertTypeErrorMessage(() => { new test_struct("foo", "x"); },
"can't convert the string \"foo\" to the 'x' field (int32_t) of test_struct");
assertTypeErrorMessage(() => { new test_struct({ "x": "foo", "bar": 1 }); },
"can't convert the string \"foo\" to the 'x' field (int32_t) of test_struct");
assertTypeErrorMessage(() => { new test_struct({ 0: 1, "bar": 1 }); },
"property name the number 0 of the object ({0:1, bar:1}) is not a string");
// field setter
let struct_val = test_struct();
assertTypeErrorMessage(() => { struct_val.x = "foo"; },
"can't convert the string \"foo\" to the 'x' field (int32_t) of test_struct");
assertTypeErrorMessage(() => { struct_val.bar = "foo"; },
"can't convert the string \"foo\" to the 'bar' field (int32_t) of test_struct");
// value setter
assertTypeErrorMessage(() => { struct_val.value = { "x": "foo" }; },
"property count of the object ({x:\"foo\"}) does not match to field count of the type test_struct (expected 2, got 1)");
assertTypeErrorMessage(() => { struct_val.value = { "x": "foo", "bar": 1 }; },
"can't convert the string \"foo\" to the 'x' field (int32_t) of test_struct");
assertTypeErrorMessage(() => { struct_val.value = "foo"; },
"can't convert the string \"foo\" to the type test_struct");
}
if (typeof ctypes === "object")
test();

View File

@ -1,20 +0,0 @@
// Accessing `value` property of non primitive type should report its type.
load(libdir + 'asserts.js');
function test() {
let test_struct = ctypes.StructType("test_struct", [{ "x": ctypes.voidptr_t }]);
assertTypeErrorMessage(() => test_struct().value,
".value only works on character and numeric types, not `test_struct`");
let test_array = ctypes.ArrayType(test_struct);
assertTypeErrorMessage(() => test_array(10).value,
".value only works on character and numeric types, not `test_struct.array(10)`");
let test_pointer = ctypes.PointerType(test_struct);
assertTypeErrorMessage(() => test_pointer(10).value,
".value only works on character and numeric types, not `test_struct.ptr`");
}
if (typeof ctypes === "object")
test();

View File

@ -930,43 +930,3 @@ JS::CreateError(JSContext* cx, JSExnType type, HandleObject stack, HandleString
rval.setObject(*obj);
return true;
}
const char*
js::ValueToSourceForError(JSContext* cx, HandleValue val, JSAutoByteString& bytes)
{
if (val.isUndefined()) {
return "undefined";
}
if (val.isNull()) {
return "null";
}
RootedString str(cx, JS_ValueToSource(cx, val));
if (!str) {
JS_ClearPendingException(cx);
return "<<error converting value to string>>";
}
StringBuffer sb(cx);
if (val.isObject()) {
RootedObject valObj(cx, val.toObjectOrNull());
if (JS_IsArrayObject(cx, valObj)) {
sb.append("the array ");
} else if (JS_IsArrayBufferObject(valObj)) {
sb.append("the array buffer ");
} else if (JS_IsArrayBufferViewObject(valObj)) {
sb.append("the typed array ");
} else {
sb.append("the object ");
}
} else if (val.isNumber()) {
sb.append("the number ");
} else if (val.isString()) {
sb.append("the string ");
} else {
MOZ_ASSERT(val.isBoolean() || val.isSymbol());
return bytes.encodeLatin1(cx, str);
}
sb.append(str);
return bytes.encodeLatin1(cx, sb.finishString());
}

View File

@ -129,9 +129,6 @@ class AutoClearPendingException
}
};
extern const char*
ValueToSourceForError(JSContext* cx, HandleValue val, JSAutoByteString& bytes);
} // namespace js
#endif /* jsexn_h */

View File

@ -1166,7 +1166,7 @@ function run_char_tests(library, t, name, size, signed, limits) {
do_check_eq(s.constructor.length, literal.length + 1);
s = t.array(50)(literal);
do_check_eq(s.readString(), literal);
do_check_throws(function() { t.array(3)(literal); }, TypeError);
do_check_throws(function() { t.array(3)(literal); }, Error);
do_check_throws(function() { t.ptr(literal); }, TypeError);
let p = t.ptr(s);
@ -1258,7 +1258,7 @@ function run_char16_tests(library, t, name, limits) {
do_check_eq(s.constructor.length, literal.length + 1);
s = t.array(50)(literal);
do_check_eq(s.readString(), literal);
do_check_throws(function() { t.array(3)(literal); }, TypeError);
do_check_throws(function() { t.array(3)(literal); }, Error);
do_check_throws(function() { t.ptr(literal); }, TypeError);
let p = t.ptr(s);
@ -1587,25 +1587,25 @@ function run_StructType_tests() {
do_check_eq(s.b.b, s2.b.b);
// Test that structs can be set from an object using 'value'.
do_check_throws(function() { s.value; }, TypeError);
do_check_throws(function() { s.value; }, Error);
let s_init = { "a": 2, "b": { "a": 9, "b": 5 }, "c": 13 };
s.value = s_init;
do_check_eq(s.b.a, 9);
do_check_eq(s.c, 13);
do_check_throws(function() { s.value = 5; }, TypeError);
do_check_throws(function() { s.value = ctypes.int32_t(); }, TypeError);
do_check_throws(function() { s.value = {}; }, TypeError);
do_check_throws(function() { s.value = { "a": 2 }; }, TypeError);
do_check_throws(function() { s.value = {}; }, Error);
do_check_throws(function() { s.value = { "a": 2 }; }, Error);
do_check_throws(function() { s.value = { "a": 2, "b": 5, "c": 10 }; }, TypeError);
do_check_throws(function() {
s.value = { "5": 2, "b": { "a": 9, "b": 5 }, "c": 13 };
}, TypeError);
}, Error);
do_check_throws(function() {
s.value = { "a": 2, "b": { "a": 9, "b": 5 }, "c": 13, "d": 17 };
}, TypeError);
}, Error);
do_check_throws(function() {
s.value = { "a": 2, "b": { "a": 9, "b": 5, "e": 9 }, "c": 13 };
}, TypeError);
}, Error);
// Test that structs can be constructed similarly through ExplicitConvert,
// and that the single-field case is disambiguated correctly.
@ -1682,7 +1682,7 @@ function run_PointerType_tests() {
// Test ExplicitConvert.
let p = p_t();
do_check_throws(function() { p.value; }, TypeError);
do_check_throws(function() { p.value; }, Error);
do_check_eq(ptrValue(p), 0);
do_check_throws(function() { p.contents; }, Error);
do_check_throws(function() { p.contents = g; }, Error);
@ -1798,10 +1798,10 @@ function run_PointerType_tests() {
let array_type_too_large = item_type.array(number_of_items + 1);
let array_type_too_small = item_type.array(number_of_items - 1);
do_check_throws(function() { array_type_too_large(c_arraybuffer); }, TypeError);
do_check_throws(function() { array_type_too_small(c_arraybuffer); }, TypeError);
do_check_throws(function() { array_type_too_large(view); }, TypeError);
do_check_throws(function() { array_type_too_small(view); }, TypeError);
do_check_throws(function() { array_type_too_large(c_arraybuffer); }, Error);
do_check_throws(function() { array_type_too_small(c_arraybuffer); }, Error);
do_check_throws(function() { array_type_too_large(view); }, Error);
do_check_throws(function() { array_type_too_small(view); }, Error);
// Convert subarray of typed array to array of right size and check contents
c_array = array_type_too_small(view.subarray(1));
@ -1884,7 +1884,7 @@ function run_FunctionType_tests() {
// Test ExplicitConvert.
let f = fp_t();
do_check_throws(function() { f.value; }, TypeError);
do_check_throws(function() { f.value; }, Error);
do_check_eq(ptrValue(f), 0);
f = fp_t(5);
do_check_eq(ptrValue(f), 5);
@ -2067,11 +2067,11 @@ function run_ArrayType_tests() {
c.value = c;
do_check_eq(c[3], 4);
do_check_throws(function() { c.value; }, TypeError);
do_check_throws(function() { c.value = [1, 2, 3, 4, 5]; }, TypeError);
do_check_throws(function() { c.value = [1, 2, 3, 4, 5, 6, 7]; }, TypeError);
do_check_throws(function() { c.value; }, Error);
do_check_throws(function() { c.value = [1, 2, 3, 4, 5]; }, Error);
do_check_throws(function() { c.value = [1, 2, 3, 4, 5, 6, 7]; }, Error);
do_check_throws(function() { c.value = [1, 2, 7.4, 4, 5, 6]; }, TypeError);
do_check_throws(function() { c.value = []; }, TypeError);
do_check_throws(function() { c.value = []; }, Error);
}
function run_type_toString_tests() {