tor-browser

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

inuse-manual.html (3644B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <title>Check for Dpub Vocabulary Role Usage</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8 setup({explicit_timeout: true, explicit_done: true });
      9 
     10 var theRoles = [
     11  "doc-abstract",
     12  "doc-acknowledgments",
     13  "doc-afterword",
     14  "doc-appendix",
     15  "doc-backlink",
     16  "doc-biblioentry",
     17  "doc-bibliography",
     18  "doc-biblioref",
     19  "doc-chapter",
     20  "doc-colophon",
     21  "doc-conclusion",
     22  "doc-cover",
     23  "doc-credit",
     24  "doc-credits",
     25  "doc-dedication",
     26  "doc-endnote",
     27  "doc-endnotes",
     28  "doc-epigraph",
     29  "doc-epilogue",
     30  "doc-errata",
     31  "doc-example",
     32  "doc-footnote",
     33  "doc-foreword",
     34  "doc-glossary",
     35  "doc-glossref",
     36  "doc-index",
     37  "doc-introduction",
     38  "doc-noteref",
     39  "doc-notice",
     40  "doc-pagebreak",
     41  "doc-pagelist",
     42  "doc-part",
     43  "doc-preface",
     44  "doc-prologue",
     45  "doc-pullquote",
     46  "doc-qna",
     47  "doc-subtitle",
     48  "doc-tip",
     49  "doc-toc"
     50  ];
     51 
     52  /* runTests - run tests against the content
     53   *
     54   * @param content - a string with the content to test
     55   */
     56  function runTests(content) {
     57    'use strict';
     58    // keep track of the test number executed
     59    var testCounter = 1;
     60    // create a DOM tree for the content
     61    var theDOM = document.createElement("body");
     62 
     63    // check the content - if it has a body element, strip up to it and after the
     64    // close
     65 
     66    content = content.replace(/\n/g, " ");
     67 
     68    if (content.search(/<body/i) !== -1) {
     69      // there is an opening body tag
     70      content = content.replace(/^.*<body[^>]*>/i, '');
     71      if (content.search(/<\/[^>]*body/i) !== -1) {
     72        content = content.replace(/<\/[^>]*body.*$/i, '');
     73      }
     74    }
     75 
     76    var parseFail = false ;
     77    var parseMessage  = "" ;
     78 
     79    if ("" === content || content.search(/^ +$/) !== -1 ) {
     80      // there is NO content
     81      parseFail = true;
     82      parseMessage = "Content is empty";
     83    } else {
     84      try {
     85        // add the content into the created body element
     86        theDOM.innerHTML = content;
     87      }
     88      catch(err) {
     89        parseFail = true;
     90        parseMessage =  err;
     91      }
     92    }
     93 
     94    test(function() {
     95      assert_false(parseFail, parseMessage);
     96    }, testCounter + " Can parse submitted content");
     97 
     98    testCounter += 1;
     99 
    100    // loop over the tree looking for roles with the values in theRoles
    101 
    102    theRoles.forEach(function(role) {
    103      var tName = testCounter + " " + "Uses role " + role;
    104      testCounter += 1;
    105      var nodes = theDOM.querySelectorAll('[role~="'+role+'"]');
    106      if (nodes.length) {
    107        // there are matching nodes
    108        test(function() {
    109          assert_true(true, "Found the role");
    110        }, tName);
    111      }
    112    });
    113 
    114    done();
    115  };
    116 
    117 on_event(document, "DOMContentLoaded", function() {
    118  var runButton = document.getElementById('dpub-run') ;
    119  var closeButton = document.getElementById('dpub-close') ;
    120 
    121  on_event(runButton, "click", function() {
    122    var content = document.getElementById("dpub-input");
    123 
    124    runTests(content.value);
    125  });
    126 });
    127 </script>
    128 </head>
    129 <body>
    130  <p>Fill the textarea below with the contents of a <code>body</code> element
    131  from HTML markup from that reflects your usage of
    132  DPub-ARIA roles.  Then select "Run Test" to evaluate the content.</p>
    133  <form name="dpub" id="dpub">
    134    <textarea name="dpub-input" id="dpub-input" style="width: 90%; height: 10em" ></textarea>
    135    <p><input type="button" id="dpub-run" name="Run Test" value="Run Test">
    136    <input style="display: none" type="button" id="dpub-close"
    137                                               name="Close" value="Close"></p>
    138  </form>
    139  <div id="log"></div>
    140 </body>
    141 </html>