tor-browser

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

test_bug1730284.html (2198B)


      1 <!DOCTYPE HTML>
      2 <meta charset="utf-8">
      3 <title>Test for bug 1730284 (throttling of same-origin iframes)</title>
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
      6 <style>
      7  iframe {
      8    width: 10px;
      9    height: 10px;
     10  }
     11  .display-none {
     12    display: none;
     13  }
     14  .vis-hidden {
     15    visibility: hidden
     16  }
     17  .transparent {
     18    opacity: 0;
     19  }
     20  .zero-size {
     21    width: 0;
     22    height: 0;
     23    border: 0;
     24  }
     25  .offscreen {
     26    position: absolute;
     27    top: 500%;
     28  }
     29  .scroller {
     30    height: 100px;
     31    overflow: auto;
     32  }
     33  .scroller-padding {
     34    height: 800px;
     35  }
     36 </style>
     37 <iframe class="visible"></iframe>
     38 <iframe class="display-none" data-throttled-expected></iframe>
     39 <iframe class="vis-hidden" data-throttled-expected></iframe>
     40 <iframe class="transparent"></iframe>
     41 <iframe class="zero-size"></iframe>
     42 <div class="scroller">
     43  <div class="scroller-padding"></div>
     44  <iframe class="scrolled-out-of-view" data-throttled-expected></iframe>
     45 </div>
     46 <iframe class="offscreen" data-throttled-expected></iframe>
     47 <iframe class="offscreen zero-size" data-throttled-expected></iframe>
     48 <iframe class="offscreen vis-hidden" data-throttled-expected></iframe>
     49 <iframe class="offscreen transparent" data-throttled-expected></iframe>
     50 <script>
     51 async function assertThrottled(win, shouldThrottle, msg) {
     52  if (isXOrigin) {
     53    // In XOrigin mode we need to depend as well on the main process having
     54    // painted the cross-origin iframe at least once for coordinates to be
     55    // correct.
     56    await SimpleTest.promiseWaitForCondition(() => {
     57      return SpecialPowers.getDOMWindowUtils(win).effectivelyThrottlesFrameRequests == shouldThrottle;
     58    }, msg);
     59  }
     60  is(SpecialPowers.getDOMWindowUtils(win).effectivelyThrottlesFrameRequests, shouldThrottle, msg);
     61 }
     62 
     63 add_task(async function() {
     64  await SimpleTest.promiseFocus(window);
     65  await assertThrottled(window, false, "Should not be throttling main page");
     66  for (let frame of document.querySelectorAll("iframe")) {
     67    let shouldThrottle = frame.getAttribute("data-throttled-expected") !== null;
     68    await assertThrottled(frame.contentWindow, shouldThrottle, frame.className);
     69  }
     70 });
     71 </script>