tor-browser

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

browser_rules_guessIndentation.js (1113B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that we can guess indentation from a style sheet, not just a
      7 // rule.
      8 
      9 // Use a weird indentation depth to avoid accidental success.
     10 const TEST_URI = `
     11  <style type='text/css'>
     12 div {
     13       background-color: blue;
     14 }
     15 
     16 * {
     17 }
     18 </style>
     19  <div id='testid' class='testclass'>Styled Node</div>
     20 `;
     21 
     22 const expectedText = `
     23 div {
     24       background-color: blue;
     25 }
     26 
     27 * {
     28       color: chartreuse;
     29 }
     30 `;
     31 
     32 add_task(async function () {
     33  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     34  const { toolbox, inspector, view } = await openRuleView();
     35  await selectNode("#testid", inspector);
     36 
     37  info("Add a new property in the rule-view");
     38  await addProperty(view, 2, "color", "chartreuse");
     39 
     40  info("Switch to the style-editor");
     41  const { UI } = await toolbox.selectTool("styleeditor");
     42 
     43  const styleEditor = await UI.editors[0].getSourceEditor();
     44  const text = styleEditor.sourceEditor.getText();
     45  is(text, expectedText, "style inspector changes are synced");
     46 });