UNPKG

siesta-lite

Version:

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

109 lines (88 loc) 3.87 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 */ // requires &quot;global&quot; attribute Role(&#39;Siesta.Test.Browser.Role.CanWorkWithKeyboard&#39;, { has : { }, methods : { isTextInput : function(node) { // somehow &quot;node.nodeName&quot; is empty sometimes in IE10 var name = node.nodeName &amp;&amp; node.nodeName.toLowerCase(); if (name === &#39;textarea&#39;) return true; if (name === &#39;input&#39;) { var type = String(node.type).toLowerCase() return type === &#39;password&#39; || type === &#39;number&#39; || type === &#39;search&#39; || type === &#39;text&#39; || type === &#39;url&#39; || type === &#39;tel&#39; || type === &#39;month&#39; || type === &#39;time&#39; || type === &#39;date&#39; || type === &#39;datetime&#39; || type === &#39;week&#39; || type === &#39;email&#39;; } return false }, isEditableNode : function(node) { return node.ownerDocument.designMode.toLowerCase() === &#39;on&#39; || node.isContentEditable; }, // private isReadableKey: function (keyCode) { var KC = Siesta.Test.UserAgent.KeyCodes(); return !KC.isNav(keyCode) &amp;&amp; !KC.isSpecial(keyCode); }, activeElement : function (notAllowBody, fallbackEl, elOrDoc) { var doc = elOrDoc &amp;&amp; this.typeOf(elOrDoc) === &#39;HTMLDocument&#39; ? elOrDoc : this.getQueryableContainer(elOrDoc) var focusedEl = doc.activeElement; // 1. In IE10,11 it seems activeElement cannot be trusted as it sometimes returns an empty object with no properties. // Try to detect this case and use the fallback el // 2. Sometimes receiving &lt;body&gt; from this method does not make sense either - use fallback el as well if (!focusedEl || !focusedEl.nodeName || !focusedEl.tagName || (focusedEl === doc.body &amp;&amp; notAllowBody)) { focusedEl = fallbackEl; } // For iframes, we need to grab the activeElement of the frame (if in the same domain) if (focusedEl) { if (String(focusedEl.tagName).toLowerCase() === &#39;iframe&#39;) { try { if (focusedEl.contentDocument &amp;&amp; focusedEl.contentDocument.body) { focusedEl = this.activeElement(notAllowBody, fallbackEl, focusedEl.contentDocument) } } catch (e) { } } else if (focusedEl.shadowRoot) { return this.activeElement(notAllowBody, fallbackEl, focusedEl.shadowRoot); } } return focusedEl || doc.body } } }); </pre> </body> </html>