summaryrefslogtreecommitdiffstats
path: root/remote/cdp/test/browser/target/browser_getTargets.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /remote/cdp/test/browser/target/browser_getTargets.js
parentInitial commit. (diff)
downloadfirefox-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 'remote/cdp/test/browser/target/browser_getTargets.js')
-rw-r--r--remote/cdp/test/browser/target/browser_getTargets.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/remote/cdp/test/browser/target/browser_getTargets.js b/remote/cdp/test/browser/target/browser_getTargets.js
new file mode 100644
index 0000000000..2669bb87a9
--- /dev/null
+++ b/remote/cdp/test/browser/target/browser_getTargets.js
@@ -0,0 +1,43 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const PAGE_TEST =
+ "https://example.com/browser/remote/cdp/test/browser/target/doc_test.html";
+
+add_task(
+ async function getTargetsDetails({ client }) {
+ const { Target, target } = client;
+
+ await loadURL(PAGE_TEST);
+
+ const { targetInfos } = await Target.getTargets();
+
+ Assert.equal(targetInfos.length, 1, "Got expected amount of targets");
+
+ const targetInfo = targetInfos[0];
+ is(targetInfo.id, target.id, "Got expected target id");
+ is(targetInfo.type, "page", "Got expected target type");
+ is(targetInfo.title, "Test Page", "Got expected target title");
+ is(targetInfo.url, PAGE_TEST, "Got expected target URL");
+ },
+ { createTab: false }
+);
+
+add_task(
+ async function getTargetsCount({ client }) {
+ const { Target, target } = client;
+ const { targetInfo: newTabTargetInfo } = await openTab(Target);
+
+ await loadURL(PAGE_TEST);
+
+ const { targetInfos } = await Target.getTargets();
+
+ Assert.equal(targetInfos.length, 2, "Got expected amount of targets");
+ const targetIds = targetInfos.map(info => info.id);
+ ok(targetIds.includes(target.id), "Got expected original target id");
+ ok(targetIds.includes(newTabTargetInfo.id), "Got expected new target id");
+ },
+ { createTab: false }
+);