tor-browser

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

test_smilInvalidValues.html (3579B)


      1 <!doctype html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=941315
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test invalid values cause the model to be updated (bug 941315)</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=941315">Mozilla Bug 941315</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none">
     16 <svg width="100%" height="1" onload="this.pauseAnimations()">
     17  <rect>
     18    <animate id="a" dur="100s"/>
     19    <animate id="b" dur="5s" begin="a.end"/>
     20  </rect>
     21  <circle cx="-100" cy="20" r="15" fill="blue" id="circle"/>
     22 </svg>
     23 </div>
     24 <pre id="test">
     25 <script class="testbody" type="text/javascript">
     26  var a = $('a'),
     27      b = $('b');
     28 
     29  // Animation doesn't start until onload
     30  SimpleTest.waitForExplicitFinish();
     31  window.addEventListener("load", runTests);
     32 
     33  // Make testing getStartTime easier
     34  SVGAnimationElement.prototype.safeGetStartTime = function() {
     35    try {
     36      return this.getStartTime();
     37    } catch(e) {
     38      if (e.name == "InvalidStateError" &&
     39          e.code == DOMException.INVALID_STATE_ERR) {
     40        return 'none';
     41      } else {
     42        ok(false, "Unexpected exception: " + e);
     43        return null;
     44      }
     45    }
     46  };
     47 
     48  function runTests() {
     49    [testSimpleDuration, testSimpleDuration2, testMin, testMax, testRepeatDur, testRepeatCount]
     50      .forEach(function(test) {
     51        is(b.getStartTime(), 100, "initial state before running " + test.name);
     52        test();
     53        is(b.getStartTime(), 100, "final state after running " + test.name);
     54      });
     55    SimpleTest.finish();
     56  }
     57 
     58  function testSimpleDuration() {
     59    // Verify a valid value updates as expected
     60    a.setAttribute("dur", "50s");
     61    is(b.safeGetStartTime(), 50, "valid simple duration");
     62 
     63    // Check an invalid value also causes the model to be updated
     64    a.setAttribute("dur", "abc"); // -> indefinite
     65    is(b.safeGetStartTime(), "none", "invalid simple duration");
     66 
     67    // Restore state
     68    a.setAttribute("dur", "100s");
     69  }
     70 
     71  function testSimpleDuration2() {
     72    // Check an invalid value causes the model to be updated
     73    a.setAttribute("dur", "-.1s"); // -> indefinite
     74    is(b.safeGetStartTime(), "none", "invalid simple duration");
     75 
     76    // Restore state
     77    a.setAttribute("dur", "100s");
     78  }
     79 
     80  function testMin() {
     81    a.setAttribute("min", "200s");
     82    is(b.safeGetStartTime(), 200, "valid min duration");
     83 
     84    a.setAttribute("min", "abc"); // -> indefinite
     85    is(b.safeGetStartTime(), 100, "invalid min duration");
     86 
     87    a.removeAttribute("min");
     88  }
     89 
     90  function testMax() {
     91    a.setAttribute("max", "50s");
     92    is(b.safeGetStartTime(), 50, "valid max duration");
     93 
     94    a.setAttribute("max", "abc"); // -> indefinite
     95    is(b.safeGetStartTime(), 100, "invalid max duration");
     96 
     97    a.removeAttribute("max");
     98  }
     99 
    100  function testRepeatDur() {
    101    a.setAttribute("repeatDur", "200s");
    102    is(b.safeGetStartTime(), 200, "valid repeatDur duration");
    103 
    104    a.setAttribute("repeatDur", "abc"); // -> indefinite
    105    is(b.safeGetStartTime(), 100, "invalid repeatDur duration");
    106 
    107    a.removeAttribute("repeatDur");
    108  }
    109 
    110  function testRepeatCount() {
    111    a.setAttribute("repeatCount", "2");
    112    is(b.safeGetStartTime(), 200, "valid repeatCount duration");
    113 
    114    a.setAttribute("repeatCount", "abc"); // -> indefinite
    115    is(b.safeGetStartTime(), 100, "invalid repeatCount duration");
    116 
    117    a.removeAttribute("repeatCount");
    118  }
    119 </script>
    120 </pre>
    121 </body>
    122 </html>