tor-browser

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

browser_boxmodel_editablemodel_border.js (2164B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that editing the border value in the box model applies the border style
      7 
      8 const TEST_URI =
      9  "<style>" +
     10  "div { margin: 10px; padding: 3px }" +
     11  "#div1 { margin-top: 5px }" +
     12  "#div2 { border-bottom: 1em solid black; }" +
     13  "#div3 { padding: 2em; }" +
     14  "</style>" +
     15  "<div id='div1'></div><div id='div2'></div><div id='div3'></div>";
     16 
     17 add_task(async function () {
     18  const tab = await addTab("data:text/html," + encodeURIComponent(TEST_URI));
     19  const { inspector, boxmodel } = await openLayoutView();
     20 
     21  const browser = tab.linkedBrowser;
     22  is(
     23    await getStyle(browser, "#div1", "border-top-width"),
     24    "",
     25    "Should have the right border"
     26  );
     27  is(
     28    await getStyle(browser, "#div1", "border-top-style"),
     29    "",
     30    "Should have the right border"
     31  );
     32  await selectNode("#div1", inspector);
     33 
     34  const span = boxmodel.document.querySelector(
     35    ".boxmodel-border.boxmodel-top > span"
     36  );
     37  await waitForElementTextContent(span, "0");
     38 
     39  EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
     40  const editor = boxmodel.document.querySelector(
     41    ".styleinspector-propertyeditor"
     42  );
     43  ok(editor, "Should have opened the editor.");
     44  is(editor.value, "0", "Should have the right value in the editor.");
     45 
     46  EventUtils.synthesizeKey("1", {}, boxmodel.document.defaultView);
     47  await waitForUpdate(inspector);
     48 
     49  is(editor.value, "1", "Should have the right value in the editor.");
     50  is(
     51    await getStyle(browser, "#div1", "border-top-width"),
     52    "1px",
     53    "Should have the right border"
     54  );
     55  is(
     56    await getStyle(browser, "#div1", "border-top-style"),
     57    "solid",
     58    "Should have the right border"
     59  );
     60 
     61  EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
     62  await waitForUpdate(inspector);
     63 
     64  is(
     65    await getStyle(browser, "#div1", "border-top-width"),
     66    "",
     67    "Should be the right padding."
     68  );
     69  is(
     70    await getStyle(browser, "#div1", "border-top-style"),
     71    "",
     72    "Should have the right border"
     73  );
     74  await waitForElementTextContent(span, "0");
     75 });