tor-browser

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

browser_rules_add-rule-csp.js (1231B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URI = `
      7 <!doctype html>
      8 <html>
      9  <head>
     10    <meta http-equiv="Content-Security-Policy" content="style-src 'none'">
     11  </head>
     12  <body>
     13    <div id="testid"></div>
     14  </body>
     15 </html>
     16 `;
     17 
     18 // Tests adding a new rule works on a page with CSP style-src none.
     19 add_task(async function () {
     20  await addTab(`data:text/html;charset=utf-8,${encodeURIComponent(TEST_URI)}`);
     21  const { inspector, view } = await openRuleView();
     22 
     23  info("Selecting the test node");
     24  await selectNode("#testid", inspector);
     25 
     26  info("Adding a new rule for this node and blurring the new selector field");
     27  await addNewRuleAndDismissEditor(inspector, view, "#testid", 1);
     28 
     29  info("Adding a new property for this rule");
     30  const ruleEditor = getRuleViewRuleEditor(view, 1);
     31 
     32  const onRuleViewChanged = view.once("ruleview-changed");
     33  ruleEditor.addProperty("color", "red", "", true);
     34  await onRuleViewChanged;
     35 
     36  const textProps = ruleEditor.rule.textProps;
     37  const prop = textProps[textProps.length - 1];
     38  is(prop.name, "color", "The last property name is color");
     39  is(prop.value, "red", "The last property value is red");
     40 });