tor-browser

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

test_bug456151.html (1998B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=456151
      5 -->
      6 <head>
      7  <title>Test for Bug 456151</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.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=456151">Mozilla Bug 456151</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none">
     16  
     17 </div>
     18 <pre id="test">
     19 <script type="application/javascript">
     20 
     21 /** Test for Bug 456151 */
     22 var intercepted = false;
     23 
     24 // Set up our new addEventListener
     25 var proto = HTMLParagraphElement.prototype;
     26 proto.oldAdd = proto.addEventListener;
     27 proto.addEventListener = function(ev, list, capt) {
     28  intercepted = true;
     29  this.oldAdd(ev, list, capt);
     30 }
     31 proto.oldRemove = proto.removeEventListener;
     32 proto.removeEventListener = function(ev, list, capt) {
     33  intercepted = true;
     34  this.oldRemove(ev, list, capt);
     35 }
     36 
     37 var called = false;
     38 
     39 var func = function() { called = true; };
     40 $("display").addEventListener("click", func);
     41 is(intercepted, true, "Should have interecepted addEventListener call");
     42 
     43 sendMouseEvent({type: "click"}, "display");
     44 is(called, true, "Should have called event listener");
     45 
     46 interecepted = false;
     47 called = false;
     48 
     49 $("display").removeEventListener("click", func);
     50 is(intercepted, true, "Should have interecepted removeEventListener call");
     51 
     52 sendMouseEvent({type: "click"}, "display");
     53 is(called, false, "Should have removed event listener");
     54 
     55 // And now some simple sanity tests
     56 var recursion = false;
     57 var x = document.createElement("span");
     58 HTMLSpanElement.prototype.addEventListener =
     59  function(a, b, c) {
     60    return x.addEventListener(a,b,c);
     61  }
     62 try {
     63  x.addEventListener("click", function() { called = true; });
     64 } catch (e) {
     65  recursion = e.message.match(/recursion/);
     66 }
     67 SimpleTest.isDeeply(recursion, ["recursion"], "Caught infinite recursion");
     68 
     69 </script>
     70 </pre>
     71 </body>
     72 </html>