tor-browser

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

file_fullscreen-single.html (2489B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 
      5 Open one window, focus it and enter fullscreen, then exit fullscreen.
      6 
      7 -->
      8 <head>
      9  <title>Simple Fullscreen Enter and Exit Test</title>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     12  <script type="application/javascript" src="file_fullscreen-utils.js"></script>
     13 </head>
     14 <body>
     15 
     16 <div id="fullscreen-div"><p>Fullscreen div</p></div>
     17 
     18 <script type="application/javascript">
     19 
     20 function ok(condition, msg) {
     21  opener.ok(condition, "[single] " + msg);
     22 }
     23 
     24 function is(value, expected, msg) {
     25  opener.is(value, expected, "[single] " + msg);
     26 }
     27 
     28 function isnot(value, unexpected, msg) {
     29  opener.isnot(value, unexpected, "[single] " + msg);
     30 }
     31 
     32 function info(msg) {
     33  opener.info("[single] " + msg);
     34 }
     35 
     36 function windowResized() {
     37  info(`Window resized to width: ${window.innerWidth}, height: ${window.innerHeight}.`);
     38 }
     39 
     40 async function begin() {
     41  window.addEventListener('resize', windowResized);
     42 
     43  info(`Starting window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
     44  let windowedWidth = window.innerWidth;
     45  let windowedHeight = window.innerHeight;
     46 
     47  info("Requesting fullscreen.");
     48  let entryPromise = document.getElementById('fullscreen-div').requestFullscreen()
     49  info("Fullscreen requested, waiting for promise to resolve.");
     50 
     51  await entryPromise;
     52 
     53  info("element.requestFullscreen() promise resolved.");
     54  info(`Fullscreen window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
     55  isnot(document.fullscreenElement, null, "document.fullscreenElement should exist.");
     56  ok(window.fullScreen, "window.fullScreen");
     57  isnot(windowedWidth, window.innerWidth, "window width should be changed.");
     58  isnot(windowedHeight, window.innerHeight, "window height should be changed.");
     59 
     60  info("Requesting fullscreen exit.");
     61  let exitPromise = document.exitFullscreen()
     62  info("Fullscreen exit requested, waiting for promise to resolve.");
     63 
     64  await exitPromise;
     65 
     66  info("document.exitFullscreen() promise resolved.");
     67  info(`Restored window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
     68  is(document.fullscreenElement, null, "document.fullscreenElement should be null.");
     69  ok(!window.fullScreen, "window.fullScreen should be false.");
     70  is(window.innerWidth, windowedWidth, "window width should be restored.");
     71  is(window.innerHeight, windowedHeight, "window height should be restored.");
     72  opener.nextTest();
     73 }
     74 
     75 </script>
     76 </pre>
     77 </body>
     78 </html>