tor-browser

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

test_w3element_traversal_svg.html (4032B)


      1 <!DOCTYPE html>
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4  <title>Test for ElementTraversal via SVG</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 
     10 <p id="display"></p>
     11 <div id="content" style="display: none"></div>
     12 
     13 <iframe id="svg" src="w3element_traversal.svg"></iframe>
     14 
     15 <pre id="test">
     16 <script class="testbody" type="application/javascript">
     17 SimpleTest.waitForExplicitFinish();
     18 
     19 function run()
     20 {
     21  var doc = $("svg").contentDocument;
     22  
     23  //et-namespace.svg
     24  var parentEl = doc.getElementById("parentEl_namespace");
     25  var nChild = parentEl.firstElementChild;
     26  is(nChild && "dill", nChild.localName, "failed to get child with namespace")
     27 
     28  //et-previousElementSibling.svg
     29  var lec = doc.getElementById("last_element_child_pes");
     30  var pes = lec.previousElementSibling;
     31  isnot(pes, null, "previousElementSibling is null");
     32  is(pes.nodeType, 1, "previousElementSibling returned the wrong node type");
     33  is(pes.getAttribute("id"), "middle_element_child_pes", "previousElementSibling returned the wrong child");
     34 
     35  //et-sibling_null.svg
     36  var fec = doc.getElementById("first_element_child_sibnull");
     37  var pes = fec.previousElementSibling;
     38  var nes = fec.nextElementSibling;
     39  is(pes, null, "previousElementSibling is not null");
     40  is(nes, null, "nextElementSibling is not null");
     41 
     42  //et-nextElementSibling.svg
     43  fec = doc.getElementById("first_element_child_nes");
     44  var nes = fec.nextElementSibling;
     45  isnot(nes, null, "nextElementSibling returned NULL");
     46  is(nes.nodeType, 1, "nextElementSibling returned wrong node type");
     47  is(nes.getAttribute("id"), "last_element_child_nes", "nextElementSibling returned wrong node id");
     48 
     49  //et-lastElementChild.svg
     50  var parentEl = doc.getElementById("parentEl_lec");
     51  var lec = parentEl.lastElementChild;
     52  isnot(lec, null, "lastElementChild returned null");
     53  is(lec.nodeType, 1, "lastElementChild returned wrong nodeType");
     54  is(lec.getAttribute("id"), "last_element_child_lec", "lastElementChild returned wrong id");
     55 
     56  //et-firstElementChild.svg
     57  var parentEl = doc.getElementById("parentEl_fec");
     58  var fec = parentEl.firstElementChild;
     59  isnot(fec, null, "firstElementChild returned null");
     60  is(fec.nodeType, 1, "firstElementChild returned wrong nodeType");
     61  is(fec.getAttribute("id"), "first_element_child_fec", "firstElementChild returned wrong id");
     62 
     63  //et-entity.svg
     64  var parentEl = doc.getElementById("parentEl_entity");
     65  var fec = parentEl.firstElementChild;
     66  isnot(fec, null, "firstElementChild returned null");
     67  is(fec.nodeType, 1, "firstElementChild returned wrong nodeType");
     68  is(fec.getAttribute("id"), "first_element_child_entity", "firstElementChild returned wrong id");
     69 
     70  //et-dynamic-remove.svg
     71  var parentEl = doc.getElementById("parentEl_dynremove");
     72  var lec = parentEl.lastElementChild;
     73  parentEl.removeChild( lec );
     74  is(parentEl.childElementCount && 1, parentEl.childElementCount, "failed to removeChild");
     75 
     76  //et-dynamic-add.svg
     77  var parentEl = doc.getElementById("parentEl_dynadd");
     78  var newChild = doc.createElementNS("http://www.w3.org/2000/svg", "tspan");
     79  parentEl.appendChild( newChild );
     80  is(parentEl.childElementCount && 2, parentEl.childElementCount, "failed to appendChild");
     81 
     82  //et-childElement-null.svg
     83  var parentEl = doc.getElementById("parentEl_null");
     84  var fec = parentEl.firstElementChild;
     85  var lec = parentEl.lastElementChild;
     86  is(fec, null, "expected null from firstElementChild");
     87  is(lec, null, "expected null from lastElementChild");
     88 
     89 
     90  //et-childElementCount.svg
     91  var parentEl = doc.getElementById("parentEl_count");
     92  is(parentEl.childElementCount && 3, parentEl.childElementCount, "got wrong childElementCount");
     93 
     94  //et-childElementCount-nochild.svg
     95  var parentEl = doc.getElementById("parentEl_nochild");
     96  is(0, parentEl.childElementCount, "got wrong childElementCount");
     97  
     98 
     99  SimpleTest.finish();
    100 }
    101 
    102 window.addEventListener("load", run);
    103 </script>
    104 </pre>
    105 </body>
    106 </html>