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 --- .../browser/browser_ext_sidebarAction_incognito.js | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js (limited to 'browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js') diff --git a/browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js b/browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js new file mode 100644 index 0000000000..221447cf2e --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_incognito.js @@ -0,0 +1,139 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +add_task(async function test_sidebarAction_not_allowed() { + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + sidebar_action: { + default_panel: "sidebar.html", + }, + }, + background() { + browser.test.onMessage.addListener(async pbw => { + await browser.test.assertRejects( + browser.sidebarAction.setTitle({ + windowId: pbw.windowId, + title: "test", + }), + /Invalid window ID/, + "should not be able to set title with windowId" + ); + await browser.test.assertRejects( + browser.sidebarAction.setTitle({ + tabId: pbw.tabId, + title: "test", + }), + /Invalid tab ID/, + "should not be able to set title" + ); + await browser.test.assertRejects( + browser.sidebarAction.getTitle({ + windowId: pbw.windowId, + }), + /Invalid window ID/, + "should not be able to get title with windowId" + ); + await browser.test.assertRejects( + browser.sidebarAction.getTitle({ + tabId: pbw.tabId, + }), + /Invalid tab ID/, + "should not be able to get title with tabId" + ); + + await browser.test.assertRejects( + browser.sidebarAction.setIcon({ + windowId: pbw.windowId, + path: "test", + }), + /Invalid window ID/, + "should not be able to set icon with windowId" + ); + await browser.test.assertRejects( + browser.sidebarAction.setIcon({ + tabId: pbw.tabId, + path: "test", + }), + /Invalid tab ID/, + "should not be able to set icon with tabId" + ); + + await browser.test.assertRejects( + browser.sidebarAction.setPanel({ + windowId: pbw.windowId, + panel: "test", + }), + /Invalid window ID/, + "should not be able to set panel with windowId" + ); + await browser.test.assertRejects( + browser.sidebarAction.setPanel({ + tabId: pbw.tabId, + panel: "test", + }), + /Invalid tab ID/, + "should not be able to set panel with tabId" + ); + await browser.test.assertRejects( + browser.sidebarAction.getPanel({ + windowId: pbw.windowId, + }), + /Invalid window ID/, + "should not be able to get panel with windowId" + ); + await browser.test.assertRejects( + browser.sidebarAction.getPanel({ + tabId: pbw.tabId, + }), + /Invalid tab ID/, + "should not be able to get panel with tabId" + ); + + await browser.test.assertRejects( + browser.sidebarAction.isOpen({ + windowId: pbw.windowId, + }), + /Invalid window ID/, + "should not be able to determine openness with windowId" + ); + + browser.test.notifyPass("pass"); + }); + }, + files: { + "sidebar.html": ` + + + + + + + A Test Sidebar + + + `, + + "sidebar.js": function () { + window.onload = () => { + browser.test.sendMessage("sidebar"); + }; + }, + }, + }); + + await extension.startup(); + let sidebarID = `${makeWidgetId(extension.id)}-sidebar-action`; + ok(SidebarUI.sidebars.has(sidebarID), "sidebar exists in non-private window"); + + let winData = await getIncognitoWindow(); + + let hasSidebar = winData.win.SidebarUI.sidebars.has(sidebarID); + ok(!hasSidebar, "sidebar does not exist in private window"); + // Test API access to private window data. + extension.sendMessage(winData.details); + await extension.awaitFinish("pass"); + + await BrowserTestUtils.closeWindow(winData.win); + await extension.unload(); +}); -- cgit v1.2.3