UNPKG

siesta-lite

Version:

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

147 lines (116 loc) 4.03 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.Simulator&#39;, { does : [ Siesta.Util.Role.CanGetType, Siesta.Test.Browser.Role.CanRebindJQueryContext, Siesta.Test.Simulate.Event, Siesta.Test.Simulate.Mouse, Siesta.Test.Simulate.Keyboard, Siesta.Test.Simulate.Touch ], has : { type : &#39;synthetic&#39;, test : null, global : null }, methods : { onTestLaunch : function (test) { var me = this; me.test = test me.global = test.global // Synthetic events unfortunately don&#39;t trigger `change` events on blur of an INPUT if (me.type === &#39;synthetic&#39;) { me.makeSureBlurWorkaroundApplied(test.global.document) } }, cleanup : function () { // Added check that global exists, made tests crash without this.global &amp;&amp; this.global.document.__SIESTA_ONBLUR_WORKAROUND_APPLIED__ &amp;&amp; this.global.document.__SIESTA_ONBLUR_WORKAROUND_APPLIED__.dispose() this.test = null this.global = null }, setSpeed : function (name) { Joose.O.extend(this, Siesta.Test.Simulator.speedPresets[name]); } } }); Siesta.Test.Simulator.speedPresets = { slow : { actionDelay : 100, afterActionDelay : 100, dragDelay : 25, pathBatchSize : 5, mouseMovePrecision : 1, mouseDragPrecision : 1 }, speedRun : { actionDelay : 1, afterActionDelay : 100, dragDelay : 10, pathBatchSize : 30, mouseMovePrecision : 1, mouseDragPrecision : 1 }, turboMode : { actionDelay : 1, afterActionDelay : 1, dragDelay : 0, pathBatchSize : 100, mouseMovePrecision : Infinity, mouseDragPrecision : Infinity } }; Class(&#39;Siesta.Test.SimulatorOnBlurWorkaround&#39;, { does : [ Siesta.Test.Browser.Role.CanWorkWithKeyboard ], has : { document : null, simulator : null, }, methods : { initialize : function () { this.SUPERARG(arguments) this.onBlur = this.onBlur.bind(this) this.document.documentElement.addEventListener(&#39;blur&#39;, this.onBlur, true) }, onBlur : function (event) { if (event.target &amp;&amp; this.isTextInput(event.target)) { var inputFiresChangeAfterLosingFocus = Siesta.Project.Browser.FeatureSupport().supports.inputFiresChangeAfterLosingFocus &amp;&amp; (!bowser.safari || !event.target.valueWasModifiedByBackspace) if (!inputFiresChangeAfterLosingFocus) { this.simulator.maybeMimicChangeEvent(event.target) } } }, dispose : function () { this.document.documentElement.removeEventListener(&#39;blur&#39;, this.onBlur, true) this.document.__SIESTA_ONBLUR_WORKAROUND_APPLIED__ = undefined } } }) </pre> </body> </html>