<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>JavaScript - Blogs at Near Infinity</title>


        <link>http://www.nearinfinity.com/blogs/</link>
        <description>Employee Blogs</description>
        <language>en</language>
        <copyright>Copyright 2010</copyright>
        <lastBuildDate>Sat, 24 Apr 2010 14:00:36 -0500</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>Selenium Mojo : Protoype Bindings in Selenium</title>
            <description><![CDATA[<font style="font-size: 1.25em;"><b>Introduction</b></font><br /><br />On my current project we have been involved in converting some of the hundreds of manual tests that are run by our Test Team every release into a suite of automated Selenium RC tests.<br /><br />During the course of this adventure my crew found several instances where XPath and native JavaScript were not sufficiently expressive to find elements in some of our more complicated interfaces. <br /><br />Since our web app uses the Prototype/Scriptaculous JavaScript framework we wanted to find a way to make the locating power of Prototype available within Selenium RC.<br /><br />We developed approaches for both Selenium 0.9.2 and Selenium 1.0.3 (which had better programmatic support for adding JavaScript user extensions to Selenium).<br /><br /><br /><font style="font-size: 1.25em;"><b>Selenium 0.9.2</b></font><br /><br />Selenium RC provides the capability to add "user extensions" to augment its JavaScript core. <br /><br />See <a href="http://seleniumhq.org/docs/08_user_extensions.html">http://seleniumhq.org/docs/08_user_extensions.html</a> for detailed information on how to set this up. <br /><br />We wrote the following user-extension.js file:<br /><br /><pre class="prettyprint">Selenium.prototype.setupProtoypeJS = function() {<br />&nbsp;&nbsp;&nbsp; id = selenium.browserbot.getCurrentWindow().$;<br />&nbsp;&nbsp;&nbsp; css = selenium.browserbot.getCurrentWindow().$$;<br />}</pre><br />In our code we have a base class for all our test cases. To this we added our own waitForPage() method:<br /><br /><pre class="prettyprint">public void waitForPage() {<br />&nbsp;&nbsp;&nbsp; selenium.waitForPage('60000')<br />&nbsp;&nbsp;&nbsp; proc.doCommand('setupPrototypeJS', [])<br />}</pre><br />Thus every time the page reloads (which clears the JavaScript context) we call waitForPage() and this command is re-executed. It creates two global variables (id and css) and binds them to Prototype's $ and $$ functions respectively.<br /><br /><i>Note: The reason we choose id and css instead of $ and $$ was that Groovy considers $ in Strings to be a special character and we would have had to escape it each time it was used</i>.<br /><br />The Prototype selectors can now be used in Selenium RC like this:<br /><br /><pre class="prettyprint">selenium.click("dom=id('foo')")<br />selenium.click("dom=css('.bar')")<br />selenium.click("dom=css('span.foo a.baz')")</pre><br /><i>Note: You still have to specify the dom locator type so Selenium RC will know to execute your locator string as JavaScript.&nbsp; <br /></i><br /><br /><font style="font-size: 1.25em;"><b>Selenium 1.0.3</b></font><br /><br />In more recent version of Selenium RC the project added the setExtensionJs() method. This allows you to set extension JavaScript programmatically prior to starting the selenium client:<br /><br /><pre class="prettyprint">selenium = new DefaultSelenium(...)<br />selenium.setExtensionJs('...')<br />selenium.start()</pre><br />This made it much easier to implement our Prototype bindings. The only trick was that the JavaScript seems to be executed prior to having access to a page context and is also only executed once. This required us to take a different approach.<br /><br />We created id and css as global functions instead of variables. This allowed us to defer accessing the current window until the functions were actually invoked. &nbsp; <br /><br /><pre class="prettyprint">selenium.setExtensionJs('''<br />        id = function(value) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    return selenium.browserbot.getCurrentWindow().$(value);<br /><div id=":w0" class="ii gt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; css = function(value) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return selenium.browserbot.<wbr>getCurrentWindow().$$(value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />''');</div></pre> <br /><i>Note: The above code snippet is written in Groovy which allows multiline Strings.<br /></i><br />The Prototype selectors are used in Selenium RC like before:<br /><br /><pre class="prettyprint">selenium.click("dom=id('foo')")<br />selenium.click("dom=css('.bar')")<br />selenium.click("dom=css('span.foo a.baz')")</pre><br /><br /><br />I would be interested in hearing feedback from anyone who has a chance to use this technique!<br />]]></description>
            <link>http://www.nearinfinity.com/blogs/stephen_mouring_jr/selenium_mojo_protoype_binding.html</link>
            <guid>http://www.nearinfinity.com/blogs/stephen_mouring_jr/selenium_mojo_protoype_binding.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Groovy</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Testing</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Web Development</category>
            
            
            <pubDate>Sat, 24 Apr 2010 14:00:36 -0500</pubDate>
        </item>
        
        <item>
            <title>JavaScript Particle Engine in Canvas</title>
            <description><![CDATA[<p>The most popular entry I've written at Near Infinity has been the <a href="http://www.nearinfinity.com/blogs/page/jharwig?entry=javascript_particle_engine">JavaScript Particle Engine</a>.  It had limitations because I used transparent images and only made one color -- black. I recreated the fire demo for a talk -- Advanced Web Graphics with Canvas -- that I gave at the <a href="http://therichwebexperience.com/conference/speaker/jason_harwig.html">Rich Web Experience</a>. I'll post the slides, sample code, and some more demos in upcoming entries.</p>
]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_particle_engine_in_canvas.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_particle_engine_in_canvas.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Tue, 23 Sep 2008 19:24:23 -0500</pubDate>
        </item>
        
        <item>
            <title>JavaScript Obscured (How to confuse coworkers)</title>
            <description><![CDATA[<p>I was reading a blog entry at <a href="http://webreflection.blogspot.com/2008/06/two-simple-tricks-in-javascript-olds.html">Web Reflection</a> that outlined some obscure solutions to common JavaScript patterns.</p>

<p>I thought that entry was interesting, but I'm not sure I'd use them because of code readability and maintenance. It did get me thinking of some other ways to obscure simple tasks.</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_obscured_how_to_confuse.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_obscured_how_to_confuse.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Thu, 05 Jun 2008 20:19:44 -0500</pubDate>
        </item>
        
        <item>
            <title>Server-side JavaScript and Jaxer</title>
            <description><![CDATA[<p>The web community has been buzzing about the new Ajax server, Jaxer, from Aptana. If you haven't heard see <a href="http://ejohn.org/blog/server-side-javascript-with-jaxer/">John's</a>, or <a href="http://ajaxian.com/archives/aptana-releases-jaxer-ajax-server-built-on-mozilla">Dion's Ajaxian</a> posts about it.</p>

<p>Now, overall, I am really excited about the future in this project. The problem I had is all their examples use <i>synchronous</i> XMLHttpRequests. We <a href="http://ajaxblog.com/archives/2005/05/25/synchronous-requests-bad">already</a> <a href="http://www.oreillynet.com/xml/blog/2007/01/do_sync_calls_freeze_browsers.html">know</a> <a href="http://swik.net/Ajax/Ajax-Development-Gotchas">why</a> this is unfriendly to users.</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/server_side_javascript_and_jaxer.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/server_side_javascript_and_jaxer.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Wed, 23 Jan 2008 13:36:15 -0500</pubDate>
        </item>
        
        <item>
            <title>JavaScript Security Slides from No Fluff Just Stuff</title>
            <description><![CDATA[<p>I spoke at the Reston, VA <a href="http://www.nofluffjuststuff.com">No Fluff Just Stuff</a> conference again this past weekend.  The talk was on JavaScript security covering topics including:
</p><ul>
<li>Cross-site scripting (XSS)</li>
<li>Cross-site-request forgery (CSRF)</li>
<li>JSON Hi-jacking</li>
<li>JavaScript portscanning</li>
<li>JavaScript and CSS History "Go Fish"</li>
</ul>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_security_slides_from_no.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_security_slides_from_no.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Security</category>
            
            
            <pubDate>Thu, 08 Nov 2007 19:38:27 -0500</pubDate>
        </item>
        
        <item>
            <title>Testing JavaScript Objects with Function.prototype.call</title>
            <description><![CDATA[<p>This is a short tip that I found useful for testing complex JavaScript objects using <a href="http://www.thefrontside.net/crosscheck">crosscheck</a>. For more information on crosscheck see my article on <a href="/blogs/page/jharwig?entry=javascript_unit_testing">JavaScript Unit Testing with Crosscheck</a>. </p>

<p>Testing instance methods can be a pain if the functions use instance variables and the object is heavyweight. In my case the constructor did a lot with the DOM that I didn't want to mock. Instead of invoking the function through an instance of an object, I called it statically. </p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/testing_custom_javascript_libraries_with.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/testing_custom_javascript_libraries_with.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Testing</category>
            
            
            <pubDate>Thu, 11 Oct 2007 18:33:31 -0500</pubDate>
        </item>
        
        <item>
            <title>JavaScript Unit Testing with Crosscheck</title>
            <description><![CDATA[<p>Here we are, a couple years since Ajax was coined, JavaScript has become a language that people actually respect. The code being written now is better than ever before. Object-orientation, name-spacing, object detection, and correct scoping are prevalent now. The libraries available (prototype, jquery, yui, dojo) are very well written. What is the next step to improve code quality? If you want my opinion, it's Testing. Otherwise, <a href="http://www.digg.com">here's</a> the door. :) </p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_unit_testing.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_unit_testing.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Testing</category>
            
            
            <pubDate>Mon, 08 Oct 2007 15:08:12 -0500</pubDate>
        </item>
        
        <item>
            <title>Prototype.js Documentation Site Launched</title>
            <description><![CDATA[<p>It seems that <a href="http://encytemedia.com/blog/articles/2007/1/18/prototype-1-5-released-and-documentation-site-live">Encytemedia</a> was successful in their <a href="http://encytemedia.com/blog/articles/2006/10/31/prototype-a-call-for-documentation">"Call for Prototype Documentation"</a> blog posted in the old year.

</p><p>The site lives at <a href="http://prototypejs.org">prototypejs.org</a> and should help new and experienced users alike master the popular JavaScript library.

</p><h3>Features</h3>

<ul>
<li>API of all extended and new objects with examples</li>
<li>Tips/Tutorials section that includes how prototype works</li>
<li>Easy method for users to contribute</li>
</ul>

<p>Good work guys!</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/prototype_js_documention_site_launched.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/prototype_js_documention_site_launched.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Thu, 18 Jan 2007 17:37:44 -0500</pubDate>
        </item>
        
        <item>
            <title>Firebug 1.0 Features announced</title>
            <description><![CDATA[<p><img style="float: right;" src="/blogs/resources/jharwig/firebug-timeline.gif" alt=" "/>Looks like Joe Hewitt has been busy. </p>

<p>Firebug now has it's own site at <a href="http://www.getfirebug.com">getfirebug.com</a>. The new site shows the features for Firebug 1.0 which seem like a giant leap in functionality from the current 0.4.1.  My favorites look to be the new profiler and the network activity view (shown right).</p>

<p>The catch?  According to <a href="http://www.joehewitt.com/blog/introducing_fir.php">Hewitt's blog</a>, it might not be free. I know I would pay $15-$25, what about you?</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/firebug_1_0_features_announced.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/firebug_1_0_features_announced.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Thu, 16 Nov 2006 11:09:47 -0500</pubDate>
        </item>
        
        <item>
            <title>Javascript Particle Engine</title>
            <description><![CDATA[<h1 style="display:none">Javascript particle Engine</h1>
<div style="padding:15px;background-color:#ffffcc">Updated: <a href="http://www.nearinfinity.com/blogs/jason_harwig/javascript_particle_engine_in_canvas.html">Particle Engine using Canvas</a></div>

<p>I was at the No Fluff Just Stuff Software Symposium in Reston, VA this past weekend and had some time in between sessions to work on something. As most of the people I work with know, I rarely code things that might actually be useful to someone in my spare time.  So, I had no reason to attempt to rationalize the use for a particle engine in Javascript.</p>

<p>I think I've written a particle engine in almost every language I've used for an extended period of time. This includes python, java, objective-c, and c.  What's surprising is that it has taken me this long to write a particle engine in the language I probably spend the most time coding in -- Javascript.</p>

<p>By the way, this is probably the worst particle engine ever created (TM), but it is written in Javascript, so give me a break.  It doesn't support colors yet as I couldn't think of an efficient way to change the color of a png.  I've only tested it in Firefox and Safari because I'm on a Powerbook. It's also pretty slow, in that it can handle only a dozen or so particles.</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_particle_engine.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_particle_engine.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Tue, 07 Nov 2006 23:28:54 -0500</pubDate>
        </item>
        
        <item>
            <title>Javascript Puzzler</title>
            <description><![CDATA[<p>
Here's an interesting bug in Internet Explorer I ran across today: </p><blockquote>When using window.location to go to a named anchor inside of an iframe, using a String object versus a string primitive produces different results.</blockquote>  Okay, it's pretty hard to explain, let's look at a demo.  We need two source html files, a main outer page, and a page for the iframe.
<p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/javascript_puzzler.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/javascript_puzzler.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Fri, 04 Aug 2006 19:38:09 -0500</pubDate>
        </item>
        
        <item>
            <title>Firebug without Firefox</title>
            <description><![CDATA[<h3>The problem..</h3>
<p>If I had been allocated one Firefox extension to use, without hesitation it would be Joe Hewitt's <a href="http://www.joehewitt.com/software/firebug">Firebug</a>. But, eventually, I have to test my code in IE (and Safari<sup>1</sup>), and need to debug some DOM or css scripting. Many times I would use the url field to execute Javascript in the page using this method... 
	</p><blockquote>javascript:function(){ /* some code */ }()</blockquote> 
<p>Wrapping the code in a function will prevent variable name collisions. The problem is that this method can get messy and time consuming when trying to inspect elements nested deep within the DOM.</p>]]></description>
            <link>http://www.nearinfinity.com/blogs/jason_harwig/firebug_without_firefox.html</link>
            <guid>http://www.nearinfinity.com/blogs/jason_harwig/firebug_without_firefox.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">JavaScript</category>
            
            
            <pubDate>Sun, 25 Jun 2006 15:52:09 -0500</pubDate>
        </item>
        
    </channel>
</rss>
