File: test_ext_tabs_groupId.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (53 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Default tab.groupId without tab groups</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
  <script type="text/javascript" src="head.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>

<script type="text/javascript">
"use strict";

// Full coverage for the tab.groupId field is provided by
// browser/components/extensions/test/browser/browser_ext_tabs_groupId.js,
// but that test only runs on desktop Firefox.
// This test runs on both desktop and mobile Firefox. Although tab groups are
// unsupported on mobile, tab.groupId can still have a meaningful value (-1).
add_task(async function default_groupId_value() {
  const extension = ExtensionTestUtils.loadExtension({
    async background() {
      const tab = await browser.tabs.create({});
      browser.test.assertEq(
        -1,
        tab.groupId,
        "tab.groupId defaults to -1 (TAB_GROUP_ID_NONE)"
      );
      let tabs = await browser.tabs.query({ groupId: -1 });
      browser.test.assertTrue(
        tabs.some(t => t.id === tab.id),
        "Found ungrouped tab with tabs.query({ groupId: -1})"
      );
      browser.test.assertDeepEq(
        [],
        await browser.tabs.query({ groupId: 123456789 }),
        "tabs.query() for non-existing groupId should return empty list"
      );
      await browser.tabs.remove(tab.id);
      browser.test.sendMessage("done");
    },
  });

  await extension.startup();
  await extension.awaitMessage("done");
  await extension.unload();
});

</script>

</body>
</html>