UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

94 lines (77 loc) 3.59 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Class(&#39;Siesta.Test.SimulatorExtJS&#39;, { isa : Siesta.Test.Simulator, has : { simulateEventsWith : { is : &#39;rw&#39;, lazy : function () { var isIE9 = navigator.userAgent.match(/MSIE 9.0;/) var Ext = this.global.Ext // no Ext or Ext3, should use standard &quot;dispatchEvent&quot; method if (!Ext || !Ext.getVersion) return &#39;dispatchEvent&#39; var extVersion = Ext.getVersion(&#39;extjs&#39;) // the &quot;Ext.getVersion(&#39;extjs&#39;)&quot; is just &quot;true&quot; in Ext3? (when testing SA) var isBelowExt421 = Boolean((extVersion &amp;&amp; extVersion.isLessThan &amp;&amp; extVersion.isLessThan(&#39;4.2.1.883&#39;))) var div = document.createElement(&#39;div&#39;) return div.attachEvent &amp;&amp; (isIE9 || isBelowExt421) ? &#39;fireEvent&#39; : &#39;dispatchEvent&#39; } } }, methods : { // Overridden to deal with the different event firing mechanisms in Ext JS 3 vs 4 // This code is required because in IE events are simulated using fireEvent instead of dispatchEvent and it seems fireEvent will // will not update a checkbox &#39;checked&#39; state properly so we&#39;re forcing the toggle to solve this situation. // This issue is only relevant in IE + Ext. // // Test case: 507_form_checkbox.t.js simulateMouseClick: function (clickInfo, options) { var me = this var el = clickInfo.el var Ext = this.global.Ext var isExt5 = Ext &amp;&amp; Ext.getVersion &amp;&amp; Ext.getVersion(&#39;extjs&#39;) &amp;&amp; Ext.getVersion(&#39;extjs&#39;).major == 5 // Force check toggle for input checkboxes if ( (this.getSimulateEventsWith() === &#39;fireEvent&#39; || isExt5) &amp;&amp; (el.type === &#39;checkbox&#39; || el.type === &#39;radio&#39;) &amp;&amp; !el.disabled &amp;&amp; !el.readOnly ) { var oldState = el.checked; return this.SUPER(clickInfo, options).then(function () { if (el.checked === oldState) { el.checked = !oldState; var optionsWithBubble = Joose.O.copy(options) optionsWithBubble.bubbles = true me.simulateEvent(el, &#39;change&#39;, optionsWithBubble) } }); } else { return this.SUPERARG(arguments); } } } }) </pre> </body> </html>