tor-browser

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

test_sanitySimpletest.html (3402B)


      1 <!--This test should be updated each time new functionality is added to SimpleTest-->
      2 <!DOCTYPE HTML>
      3 <html>
      4 <head>
      5  <title>Profiling test suite for SimpleTest</title>
      6  <script type="text/javascript">
      7  var start = new Date();
      8  </script>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11  <script type="text/javascript">
     12  var loadTime = new Date();
     13  </script>
     14 </head>
     15 <body>
     16 <input id="textB"/>
     17 <script class="testbody" type="text/javascript">
     18 info("Profile::SimpleTestLoadTime: " + (loadTime - start));
     19 var startTime = new Date();
     20 SimpleTest.waitForExplicitFinish();
     21 function starttest() {
     22  SimpleTest.waitForFocus(
     23    function() {
     24      //test log
     25      info("Logging some info")
     26 
     27      //basic usage
     28      ok(true, "test ok");
     29      SimpleTest.record(true, "test ok", "diagnostic information");
     30      is(0, 0, "is() test failed");
     31      isnot(0, 1, "isnot() test failed");
     32 
     33      //todo tests
     34      todo(false, "test todo", "todo() test should not pass");
     35      todo_is(false, true, "test todo_is");
     36      todo_isnot(true, true, "test todo_isnot");
     37 
     38      //misc
     39      SimpleTest.requestLongerTimeout(1);
     40 
     41      //note: this test may alter runtimes as it waits
     42      var check = false;
     43      $('textB').focus();
     44      SimpleTest.waitForClipboard("a",
     45        function () {
     46          SpecialPowers.clipboardCopyString("a");
     47        },
     48        function () {
     49          check = true;
     50          is(check, true, "waitForClipboard should work");
     51          manipulateElements();
     52        },
     53        function () {
     54          check = false;
     55          is(check, false, "waitForClipboard should work");
     56          manipulateElements();
     57        }
     58      );
     59 
     60      //use helper functions
     61      function manipulateElements()
     62      {
     63        var div1 = createEl('div', {'id': 'somediv', 'display': 'block'}, "I am a div");
     64        document.body.appendChild(div1);
     65        var divObj = this.getElement('somediv');
     66        is(divObj, div1, 'createEl did not create element as expected');
     67        is($('somediv'), divObj, '$ helper did not get element as expected');
     68        is(computedStyle(divObj, 'display'), 'block', 'computedStyle did not get right display value');
     69        document.body.removeChild(div1);
     70 
     71        /* note: expectChildProcessCrash is not being tested here, as it causes wildly variable
     72         * run times. It is currently being tested in:
     73         *  dom/plugins/test/test_hanging.html and dom/plugins/test/test_crashing.html
     74         */
     75 
     76        //note: this also adds a short wait period
     77        SimpleTest.executeSoon(
     78          function () {
     79            //finish() calls a slew of SimpleTest functions
     80            SimpleTest.finish();
     81            //call this after finish so we can make sure it works and doesn't hang our process
     82            var endTime = new Date();
     83            info("Profile::SimpleTestRunTime: " + (endTime-startTime));
     84            //expect and throw exception here. Otherwise, any code that follows the throw call will never be executed
     85            SimpleTest.expectUncaughtException();
     86            //make sure we catch this error
     87            // eslint-disable-next-line no-throw-literal
     88            throw "i am an uncaught exception"
     89          }
     90        );
     91      }
     92    }
     93  );
     94 };
     95 //use addLoadEvent
     96 addLoadEvent(
     97  function() {
     98    starttest();
     99  }
    100 );
    101 </script>
    102 </body>
    103 </html>