diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html')
-rw-r--r-- | toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html b/toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html new file mode 100644 index 0000000000..ea5a9fc25c --- /dev/null +++ b/toolkit/content/tests/widgets/test_panel_list_in_xul_panel.html @@ -0,0 +1,87 @@ +<!DOCTYPE HTML> +<!-- Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ --> +<html> +<head> + <title>Test Panel List In XUL Panel</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="head.js"></script> + <link rel="stylesheet" href="chrome://global/skin/global.css" type="text/css"/> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> + +<div id="content"> + <button id="anchor-button">Open</button> + <panel-list id="panel-list"> + <panel-item>one</panel-item> + <panel-item>two</panel-item> + <panel-item>three</panel-item> + <panel-item>four</panel-item> + <panel-item>five</panel-item> + <panel-item>six</panel-item> + </panel-list> +</div> + +<pre id="test"> +<script class="testbody" type="application/javascript"> +const {BrowserTestUtils} = ChromeUtils.importESModule("resource://testing-common/BrowserTestUtils.sys.mjs"); +let xulPanel, anchorButton, panelList; + + +add_setup(function setup() { + // The HTML document parser doesn't let us put XUL elements in the markup, so + // we have to create the <xul:panel> programmatically with script. + let content = document.getElementById("content"); + xulPanel = document.createXULElement("panel"); + panelList = document.getElementById("panel-list"); + xulPanel.appendChild(panelList); + content.appendChild(xulPanel); + anchorButton = document.getElementById("anchor-button"); + anchorButton.addEventListener("click", e => panelList.toggle(e)); +}); + +add_task(async function testXULPanelOpenFromClicks() { + let xulPanelShown = BrowserTestUtils.waitForPopupEvent(xulPanel, "shown"); + let shown = BrowserTestUtils.waitForEvent(panelList, "shown"); + synthesizeMouseAtCenter(anchorButton, {}); + await shown; + await xulPanelShown; + + ok(panelList.hasAttribute("inxulpanel"), "Should have inxulpanel attribute set"); + + let style = window.getComputedStyle(panelList); + is(style.top, "0px", "computed top inline style should be 0px."); + is(style.left, "0px", "computed left inline style should be 0px."); + + let xulPanelHidden = BrowserTestUtils.waitForPopupEvent(xulPanel, "hidden"); + let hidden = BrowserTestUtils.waitForEvent(panelList, "hidden"); + synthesizeKey("Escape", {}); + await hidden; + await xulPanelHidden; +}); + +add_task(async function testXULPanelOpenProgrammatically() { + let xulPanelShown = BrowserTestUtils.waitForPopupEvent(xulPanel, "shown"); + let shown = BrowserTestUtils.waitForEvent(panelList, "shown"); + panelList.show(); + await shown; + await xulPanelShown; + + ok(panelList.hasAttribute("inxulpanel"), "Should have inxulpanel attribute set"); + let style = window.getComputedStyle(panelList); + is(style.top, "0px", "computed top inline style should be 0px."); + is(style.left, "0px", "computed left inline style should be 0px."); + + let xulPanelHidden = BrowserTestUtils.waitForPopupEvent(xulPanel, "hidden"); + let hidden = BrowserTestUtils.waitForEvent(panelList, "hidden"); + panelList.hide(); + await hidden; + await xulPanelHidden; +}); +</script> +</pre> +</body> +</html> |