Source code

Revision control

Other Tools

Test Info:

  • This test ran 178 times in the preceding 7 days with an average run time of 0.38 secs.
<meta charset="utf-8">
<title>Tabs create Test</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" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript">
"use strict";
add_task(async function test_query_index() {
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
background: function() {
browser.tabs.onCreated.addListener(async function({index, windowId, id}) {
() => browser.tabs.query({index: -1}),
/-1 is too small \(must be at least 0\)/,
"tab indices must be non-negative");
let tabs = await browser.tabs.query({index, windowId});
browser.test.assertEq(tabs.length, 1, `Got one tab at index ${index}`);
browser.test.assertEq(tabs[0].id, id, "The tab is the right one");
tabs = await browser.tabs.query({index: 1e5, windowId});
browser.test.assertEq(tabs.length, 0, "There is no tab at this index");
await extension.startup();
const win ="");
await extension.awaitFinish("tabs.query");
await extension.unload();