1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * Tests if selecting a tab in a tab bar makes it visible
9 add_task(async
function () {
10 Services
.prefs
.clearUserPref(
11 "devtools.netmonitor.panes-network-details-width"
14 const { tab
, monitor
} = await
initNetMonitor(SIMPLE_URL
, {
17 info("Starting test... ");
19 const { document
, store
, windowRequire
} = monitor
.panelWin
;
20 const topMostDocument
= DevToolsUtils
.getTopWindow(
23 const Actions
= windowRequire("devtools/client/netmonitor/src/actions/index");
25 const networkEvent
= waitForNetworkEvents(monitor
, 1);
26 tab
.linkedBrowser
.reload();
29 store
.dispatch(Actions
.toggleNetworkDetails());
31 const splitter
= document
.querySelector(".splitter");
33 await EventUtils
.synthesizeMouse(
37 { type
: "mousedown" },
40 await EventUtils
.synthesizeMouse(
44 { type
: "mousemove" },
47 await EventUtils
.synthesizeMouse(
55 await
waitUntil(() => document
.querySelector(".all-tabs-menu"));
56 const allTabsMenu
= document
.querySelector(".all-tabs-menu");
57 const panelsWidth
= document
.querySelector(".tabs-menu").offsetWidth
;
59 const selectTabFromTabsMenuButton
= async id
=> {
60 EventUtils
.sendMouseEvent({ type
: "click" }, allTabsMenu
);
61 const tabMenuElement
= topMostDocument
.querySelector(
62 `#devtools-sidebar-${id}`
64 if (tabMenuElement
!= null) {
65 tabMenuElement
.click();
66 // The tab should be visible within the panel
67 const tabLi
= document
.querySelector(`#${id}-tab`).parentElement
;
69 tabLi
.parentElement
.scrollLeft
+ tabLi
.parentElement
.offsetLeft
;
71 tabLi
.offsetLeft
>= ulScrollPos
&&
72 tabLi
.offsetLeft
+ tabLi
.offsetWidth
<= panelsWidth
+ ulScrollPos
,
73 `The ${id} tab is visible`
86 await
selectTabFromTabsMenuButton(elem
);
89 await
teardown(monitor
);