UNPKG

siesta-lite

Version:

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

270 lines (180 loc) 7.79 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;Scope.Provider.Window&#39;, { isa : Scope.Provider, does : Scope.Provider.Role.WithDOM, has : { popupWindow : null }, methods : { setViewportSize : function (width, height) { var popupWindow = this.popupWindow if (!popupWindow) return // is not guaranteed to work popupWindow.resizeTo(width, height) }, create : function (onLoadCallback) { var minViewportSize = this.minViewportSize var width = minViewportSize &amp;&amp; minViewportSize.width || 1024 var height = minViewportSize &amp;&amp; minViewportSize.height || 768 var popup = this.scope = this.popupWindow = this.parentWindow.open( // left/top is set to &gt; 0 value with intent to keep the mouse cursor outside of the popup // its always recommened to set the mousecursor position to 0, 0 in the automation script this.sourceURL || &#39;about:blank&#39;, &#39;_blank&#39;, &quot;left=10,top=10,width=&quot; + width + &quot;,height=&quot; + height ) if (!popup) { alert(&#39;Please enable popups for the host with this test suite running: &#39; + this.parentWindow.location.host) throw &#39;Please enable popups for the host with this test suite running: &#39; + this.parentWindow.location.host } var isIE = &#39;v&#39; == &#39;\v&#39; || Boolean(this.parentWindow.msWriteProfilerMark) // dances with tambourine around the IE if (isIE &amp;&amp; !this.sourceURL) { var doc = this.getDocument() doc.open() doc.write(&#39;&#39;) doc.close() } // trying to add the &quot;early&quot; onerror handler - will probably only work in FF if (this.cachedOnError) this.installOnErrorHandler(this.cachedOnError) /*! * contentloaded.js * * Author: Diego Perini (diego.perini at gmail.com) * Summary: cross-browser wrapper for DOMContentLoaded * Updated: 20101020 * License: MIT * Version: 1.2 * * URL: * http://javascript.nwbox.com/ContentLoaded/ * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE * */ var me = this // @win window reference // @fn function reference var contentLoaded = function (win, fn) { var done = false, top = true, doc = win.document, root = doc.documentElement, add = doc.addEventListener ? &#39;addEventListener&#39; : &#39;attachEvent&#39;, rem = doc.addEventListener ? &#39;removeEventListener&#39; : &#39;detachEvent&#39;, pre = doc.addEventListener ? &#39;&#39; : &#39;on&#39;, init = function(e) { if (e.type == &#39;readystatechange&#39; &amp;&amp; doc.readyState != &#39;complete&#39;) return; (e.type == &#39;load&#39; ? win : doc)[ rem ](pre + e.type, init, false); if (!done &amp;&amp; (done = true)) fn.call(win, me); }, poll = function () { try { root.doScroll(&#39;left&#39;); } catch(e) { setTimeout(poll, 50); return; } init(&#39;poll&#39;); }; if (doc.readyState == &#39;complete&#39;) fn.call(win, me); else { if (doc.createEventObject &amp;&amp; root.doScroll) { try { top = !win.frameElement; } catch(e) { } if (top) poll(); } doc[add](pre + &#39;DOMContentLoaded&#39;, init, false); doc[add](pre + &#39;readystatechange&#39;, init, false); win[add](pre + &#39;load&#39;, init, false); } } if (this.sourceURL) // seems the &quot;doc.readyState&quot; is set before the DOM is created on the page // if one will start interact with page immediately he can overwrite the page content setTimeout(function () { contentLoaded(popup, onLoadCallback || function () {}) }, 10) else contentLoaded(popup, onLoadCallback || function () {}) }, getDocument : function () { return this.popupWindow.document }, cleanup : function () { if (this.beforeCleanupCallback) this.beforeCleanupCallback() this.beforeCleanupCallback = null this.popupWindow.close() this.popupWindow = null this.cleanupHandlers() if (this.cleanupCallback) this.cleanupCallback() this.cleanupCallback = null } } }) <span id='global-property-'>/** </span> Name ==== Scope.Provider.Window - scope provider, which uses the popup browser window. SYNOPSIS ======== var provider = new Scope.Provider.Window() provider.setup(function () { if (provider.scope.SOME_GLOBAL == &#39;some_value&#39;) { ... } provider.runCode(text, callback) ... provider.runScript(url, callback) ... provider.cleanup() }) DESCRIPTION =========== `Scope.Provider.Window` is an implementation of the scope provider, which uses the popup browser window, to create a new scope. ISA === [Scope.Provider](../Provider.html) DOES ==== [Scope.Provider.Role.WithDOM](Role/WithDOM.html) GETTING HELP ============ This extension is supported via github issues tracker: &lt;http://github.com/SamuraiJack/Scope-Provider/issues&gt; You can also ask questions at IRC channel : [#joose](http://webchat.freenode.net/?randomnick=1&amp;channels=joose&amp;prompt=1) Or the mailing list: &lt;http://groups.google.com/group/joose-js&gt; SEE ALSO ======== Web page of this module: &lt;http://github.com/SamuraiJack/Scope-Provider/&gt; General documentation for Joose: &lt;http://joose.github.com/Joose&gt; BUGS ==== All complex software has bugs lurking in it, and this module is no exception. Please report any bugs through the web interface at &lt;http://github.com/SamuraiJack/Scope-Provider/issues&gt; AUTHORS ======= Nickolay Platonov &lt;nplatonov@cpan.org&gt; COPYRIGHT AND LICENSE ===================== This software is Copyright (c) 2010 by Nickolay Platonov &lt;nplatonov@cpan.org&gt;. This is free software, licensed under: The GNU Lesser General Public License, Version 3, June 2007 */</pre> </body> </html>