tor-browser

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

test_sheet_privilege.html (1073B)


      1 <!doctype html>
      2 <title>Test whether it can access a filed in MediaList with normal privilege after accessing with chrome privilege.</title>
      3 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      4 
      5 <style>
      6 @media screen and (max-width: 800px) {
      7  body {
      8    background-color: lime;
      9  }
     10 }
     11 </style>
     12 <script>
     13 "use strict";
     14 
     15 function assertMediaText(rule, description) {
     16  is(rule.media.mediaText, "screen and (max-width: 800px)", description);
     17 }
     18 
     19 add_task(function testCssRuleMedia() {
     20  assertMediaText(SpecialPowers.wrap(document).styleSheets[0].cssRules[0], "privileged document");
     21  assertMediaText(document.styleSheets[0].cssRules[0], "unprivileged document");
     22 });
     23 
     24 add_task(function testSheetFromCache() {
     25  for (let i = 0; i < 2; ++i) {
     26    const style = document.createElement("style");
     27    style.textContent = `@media screen and (max-width: 800px) {}`;
     28    document.head.append(style);
     29    assertMediaText(SpecialPowers.wrap(style).sheet.cssRules[0], "privileged sheet " + i);
     30    assertMediaText(style.sheet.cssRules[0], "unprivileged sheet " + i);
     31  }
     32 });
     33 </script>