tor-browser

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

149.html (1911B)


      1 <!DOCTYPE html>
      2 <html><head>
      3  <title>scheduler: event/for attribute on script</title>
      4  <script src="/resources/testharness.js"></script>
      5  <script src="/resources/testharnessreport.js"></script>
      6  <script src="testlib/testlib.js"></script>
      7 </head>
      8 <body>
      9 <div id="log"></div>
     10 <script>
     11 
     12 attributes = [
     13  {for:"window", event:"onload()", expect:true},
     14  {for:"window", event:"onload", expect:true},
     15  {for:"  WINdow\t\n", event:"ONload\t\n", expect:true},
     16  {for:"window", event:"load", expect:false},
     17  {for:"window", event:"onpageshow", expect:false},
     18  {for:"document", event:"onload", expect:false},
     19 ]
     20 
     21 function test_maker(array_name) {
     22  return function(x, i) {
     23    var title = "for='" + x.for + "' event='" + x.event + "' " + array_name.replace("_", " ") + " " + (x.expect ? "executes immediately" : "does not execute");
     24    script_content = "var d =" + array_name + "[" + i  + "];"
     25    script_content += x.expect?"d[1].step(function() {d[3] = true});":"d[1].step(function() {assert_unreached()});"
     26    return [x, async_test(title), script_content, false];
     27  }
     28 }
     29 
     30 parser_inserted = attributes.map(test_maker("parser_inserted"));
     31 dom_inserted = attributes.map(test_maker("dom_inserted"));
     32 
     33 parser_inserted.forEach(function(x) {
     34  var d = x[0];
     35  document.write("<script for='" + d.for + "' event='" + d.event + "'>" + x[2] + "<\/script>");
     36 });
     37 
     38 dom_inserted.forEach(function(x) {
     39  var d = x[0];
     40  var s = document.createElement("script");
     41  s.setAttribute("event", d.event);
     42  s.setAttribute("for", d.for);
     43  s.textContent = x[2];
     44  document.body.appendChild(s);
     45 });
     46 </script>
     47 
     48 <script>
     49 var all_tests = parser_inserted.concat(dom_inserted);
     50 
     51 all_tests.filter(function(x) {return x[0]["expect"]}).forEach(function(x) {var t = x[1]; t.step(function() {assert_true(x[3])});})
     52 
     53 onload = function() {
     54  all_tests.forEach(function(x) {var t = x[1]; t.step(function() {t.done()})});
     55 }
     56 </script>
     57 
     58 </body>
     59 </html>