diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /remote/cdp/test/browser/dom/browser_resolveNode.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream/124.0.1.tar.xz firefox-upstream/124.0.1.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/cdp/test/browser/dom/browser_resolveNode.js')
-rw-r--r-- | remote/cdp/test/browser/dom/browser_resolveNode.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/remote/cdp/test/browser/dom/browser_resolveNode.js b/remote/cdp/test/browser/dom/browser_resolveNode.js new file mode 100644 index 0000000000..759c4ee76c --- /dev/null +++ b/remote/cdp/test/browser/dom/browser_resolveNode.js @@ -0,0 +1,79 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function backendNodeIdInvalidTypes({ client }) { + const { DOM } = client; + + for (const backendNodeId of [null, true, "foo", [], {}]) { + await Assert.rejects( + DOM.resolveNode({ backendNodeId }), + /backendNodeId: number value expected/, + `Fails for invalid type: ${backendNodeId}` + ); + } +}); + +add_task(async function backendNodeIdInvalidValue({ client }) { + const { DOM } = client; + + await Assert.rejects( + DOM.resolveNode({ backendNodeId: -1 }), + /No node with given id found/, + "Fails for unknown backendNodeId" + ); +}); + +add_task(async function backendNodeIdResultProperties({ client }) { + const { DOM, Runtime } = client; + + await Runtime.enable(); + const { result } = await Runtime.evaluate({ expression: "document" }); + const { node } = await DOM.describeNode({ objectId: result.objectId }); + + const { object } = await DOM.resolveNode({ + backendNodeId: node.backendNodeId, + }); + + ok(!!object, "Javascript node object returned"); + is(object.type, result.type, "Expected type returned"); + is(object.subtype, result.subtype, "Expected subtype returned"); + isnot(object.objectId, result.objectId, "Object has been duplicated"); +}); + +add_task(async function executionContextIdInvalidTypes({ client }) { + const { DOM, Runtime } = client; + + await Runtime.enable(); + const { result } = await Runtime.evaluate({ expression: "document" }); + const { node } = await DOM.describeNode({ objectId: result.objectId }); + + for (const executionContextId of [null, true, "foo", [], {}]) { + await Assert.rejects( + DOM.resolveNode({ + backendNodeId: node.backendNodeId, + executionContextId, + }), + /executionContextId: integer value expected/, + `Fails for invalid type: ${executionContextId}` + ); + } +}); + +add_task(async function executionContextIdInvalidValue({ client }) { + const { DOM, Runtime } = client; + + await Runtime.enable(); + const { result } = await Runtime.evaluate({ expression: "document" }); + const { node } = await DOM.describeNode({ objectId: result.objectId }); + + await Assert.rejects( + DOM.resolveNode({ + backendNodeId: node.backendNodeId, + executionContextId: -1, + }), + /Node with given id does not belong to the document/, + "Fails for unknown executionContextId" + ); +}); |