<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IDEAL Garden &#187; javascript</title>
	<atom:link href="http://www.zhangkf.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zhangkf.com</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jan 2012 14:02:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>this in Selenium&#8217;s get_eval() method</title>
		<link>http://www.zhangkf.com/2011/05/this-in-get_eval/</link>
		<comments>http://www.zhangkf.com/2011/05/this-in-get_eval/#comments</comments>
		<pubDate>Tue, 10 May 2011 15:52:12 +0000</pubDate>
		<dc:creator>zhangkf</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[selenium]]></category>

		<guid isPermaLink="false">http://kfzhang.thoughtworkers.org/?p=1003</guid>
		<description><![CDATA[At Selenium Ruby site, there is a description for method get_eval(script), as following: Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned. Note &#8230; <a href="http://www.zhangkf.com/2011/05/this-in-get_eval/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://selenium-client.rubyforge.org/" target="_blank">Selenium Ruby</a> site, there is a description for method <strong>get_eval</strong>(script), as following:</p>
<blockquote><p>Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.</p>
<p>Note that, by default, the snippet will run in the context of the &#8220;selenium&#8221; object itself, so <strong><tt>this</tt></strong> will refer to the <a href="http://selenium-client.rubyforge.org/classes/Selenium.html">Selenium</a> object. Use <strong><tt>window</tt></strong> to refer to the window of your application, e.g. <tt>window.document.getElementById(‘foo’)</tt> If you need to use a locator to refer to a single element in your application page, you can use <tt>this.browserbot.findElement("id=foo")</tt> where &#8220;id=foo&#8221; is your locator.</p></blockquote>
<p>The special thing here is the <strong>this</strong> reference, means when invoking method get_eval() to run some javascript snippet, the <strong>this</strong> reference in snippet would refer to (redicted?) caller Selenium object but not the original belonging object.</p>
<p>This does differ from what we already know for window.eval() method, in which javascript snippt this still refer to the original belonging object, see below demo code:</p>
<pre>var a = 0;
window.eval("this.a = 1"); <span style="color: #339966;">// this refers to window object</span>
alert(a); <span style="color: #339966;">// a=1</span>
alert(this.a == a) <span style="color: #339966;">// true</span></pre>
<p>Above code demos <strong>this</strong> is window object itself.</p>
<pre>function A(){};
A.prototype = {
  f1: function(){
    return "f1";
  },
  f2: function(){
    alert(this.f1());
  }
}
var a = new A();
window.eval("a.f2()"); <span style="color: #339966;">// equals to a.f2(), this in f2 refers to a.</span></pre>
<p><span style="color: #000000;">Above code demos </span><strong>this</strong> in a.f2() method still refers to a, but not window object.</p>
<p>Generally, eval() is an <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/eval" target="_blank">evil thing</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhangkf.com/2011/05/this-in-get_eval/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automation Training For TW QA</title>
		<link>http://www.zhangkf.com/2011/04/automation-training-for-tw-qa/</link>
		<comments>http://www.zhangkf.com/2011/04/automation-training-for-tw-qa/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 13:30:03 +0000</pubDate>
		<dc:creator>zhangkf</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[TW]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[ThoughtBlogs]]></category>
		<category><![CDATA[ThoughtWorks]]></category>

		<guid isPermaLink="false">http://kfzhang.thoughtworkers.org/?p=958</guid>
		<description><![CDATA[今天作为酱油党之一（徐X语，还有小刀和LeoShi同行）参加了徐X为TW QA开的Automation Training。 对于Ruby小白的我，跟着QA一起学了一把。 Ruby的包机制，应用的配置环境 Selenium RC的原理，包的四个变种。 在07年就提到过的Page Object 自动化测试具备怎样的特质，才能最大限度的减少QA手工测试的工作量？ Effective QA manageable 最后，徐X介绍了几个月前他研究出的Data Flow大法。简言之，测试不是要去测试事情本身，而是要测试事情结果的确发生。听着象废话，但那张精美手绘图却惊艳得不行。用以作为切分并归纳测试案例的依据。很受用，争取撺掇一篇文章出来。]]></description>
			<content:encoded><![CDATA[<p>今天作为酱油党之一（徐X语，还有<a href="http://iamxiaodao.com/" target="_blank">小刀</a>和LeoShi同行）参加了<a href="http://blog.vincentx.info/" target="_blank">徐X</a>为TW QA开的Automation Training。</p>
<p>对于Ruby小白的我，跟着QA一起学了一把。</p>
<ul>
<li>Ruby的包机制，应用的配置环境</li>
<li>Selenium RC的原理，包的四个变种。</li>
<li>在07年就提到过的<a href="http://www.infoq.com/cn/articles/domain-web-testing" target="_blank">Page Object</a></li>
</ul>
<p>自动化测试具备怎样的特质，才能最大限度的减少QA手工测试的工作量？</p>
<ol>
<li>Effective</li>
<li>QA manageable</li>
</ol>
<p>最后，徐X介绍了几个月前他研究出的Data Flow大法。简言之，测试不是要去测试事情本身，而是要测试事情结果的确发生。听着象废话，但那张精美手绘图却惊艳得不行。用以作为切分并归纳测试案例的依据。很受用，争取撺掇一篇文章出来。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhangkf.com/2011/04/automation-training-for-tw-qa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic SCRIPT and STYLE elements in IE</title>
		<link>http://www.zhangkf.com/2010/09/dynamic-script-and-style-elements-in-ie/</link>
		<comments>http://www.zhangkf.com/2010/09/dynamic-script-and-style-elements-in-ie/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 06:34:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://www.zhangkf.com/?p=873</guid>
		<description><![CDATA[var ss1 = document.createElement('style'); var def = 'body {color: red;}'; ss1.setAttribute("type", "text/css"); if (ss1.styleSheet) { // IE ss1.styleSheet.cssText = def; } else { // the world var tt1 = document.createTextNode(def); ss1.appendChild(tt1); } var hh1 = document.getElementsByTagName('head')[0]; hh1.appendChild(ss1); via Dynamic SCRIPT &#8230; <a href="http://www.zhangkf.com/2010/09/dynamic-script-and-style-elements-in-ie/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="hl-main">
<blockquote>
<pre><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">ss1</span><span class="hl-code"> = </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">createElement</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">style</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">def</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">body {color: red;}</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-identifier">ss1</span><span class="hl-code">.</span><span class="hl-identifier">setAttribute</span><span class="hl-brackets">(</span><span class="hl-quotes">"</span><span class="hl-string">type</span><span class="hl-quotes">"</span><span class="hl-code">, </span><span class="hl-quotes">"</span><span class="hl-string">text/css</span><span class="hl-quotes">"</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">if</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ss1</span><span class="hl-code">.</span><span class="hl-identifier">styleSheet</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">   </span><span class="hl-comment">// IE</span><span class="hl-code">
    </span><span class="hl-identifier">ss1</span><span class="hl-code">.</span><span class="hl-identifier">styleSheet</span><span class="hl-code">.</span><span class="hl-identifier">cssText</span><span class="hl-code"> = </span><span class="hl-identifier">def</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code"> </span><span class="hl-reserved">else</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">                </span><span class="hl-comment">// the world</span><span class="hl-code">
    </span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">tt1</span><span class="hl-code"> = </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">createTextNode</span><span class="hl-brackets">(</span><span class="hl-identifier">def</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">ss1</span><span class="hl-code">.</span><span class="hl-identifier">appendChild</span><span class="hl-brackets">(</span><span class="hl-identifier">tt1</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">hh1</span><span class="hl-code"> = </span><span class="hl-builtin">document</span><span class="hl-code">.</span><span class="hl-identifier">getElementsByTagName</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">head</span><span class="hl-quotes">'</span><span class="hl-brackets">)[</span><span class="hl-number">0</span><span class="hl-brackets">]</span><span class="hl-code">;
</span><span class="hl-identifier">hh1</span><span class="hl-code">.</span><span class="hl-identifier">appendChild</span><span class="hl-brackets">(</span><span class="hl-identifier">ss1</span><span class="hl-brackets">)</span><span class="hl-code">;</span></pre>
</blockquote>
</div>
<p>via <a href="http://www.phpied.com/dynamic-script-and-style-elements-in-ie/">Dynamic SCRIPT and STYLE elements in IE / Stoyan&#8217;s phpied.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhangkf.com/2010/09/dynamic-script-and-style-elements-in-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于动态创建script元素</title>
		<link>http://www.zhangkf.com/2010/07/%e5%85%b3%e4%ba%8e%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%bascript%e5%85%83%e7%b4%a0/</link>
		<comments>http://www.zhangkf.com/2010/07/%e5%85%b3%e4%ba%8e%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%bascript%e5%85%83%e7%b4%a0/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 14:33:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.zhangkf.com/?p=740</guid>
		<description><![CDATA[有时是需要动态创建&#60;script&#62;元素的，比如从第三方动态（在主页面已经加载完毕后）引入js；或者需要从某个地址引入一段document，其中包含script和dom，这里的script需要被动态执行。 找到三个链接： http://www.javaeye.com/topic/37745 http://www.cnblogs.com/xujiaci/archive/2007/12/14/994857.html http://blog.csdn.net/liaoya/archive/2009/01/16/3796217.aspx 然后又发现了这篇，更具重量级的文章： http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/]]></description>
			<content:encoded><![CDATA[<p>有时是需要动态创建&lt;script&gt;元素的，比如从第三方动态（在主页面已经加载完毕后）引入js；或者需要从某个地址引入一段document，其中包含script和dom，这里的script需要被动态执行。</p>
<p>找到三个链接：</p>
<p><a href="http://www.javaeye.com/topic/37745" target="_blank">http://www.javaeye.com/topic/37745</a></p>
<p><a href="http://www.cnblogs.com/xujiaci/archive/2007/12/14/994857.html" target="_blank">http://www.cnblogs.com/xujiaci/archive/2007/12/14/994857.html</a></p>
<p><a href="http://www.cnblogs.com/xujiaci/archive/2007/12/14/994857.html" target="_blank">http://blog.csdn.net/liaoya/archive/2009/01/16/3796217.aspx</a></p>
<p>然后又发现了这篇，更具重量级的文章：</p>
<p><a href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/" target="_blank">http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhangkf.com/2010/07/%e5%85%b3%e4%ba%8e%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%bascript%e5%85%83%e7%b4%a0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

