blob: 5b32dd0a392098b106057b84006c18a25f3d0db6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
const {types} = require("devtools/shared/protocol");
function run_test()
{
types.addType("test", {
read: (v) => { return "successful read: " + v; },
write: (v) => { return "successful write: " + v; }
});
// Verify the type registered correctly.
let type = types.getType("test");
let arrayType = types.getType("array:test");
do_check_eq(type.read("foo"), "successful read: foo");
do_check_eq(arrayType.read(["foo"])[0], "successful read: foo");
types.removeType("test");
do_check_eq(type.name, "DEFUNCT:test");
try {
types.getType("test");
do_check_true(false, "getType should fail");
} catch (ex) {
do_check_eq(ex.toString(), "Error: Unknown type: test");
}
try {
type.read("foo");
do_check_true(false, "type.read should have thrown an exception.");
} catch (ex) {
do_check_eq(ex.toString(), "Error: Using defunct type: test");
}
try {
arrayType.read(["foo"]);
do_check_true(false, "array:test.read should have thrown an exception.");
} catch (ex) {
do_check_eq(ex.toString(), "Error: Using defunct type: test");
}
}
|