tor-browser

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

test_non_content_accessible_values.html (4330B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <style id="sheet"></style>
      5 <div></div>
      6 <script>
      7 const NON_CONTENT_ACCESSIBLE_VALUES = {
      8  "color": [
      9    "-moz-buttonactivetext",
     10    "-moz-buttonactiveface",
     11    "-moz-buttondisabledface",
     12    "-moz-disabledfield",
     13    "-moz-colheaderhovertext",
     14    "-moz-colheadertext",
     15    "-moz-nativevisitedhyperlinktext",
     16    "text-select-disabled-background",
     17    "text-select-attention-background",
     18    "text-select-attention-foreground",
     19    "-moz-autofill-background",
     20  ],
     21  "display": [
     22    "-moz-box",
     23    "-moz-inline-box",
     24  ],
     25  "font": [
     26      "-moz-pull-down-menu",
     27      "-moz-button",
     28      "-moz-list",
     29      "-moz-field",
     30  ],
     31  "-moz-appearance": [
     32    "button-arrow-down",
     33    "button-arrow-next",
     34    "button-arrow-previous",
     35    "button-arrow-up",
     36    "button-focus",
     37    "dualbutton",
     38    "groupbox",
     39    "menubar",
     40    "menuitem",
     41    "checkmenuitem",
     42    "radiomenuitem",
     43    "menuitemtext",
     44    "menupopup",
     45    "menucheckbox",
     46    "menuradio",
     47    "menuseparator",
     48    "menuimage",
     49    "-moz-menulist-arrow-button",
     50    "checkbox-container",
     51    "radio-container",
     52    "checkbox-label",
     53    "radio-label",
     54    "resizerpanel",
     55    "resizer",
     56    "scrollbar",
     57    "scrollbar-small",
     58    "scrollbar-horizontal",
     59    "scrollbar-vertical",
     60    "scrollbarbutton-up",
     61    "scrollbarbutton-down",
     62    "scrollbarbutton-left",
     63    "scrollbarbutton-right",
     64    "scrollcorner",
     65    "separator",
     66    "spinner",
     67    "spinner-upbutton",
     68    "spinner-downbutton",
     69    "spinner-textfield",
     70    "splitter",
     71    "statusbar",
     72    "statusbarpanel",
     73    "tab",
     74    "tabpanel",
     75    "tabpanels",
     76    "tab-scroll-arrow-back",
     77    "tab-scroll-arrow-forward",
     78    "toolbar",
     79    "toolbarbutton",
     80    "toolbarbutton-dropdown",
     81    "toolbargripper",
     82    "toolbox",
     83    "tooltip",
     84    "treeheader",
     85    "treeheadercell",
     86    "treeheadersortarrow",
     87    "treeitem",
     88    "treeline",
     89    "treetwisty",
     90    "treetwistyopen",
     91    "treeview",
     92    "window",
     93    "dialog",
     94    "-moz-win-communications-toolbox",
     95    "-moz-win-media-toolbox",
     96    "-moz-win-browsertabbar-toolbox",
     97    "-moz-win-borderless-glass",
     98    "-moz-win-exclude-glass",
     99    "-moz-mac-help-button",
    100    "-moz-window-button-box",
    101    "-moz-window-button-box-maximized",
    102    "-moz-window-button-close",
    103    "-moz-window-button-maximize",
    104    "-moz-window-button-minimize",
    105    "-moz-window-button-restore",
    106    "-moz-window-titlebar",
    107    "-moz-window-titlebar-maximized",
    108    "-moz-mac-active-source-list-selection",
    109    "-moz-mac-disclosure-button-closed",
    110    "-moz-mac-disclosure-button-open",
    111    "-moz-mac-source-list",
    112    "-moz-mac-source-list-selection",
    113 
    114    "button-bevel",
    115    "caret",
    116    "listitem",
    117    "menulist-textfield",
    118    "menulist-text",
    119  ],
    120  "user-select": [
    121    "-moz-text",
    122  ],
    123  "line-height": [
    124    "-moz-block-height",
    125  ],
    126  "text-align": [
    127    "-moz-center-or-inherit",
    128  ],
    129 };
    130 
    131 const sheet = document.getElementById("sheet");
    132 const div = document.querySelector("div");
    133 
    134 test(function() {
    135  sheet.textContent = `div { color: initial }`;
    136  assert_equals(sheet.sheet.cssRules[0].style.length, 1);
    137 }, "sanity");
    138 
    139 for (const prop in NON_CONTENT_ACCESSIBLE_VALUES) {
    140  const values = NON_CONTENT_ACCESSIBLE_VALUES[prop];
    141  test(function() {
    142    for (const value of values) {
    143      sheet.textContent = `div { ${prop}: ${value} }`;
    144      const block = sheet.sheet.cssRules[0].style;
    145      assert_equals(
    146        block.length,
    147        0,
    148        `${prop}: ${value} should not be parsed in content`
    149      );
    150      block.setProperty(prop, value);
    151      assert_equals(
    152        block.length,
    153        0,
    154        `${prop}: ${value} should not be settable via CSSOM in content`
    155      );
    156      div.style.setProperty(prop, value);
    157      assert_equals(
    158        div.style.length,
    159        0,
    160        `${prop}: ${value} should not be settable via CSSOM in content (inline style)`
    161      );
    162      assert_not_equals(
    163        getComputedStyle(div).getPropertyValue(prop),
    164        value,
    165        `${prop}: ${value} should not be settable via CSSOM in content (gcs)`
    166      );
    167 
    168      assert_false(CSS.supports(prop, value), `${prop}: ${value} should not claim to be supported`)
    169    }
    170  }, prop + " non-accessible values: " + values.join(", "))
    171 }
    172 </script>