tor-browser

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

browser_rules_class_panel_edit.js (1974B)


      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 classes can be toggled in the class panel
      7 
      8 add_task(async function () {
      9  await addTab("data:text/html;charset=utf-8,<body class='class1 class2'>");
     10  const { view } = await openRuleView();
     11 
     12  info("Open the class panel");
     13  view.showClassPanel();
     14 
     15  info(
     16    "Click on class1 and check that the checkbox is unchecked and the DOM is updated"
     17  );
     18  await toggleClassPanelCheckBox(view, "class1");
     19  checkClassPanelContent(view, [
     20    { name: "class1", state: false },
     21    { name: "class2", state: true },
     22  ]);
     23  let newClassName = await getContentPageElementAttribute("body", "class");
     24  is(newClassName, "class2", "The class attribute has been updated in the DOM");
     25 
     26  info("Click on class2 and check the same thing");
     27  await toggleClassPanelCheckBox(view, "class2");
     28  checkClassPanelContent(view, [
     29    { name: "class1", state: false },
     30    { name: "class2", state: false },
     31  ]);
     32  newClassName = await getContentPageElementAttribute("body", "class");
     33  is(newClassName, "", "The class attribute has been updated in the DOM");
     34 
     35  info("Click on class2 and checks that the class is added again");
     36  await toggleClassPanelCheckBox(view, "class2");
     37  checkClassPanelContent(view, [
     38    { name: "class1", state: false },
     39    { name: "class2", state: true },
     40  ]);
     41  newClassName = await getContentPageElementAttribute("body", "class");
     42  is(newClassName, "class2", "The class attribute has been updated in the DOM");
     43 
     44  info("And finally, click on class1 again and checks it is added again");
     45  await toggleClassPanelCheckBox(view, "class1");
     46  checkClassPanelContent(view, [
     47    { name: "class1", state: true },
     48    { name: "class2", state: true },
     49  ]);
     50  newClassName = await getContentPageElementAttribute("body", "class");
     51  is(
     52    newClassName,
     53    "class1 class2",
     54    "The class attribute has been updated in the DOM"
     55  );
     56 });