summaryrefslogtreecommitdiffstats
path: root/remote/test/browser/target/browser_getTargets.js
diff options
context:
space:
mode:
Diffstat (limited to 'remote/test/browser/target/browser_getTargets.js')
-rw-r--r--remote/test/browser/target/browser_getTargets.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/remote/test/browser/target/browser_getTargets.js b/remote/test/browser/target/browser_getTargets.js
new file mode 100644
index 0000000000..a867a0d18d
--- /dev/null
+++ b/remote/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 =
+ "http://example.com/browser/remote/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 }
+);