tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_markup_events-windowed-host.js (1952B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 /*
      6 * Test that the event details tooltip can be hidden by clicking outside of the tooltip
      7 * after switching hosts.
      8 */
      9 
     10 const TEST_URL = URL_ROOT + "doc_markup_events-overflow.html";
     11 
     12 add_task(async function () {
     13  info(
     14    "Switch to 2 pane inspector to avoid sidebar width issues with opening events"
     15  );
     16  await pushPref("devtools.inspector.three-pane-enabled", false);
     17  const { inspector, toolbox } = await openInspectorForURL(TEST_URL);
     18  await runTests(inspector);
     19 
     20  await toolbox.switchHost("window");
     21 
     22  // Switching hosts is not correctly waiting when DevTools run in content frame
     23  // See Bug 1571421.
     24  await wait(1000);
     25 
     26  await runTests(inspector);
     27 
     28  await toolbox.switchHost("bottom");
     29 
     30  // Switching hosts is not correctly waiting when DevTools run in content frame
     31  // See Bug 1571421.
     32  await wait(1000);
     33 
     34  await runTests(inspector);
     35 
     36  await toolbox.destroy();
     37 });
     38 
     39 async function runTests(inspector) {
     40  const markupContainer = await getContainerForSelector("#events", inspector);
     41  const evHolder = markupContainer.elt.querySelector(
     42    ".inspector-badge.interactive[data-event]"
     43  );
     44  const tooltip = inspector.markup.eventDetailsTooltip;
     45 
     46  info("Clicking to open event tooltip.");
     47  const onTooltipShown = tooltip.once("shown");
     48  EventUtils.synthesizeMouseAtCenter(
     49    evHolder,
     50    {},
     51    inspector.markup.doc.defaultView
     52  );
     53  await onTooltipShown;
     54  ok(tooltip.isVisible(), "EventTooltip visible.");
     55 
     56  info("Click on another tag to hide the event tooltip");
     57  const onTooltipHidden = tooltip.once("hidden");
     58  const script = await getContainerForSelector("script", inspector);
     59  const tag = script.elt.querySelector(".tag");
     60  EventUtils.synthesizeMouseAtCenter(tag, {}, inspector.markup.doc.defaultView);
     61 
     62  await onTooltipHidden;
     63 
     64  ok(!tooltip.isVisible(), "EventTooltip hidden.");
     65 }