diff options
Diffstat (limited to '')
-rw-r--r-- | devtools/shared/protocol/tests/xpcshell/test_protocol_invalid_response.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/shared/protocol/tests/xpcshell/test_protocol_invalid_response.js b/devtools/shared/protocol/tests/xpcshell/test_protocol_invalid_response.js new file mode 100644 index 0000000000..6b530f0a61 --- /dev/null +++ b/devtools/shared/protocol/tests/xpcshell/test_protocol_invalid_response.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const protocol = require("resource://devtools/shared/protocol.js"); +const { RetVal } = protocol; + +// Test invalid response specs throw when generating the Actor specification. + +// Test top level array response +add_task(async function () { + Assert.throws(() => { + protocol.generateActorSpec({ + typeName: "invalidArrayResponse", + methods: { + invalidMethod: { + response: RetVal("array:string"), + }, + }, + }); + }, /Arrays should be wrapped in objects/); + + protocol.generateActorSpec({ + typeName: "validArrayResponse", + methods: { + validMethod: { + response: { + someArray: RetVal("array:string"), + }, + }, + }, + }); + ok(true, "Arrays wrapped in object are valid response packets"); +}); + +// Test response with several placeholders +add_task(async function () { + Assert.throws(() => { + protocol.generateActorSpec({ + typeName: "tooManyPlaceholdersResponse", + methods: { + invalidMethod: { + response: { + prop1: RetVal("json"), + prop2: RetVal("json"), + }, + }, + }, + }); + }, /More than one RetVal specified in response/); +}); |