tor-browser

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

desktop-mode.html (2249B)


      1 <!DOCTYPE html>
      2 <html class="reftest-wait">
      3 <style>
      4 html {
      5  height: 100%;
      6  width: 100%;
      7 }
      8 body {
      9  height: 2000px;
     10  width: 200%;
     11  margin: 0px;
     12  padding: 0px;
     13 }
     14 div {
     15  width: 20px;
     16  height: 100%;
     17  top: 0px;
     18  background-color: green;
     19 }
     20 </style>
     21 <div style="right: 0px;  position: fixed;"></div>
     22 <div style="right: 25px; position: absolute;"></div>
     23 <script>
     24 async function go() {
     25  let win = SpecialPowers.wrap(window);
     26  let origVal = await SpecialPowers.spawnChrome([win.browsingContext.id],
     27                                                id => {
     28    // We enable 'forceDesktopViewport' (which is otherwise off-by-default)
     29    // and we test our rendering under that condition.  It's important that we
     30    // are followed by reftest "desktop-mode-cleanup.html" which will revert
     31    // this change for us, so that forceDesktopViewport doesn't remain on for
     32    // subsequent tests.
     33    let ctx = BrowsingContext.get(id);
     34    let origVal = ctx.forceDesktopViewport;
     35    ctx.forceDesktopViewport = true;
     36    return origVal;
     37  });
     38 
     39  if (origVal) {
     40    // UNEXPECTED: if we get here, then forceDesktopViewport was somehow
     41    // true already (when it should be at its default 'false')! Either we've
     42    // got the wrong assumption about the default value, or some earlier test
     43    // enabled it and forgot to clean up after themselves.
     44    //
     45    // NOTE: We could signal a test-failure in this circumstance,
     46    // by e.g. setting the background to red...
     47    //   document.body.style.background = "red";
     48    // ...but that also makes this test trivially fail in 'test-verify' runs
     49    // per bug 1915025 comment 17 through 19, so let's not do that for now.
     50    // So for now, we handle this unexpected condition silently/gracefully.
     51    // I'm leaving this (no-op) if-check in the test in case it's useful
     52    // for debugging/logging at some point, though.
     53  }
     54 
     55  // Force a reflow to make sure the forceDesktopViewport flag is
     56  // picked up.
     57  document.documentElement.style.display = "none";
     58  document.documentElement.getBoundingClientRect();
     59  document.documentElement.style.display = "block";
     60  document.documentElement.getBoundingClientRect();
     61 
     62  document.documentElement.classList.remove('reftest-wait');
     63 }
     64 
     65 go();
     66 </script>
     67 </html>