tor-browser

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

test_SVGPointList.xhtml (4696B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=629200
      4 -->
      5 <head>
      6  <title>Tests specific to SVGPointList</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629200">Mozilla Bug 629200</a>
     12 <p id="display"></p>
     13 <div id="content" style="display:none;">
     14 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
     15  <polyline id="polyline" points="50,375 150,380"/>
     16  <polyline id="polyline2" points="10,20"/>
     17 </svg>
     18 </div>
     19 <pre id="test">
     20 <script class="testbody" type="text/javascript">
     21 <![CDATA[
     22 
     23 SimpleTest.waitForExplicitFinish();
     24 
     25 /*
     26 This file runs a series of SVGPointList specific tests. Generic SVGXxxList
     27 tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
     28 to other list types belongs there.
     29 */
     30 
     31 function run_tests() {
     32  document.getElementById("svg").pauseAnimations();
     33 
     34  var polyline = document.getElementById("polyline");
     35  var points = polyline.points;
     36 
     37  is(points.numberOfItems, 2, "Checking numberOfItems");
     38 
     39  // Test mutation events
     40  // -- Actual changes
     41  points[0].x = 40;
     42  polyline.setAttribute("points", "30,375 150,380");
     43  // -- Redundant changes
     44  points[0].x = 30;
     45  points[1].y = 380;
     46  polyline.setAttribute("points", "30,375 150,380");
     47  // -- Invalid attribute
     48  polyline.setAttribute("points", ",30,375");
     49  is(points.numberOfItems, 0, "Checking that parsing stops at invalid token");
     50  // -- Attribute removal
     51  polyline.removeAttribute("points");
     52  // -- Non-existent attribute removal
     53  polyline.removeAttribute("points");
     54  polyline.removeAttributeNS(null, "points");
     55 
     56  // Test that the addition of an owned SVGPoint to an SVGPointList creates a
     57  // copy of the SVGPoint
     58  var polyline2 = document.getElementById("polyline2");
     59  var subtests = [
     60    function initialize(aItem) {
     61      polyline.removeAttribute("points");
     62      return points.initialize(aItem);
     63    },
     64    function insertItemBefore(aItem) {
     65      polyline.removeAttribute("points");
     66      return points.insertItemBefore(aItem, 0);
     67    },
     68    function replaceItem(aItem) {
     69      polyline.setAttribute("points", "10,20");
     70      return points.replaceItem(aItem, 0);
     71    },
     72    function appendItem(aItem) {
     73      polyline.removeAttribute("points");
     74      return points.appendItem(aItem);
     75    },
     76  ];
     77  subtests.forEach(function(aFunction) {
     78    // -- Adding SVGSVGElement.currentTranslate, which is the only instance
     79    //    of an owned, single SVGPoint
     80    var svg = document.getElementById("svg");
     81    var name = aFunction.name;
     82    var existingItem = svg.currentTranslate;
     83    var newItem = aFunction(existingItem);
     84    is(newItem, points.getItem(0), name + " return value is correct when passed currentTranslate");
     85    isnot(newItem, existingItem, name + " made a copy when passed currentTranslate");
     86    is(newItem.value, existingItem.value, name + " made a copy with the right values when passed currentTranslate");
     87    is(svg.currentTranslate, existingItem, name + " left the original object alone when passed currentTranslate");
     88  });
     89  subtests.forEach(function(aFunction) {
     90    // -- Adding an SVGPoint that is in a baseVal list
     91    var name = aFunction.name;
     92    var existingItem = polyline2.points.getItem(0);
     93    var newItem = aFunction(existingItem);
     94    is(newItem, points.getItem(0), name + " return value is correct when passed a baseVal list item");
     95    isnot(newItem, existingItem, name + " made a copy when passed a baseVal list item");
     96    is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a baseVal list item");
     97    is(polyline2.points.getItem(0), existingItem, name + " left the original object alone when passed a baseVal list item");
     98  });
     99  subtests.forEach(function(aFunction) {
    100    // -- Adding an SVGPoint that is in a animVal list
    101    var name = aFunction.name;
    102    var existingItem = polyline2.animatedPoints.getItem(0);
    103    var newItem = aFunction(existingItem);
    104    is(newItem, points.getItem(0), name + " return value is correct when passed a animVal list item");
    105    isnot(newItem, existingItem, name + " made a copy when passed a animVal list item");
    106    is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a animVal list item");
    107    is(polyline2.animatedPoints.getItem(0), existingItem, name + " left the original object alone when passed a animVal list item");
    108  });
    109 
    110  SimpleTest.finish();
    111 }
    112 
    113 window.addEventListener("load",
    114  () => SimpleTest.executeSoon(run_tests)
    115 );
    116 
    117 ]]>
    118 </script>
    119 </pre>
    120 </body>
    121 </html>