UNPKG

siesta-lite

Version:

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

180 lines (140 loc) 6.86 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 */ <span id='Siesta-Project-Browser-ExtJSCore'>/** </span>@class Siesta.Project.Browser.ExtJSCore This is a role (mixin), representing the shared functionality between Ext JS and SenchaTouch projects. */ Role(&#39;Siesta.Project.Browser.ExtJSCore&#39;, { has : { <span id='Siesta-Project-Browser-ExtJSCore-cfg-loaderPath'> /** </span> * @cfg {Object} loaderPath * * The path used to configure the Ext.Loader &#39;paths&#39; config to resolve JS namespaces to file paths, for dynamic loading of Ext JS classes. * For more information, please see the Ext docs: http://docs.sencha.com/extjs/apidocs/#!/api/Ext.Loader-cfg-paths * * See also {@link #requires}. * * By default the value will be set right before the test starts. If you need to set it earlier (during preloading phase), * use {@link #getLoaderPathHook} method. * * This option can be also specified in the test file descriptor. * * **Note**, that the value of this config will not be inherited from the parent tests group, if test has {@link Siesta.Project.Browser#pageUrl} option set. */ loaderPath : null, <span id='Siesta-Project-Browser-ExtJSCore-cfg-requires'> /** </span> * @cfg {Array[String]} requires * * The array of class names, to be dynamically loaded with `Ext.require` call, before the test starts. Naturally, requires * the correct value for the {@link #loaderPath} to be set. * * This option can be also specified in the test file descriptor. */ requires : null, <span id='Siesta-Project-Browser-ExtJSCore-cfg-waitForExtComponentQueryReady'> /** </span> * @cfg {Boolean} waitForExtComponentQueryReady * * Setting this configuration option to &quot;true&quot; will cause Siesta to wait until the `Ext.ComponentQuery` class is loaded on the page, * before starting the test. * * This option can (and probably should) be also specified in the test file descriptor. */ waitForExtComponentQueryReady : true, // Set to true to fail t.knownBugInStatements, useful when running against Ext JS nightly builds failKnownBugIn : false, recorderClass : function () { return Siesta.Recorder.ExtJS } }, override : { getNewTestConfiguration : function (desc, scopeProvider, contentManager, launchState) { var config = this.SUPERARG(arguments) config.loaderPath = this.getDescriptorConfig(desc, &#39;loaderPath&#39;) config.requires = this.getDescriptorConfig(desc, &#39;requires&#39;) config.waitForExtComponentQueryReady = this.getDescriptorConfig(desc, &#39;waitForExtComponentQueryReady&#39;) return config }, buildSandboxHashStructure : function () { var structure = this.SUPERARG(arguments) structure.push(&#39;loaderPath&#39;, &#39;requires&#39;) return structure }, buildHostPageUrlStopsInheriting : function () { var res = this.SUPER() res.loaderPath = true return res } }, methods : { createViewport : function(config) { return Ext.create(&quot;Siesta.Project.Browser.UI.Viewport&quot;, config); }, generateLoaderPathHook : function () { // Such tedious check to allow setting the paths without crash for Ext JS versions &lt; 4 // (which may have own &quot;Ext.Loader&quot; object) return function (StartTest, Ext, loaderPath) { if (!loaderPath || StartTest.loaderPathHookInstalled || !Ext || !Ext.Loader || !Ext.Loader.setPath) return StartTest.loaderPathHookInstalled = true Ext.Loader.setPath(loaderPath) } }, <span id='Siesta-Project-Browser-ExtJSCore-method-getLoaderPathHook'> /** </span> * Returns a string presentation of the ExtJS/SenchaTouch hook for setting &quot;Ext.Loader&quot; paths, * suitable to be used in the test&#39;s {@link Siesta.Project#preload preloads}. * This will allow you to install the hook at the earliest possible point, * right after preloading Ext and before &quot;requiring&quot; any classes. * * The value for the paths should be provided in the {@link #loaderPath} config. * The inheritance of the value from groups is supported as usually, except the tests with * {@link Siesta.Project.Browser#pageUrl} option set. * * Typical usage will be: * var project = new Siesta.Project.Browser.ExtJS(); project.configure({ loaderPath : { &#39;My&#39; : &#39;js&#39;, &#39;My.Namespace&#39; : &#39;js/somepath&#39; }, preload : [ &#39;http://cdn.sencha.io/ext-4.2.0-gpl/ext-all.js&#39;, { // inject the loader paths right after ExtJS and before the application file text : project.getLoaderPathHook() }, &#39;app.js&#39; ] }); * * @return {String} */ getLoaderPathHook : function () { var hook = function (installationHook) { var parentWindow = window.opener || window.parent var project = parentWindow.Siesta.my.activeHarness eval(&#39;(&#39; + installationHook + &#39;)&#39;)(StartTest, Ext, project.getDescriptorConfig(project.getScriptDescriptor(StartTest.id), &quot;loaderPath&quot;)) } return &#39;;(&#39; + hook.toString() + &#39;)(&#39; + JSON.stringify(this.generateLoaderPathHook().toString()) + &#39;)&#39; } } })</pre> </body> </html>