From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/browser_ext_tabs_attention.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 browser/components/extensions/test/browser/browser_ext_tabs_attention.js (limited to 'browser/components/extensions/test/browser/browser_ext_tabs_attention.js') diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_attention.js b/browser/components/extensions/test/browser/browser_ext_tabs_attention.js new file mode 100644 index 0000000000..0f267460f3 --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_tabs_attention.js @@ -0,0 +1,64 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +add_task(async function tabsAttention() { + let tab1 = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "http://example.com/?2", + true + ); + let tab2 = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "http://example.com/?1", + true + ); + gBrowser.selectedTab = tab2; + + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + permissions: ["tabs", "http://example.com/*"], + }, + + background: async function () { + function onActive(tabId, changeInfo, tab) { + browser.test.assertFalse( + changeInfo.attention, + "changeInfo.attention should be false" + ); + browser.test.assertFalse( + tab.attention, + "tab.attention should be false" + ); + browser.test.assertTrue(tab.active, "tab.active should be true"); + browser.test.notifyPass("tabsAttention"); + } + + function onUpdated(tabId, changeInfo, tab) { + browser.test.assertTrue( + changeInfo.attention, + "changeInfo.attention should be true" + ); + browser.test.assertTrue(tab.attention, "tab.attention should be true"); + browser.tabs.onUpdated.removeListener(onUpdated); + browser.tabs.onUpdated.addListener(onActive); + browser.tabs.update(tabId, { active: true }); + } + + browser.tabs.onUpdated.addListener(onUpdated, { + properties: ["attention"], + }); + const tabs = await browser.tabs.query({ index: 1 }); + browser.tabs.executeScript(tabs[0].id, { + code: `alert("tab attention")`, + }); + }, + }); + + await extension.startup(); + await extension.awaitFinish("tabsAttention"); + await extension.unload(); + + BrowserTestUtils.removeTab(tab1); + BrowserTestUtils.removeTab(tab2); +}); -- cgit v1.2.3