tor-browser

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

test_smilConditionalProcessing.html (3118B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test conditional processing tests applied to animations</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <p id="display"></p>
     11 <div id="content">
     12 <svg id="svg" width="120px" height="120px"
     13     onload="this.pauseAnimations()">
     14  <circle r="50" fill="blue" id="circle">
     15    <set attributeName="cy" to="100" begin="0s" dur="100s" id="a"/>
     16    <set attributeName="cx" to="100" begin="a.end" dur="100s" id="b"/>
     17  </circle>
     18 </svg>
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 
     23 SimpleTest.waitForExplicitFinish();
     24 
     25 function run() {
     26  SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en"]]}, runInternal);
     27 }
     28 
     29 function runInternal() {
     30  var svg = document.getElementById("svg"),
     31      a = document.getElementById("a"),
     32      b = document.getElementById("b"),
     33      circle = document.getElementById("circle");
     34 
     35  // Check initial state
     36  svg.setCurrentTime(50);
     37  is(a.getStartTime(), 0, "a has resolved start time at start");
     38  is(circle.cy.animVal.value, 100, "a is in effect at start");
     39  is(b.getStartTime(), 100, "b has resolved start time at start");
     40 
     41  // Add a failing conditional processing test
     42  a.setAttribute("systemLanguage", "no-such-language");
     43  ok(hasUnresolvedStartTime(a),
     44     "a has unresolved start time with failing conditional processing test");
     45  is(circle.cy.animVal.value, 0,
     46     "a is not in effect with failing conditional processing test");
     47  ok(hasUnresolvedStartTime(b),
     48     "b has unresolved start time with failing conditional processing test on a");
     49 
     50  // Remove failing conditional processing test
     51  a.removeAttribute("systemLanguage");
     52  is(a.getStartTime(), 0, "a has resolved start time after removing test");
     53  is(circle.cy.animVal.value, 100, "a is in effect after removing test");
     54  is(b.getStartTime(), 100, "b has resolved start time after removing test on a");
     55 
     56  // Add another failing conditional processing test
     57  // According to the spec, if a null string or empty string value is set for
     58  // the 'systemLanguage' attribute, the attribute returns "false".
     59  a.setAttribute("systemLanguage", "");
     60 
     61  // Fast forward until |a| would have finished
     62  var endEventsReceived = 0;
     63  a.addEventListener("endEvent", function() { endEventsReceived++; });
     64  svg.setCurrentTime(150);
     65  is(endEventsReceived, 0,
     66     "a does not dispatch end events with failing condition processing test");
     67  is(circle.cx.animVal.value, 0,
     68     "b is not in effect with failing conditional processing test on a");
     69 
     70  // Make test pass
     71  a.setAttribute("systemLanguage", "en");
     72  is(circle.cx.animVal.value, 100,
     73     "b is in effect with passing conditional processing test on a");
     74 
     75  SimpleTest.finish();
     76 }
     77 
     78 function hasUnresolvedStartTime(anim) {
     79  // getStartTime throws INVALID_STATE_ERR when there is no current interval
     80  try {
     81    anim.getStartTime();
     82    return false;
     83  } catch (e) {
     84    return true;
     85  }
     86 }
     87 
     88 window.addEventListener("load", run);
     89 
     90 </script>
     91 </pre>
     92 </body>
     93 </html>