diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js')
-rw-r--r-- | devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js b/devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js new file mode 100644 index 0000000000..060a1743b1 --- /dev/null +++ b/devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js @@ -0,0 +1,41 @@ +"use strict"; + +const { types } = require("resource://devtools/shared/protocol.js"); + +function run_test() { + types.addType("test", { + read: v => "successful read: " + v, + write: v => "successful write: " + v, + }); + + // Verify the type registered correctly. + + const type = types.getType("test"); + const arrayType = types.getType("array:test"); + Assert.equal(type.read("foo"), "successful read: foo"); + Assert.equal(arrayType.read(["foo"])[0], "successful read: foo"); + + types.removeType("test"); + + Assert.equal(type.name, "DEFUNCT:test"); + try { + types.getType("test"); + Assert.ok(false, "getType should fail"); + } catch (ex) { + Assert.equal(ex.toString(), "Error: Unknown type: test"); + } + + try { + type.read("foo"); + Assert.ok(false, "type.read should have thrown an exception."); + } catch (ex) { + Assert.equal(ex.toString(), "Error: Using defunct type: test"); + } + + try { + arrayType.read(["foo"]); + Assert.ok(false, "array:test.read should have thrown an exception."); + } catch (ex) { + Assert.equal(ex.toString(), "Error: Using defunct type: test"); + } +} |