tor-browser

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

browser_application_xml_handle_internally.js (1633B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const HandlerService = Cc[
      5  "@mozilla.org/uriloader/handler-service;1"
      6 ].getService(Ci.nsIHandlerService);
      7 
      8 const MIMEService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
      9 
     10 // This test checks that application/xml has the handle internally option.
     11 add_task(async function applicationXmlHandleInternally() {
     12  const mimeInfo = MIMEService.getFromTypeAndExtension(
     13    "application/xml",
     14    "xml"
     15  );
     16  HandlerService.store(mimeInfo);
     17  registerCleanupFunction(() => {
     18    HandlerService.remove(mimeInfo);
     19  });
     20 
     21  await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
     22 
     23  let win = gBrowser.selectedBrowser.contentWindow;
     24 
     25  let container = win.document.getElementById("handlersView");
     26 
     27  // First, find the application/xml item.
     28  let xmlItem = container.querySelector("richlistitem[type='application/xml']");
     29  Assert.ok(xmlItem, "application/xml is present in handlersView");
     30  if (xmlItem) {
     31    xmlItem.scrollIntoView({ block: "center" });
     32    xmlItem.closest("richlistbox").selectItem(xmlItem);
     33 
     34    // Open its menu
     35    let list = xmlItem.querySelector(".actionsMenu");
     36    let popup = list.menupopup;
     37    let popupShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
     38    EventUtils.synthesizeMouseAtCenter(list, {}, win);
     39    await popupShown;
     40 
     41    let handleInternallyItem = list.querySelector(
     42      `menuitem[action='${Ci.nsIHandlerInfo.handleInternally}']`
     43    );
     44 
     45    ok(!!handleInternallyItem, "handle internally is present");
     46  }
     47 
     48  gBrowser.removeCurrentTab();
     49 });