<?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>走走停停看看 &#187; Firefox</title>
	<atom:link href="http://shawphy.com/tag/firefox/feed" rel="self" type="application/rss+xml" />
	<link>http://shawphy.com</link>
	<description>关注HTML,CSS,JavaScript,jQuery等前端开发</description>
	<lastBuildDate>Mon, 12 Jul 2010 15:45:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>文件保存后自动刷新浏览器页面</title>
		<link>http://shawphy.com/2010/02/auto-refresh-page-after-saving-file.html</link>
		<comments>http://shawphy.com/2010/02/auto-refresh-page-after-saving-file.html#comments</comments>
		<pubDate>Sun, 28 Feb 2010 15:44:37 +0000</pubDate>
		<dc:creator>Shawphy</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[前端开发]]></category>

		<guid isPermaLink="false">http://shawphy.com/?p=181</guid>
		<description><![CDATA[做前端的就是苦命，前端的键盘最苦命的是F5按键。 每次修改了点页面，写了点代码就要按F5去测试，着实让人崩溃。 除非用DreamWeaver这种工具，或者TopStyle这种，否则就免不了受罪。 这也归罪于微软各个GUI直接通信不良…… 今天找到个方案， 这位达人写了一个Firefox小扩展，用于修改js和host文件的时候用。 原理请参考上面的链接，我就拿来改了一改 敲击这里下载 注意：这个工具只是一个很原始的模型！！ 怎么用呢？ 很简单，在Firefox，打开你所要的页面，这个扩展会不停检测 D:\refresh.firefox 文件， 如果存在这个文件，他就会自动刷新当前页面并删除这个文件。 那么如何创建这个文件呢？ For VIM 如果你是用VIM的，在$MYVIMRC中加入这句话 function! b:AutoRefresh() &#160;&#160; &#160;!start cmd /c echo x &#62; d:\\refresh.firefox &#160;&#160; &#160;syntax on endfunction autocmd BufWritePost,FileWritePost *.html :call b:AutoRefresh() 其中 syntax on &#8230; <a href="http://shawphy.com/2010/02/auto-refresh-page-after-saving-file.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>做前端的就是苦命，前端的键盘最苦命的是F5按键。<br />
每次修改了点页面，写了点代码就要按F5去测试，着实让人崩溃。<br />
除非用DreamWeaver这种工具，或者TopStyle这种，否则就免不了受罪。<br />
这也归罪于微软各个GUI直接通信不良……</p>
<p>今天找到个方案， <a href="http://bluehua.org/2009/04/03/257.html">这位达人</a>写了一个Firefox小扩展，用于修改js和host文件的时候用。<br />
原理请参考上面的链接，我就拿来改了一改</p>
<p><a href="http://shawphy.googlecode.com/files/overlay.xpi">敲击这里下载</a></p>
<p><strong>注意：这个工具只是一个很原始的模型！！</strong></p>
<h3>怎么用呢？</h3>
<p>很简单，在Firefox，打开你所要的页面，这个扩展会不停检测 D:\refresh.firefox 文件，<br />
如果存在这个文件，他就会自动刷新当前页面并删除这个文件。</p>
<h3>那么如何创建这个文件呢？</h3>
<h4>For VIM</h4>
<p>如果你是用VIM的，在$MYVIMRC中加入这句话</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">function! b:AutoRefresh()</li>
<li>&nbsp;&nbsp; &nbsp;!start cmd /c echo x &gt; d:\\refresh.firefox</li>
<li>&nbsp;&nbsp; &nbsp;syntax on</li>
<li>endfunction</li>
<li>autocmd BufWritePost,FileWritePost *.html :call b:AutoRefresh()</li></ol></div>
<p>其中 syntax on 这句是为了可以不会出现一个等待键盘确认的事件。我是参考<a href="http://glacjay.is-a-geek.org/blog/archives/151">这里</a>的<br />
这就让html文件保存的时候生成d:\refresh.firefox文件了</p>
<h4>For Editplus</h4>
<p>如果你像我一样是Editplus用户的话，也很容易。如图<br />
<a href="http://shawphy.com/2010/02/auto-refresh-page-after-saving-file.html/editplus2refreash" rel="attachment wp-att-182"><img src="http://shawphy.com/wp-content/uploads/2010/02/editplus2refreash-300x245.png" alt="" title="editplus2refreash" width="300" height="245" class="alignnone size-medium wp-image-182" /></a><br />
设置Auto Run: After Save里的，添加命令就行了。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">cmd /c echo x &gt;d:\refresh.firefox</li></ol></div>
<p>只不过还是有点后遗症，随便什么文件保存它都会生成……<br />
作为一个不开源，没有插件体系，更新也很不勤快的编辑器……要求也不要太高了……<br />
友情提醒：请使用正版软件~可以在有能力的时候购买许可，或者转用其他开源编辑器，比如Notepad++等。不要让使用盗版成为国内软件开发人员的<a href="http://twitter.com/tinyfool/status/9227064084">原罪</a>……</p>
<h4>For Others</h4>
<p>基本原理都知道了，应该不难办了吧？</p>
<h3>系统资源占用</h3>
<p>实测下来，我E7200，CPU占用率不到1%。这个setInterval还是很节约资源的。</p>
<h3>带来的好处</h3>
<p>仔细想的话，节约的不只一步。你要切换窗口，要按f5，看效果，再切换回来继续调整。但如果你是宽屏或者是编辑器背景透明的话，无需切换就可以完成了。节约的是大把时间。如果是虚拟机或者其他电脑测试的情况下，也可以用局域网共享实现，非常好用。其他浏览器只要提供访问文件的接口，也可以如法炮制。</p>
]]></content:encoded>
			<wfw:commentRss>http://shawphy.com/2010/02/auto-refresh-page-after-saving-file.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>FireUnit:基于Firebug的JavaScript单元测试扩展</title>
		<link>http://shawphy.com/2008/12/fireunit.html</link>
		<comments>http://shawphy.com/2008/12/fireunit.html#comments</comments>
		<pubDate>Thu, 18 Dec 2008 08:43:15 +0000</pubDate>
		<dc:creator>Shawphy</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[FireUnit]]></category>

		<guid isPermaLink="false">http://shawphy.com/?p=128</guid>
		<description><![CDATA[John Resig最近在他的博客中发表文章John Resig &#8211; FireUnit: JavaScript Unit Testing Extension.发布了他与Jan Odvarko合作开发的一款基于Firebug的扩展FireUnit。(Firebug真是越来越强大了……) 简单说来，FireUnit给Firebug增加了一个标签面板，并提供了一些简单的JavaScript API来记录和查看测试。 举例来说： // Simple true-like/false-like testing fireunit.ok(&#160;true, &#34;I'm going to pass!&#34; ); fireunit.ok(&#160;false, &#34;I'm going to fail!&#34; ); &#160; // Compare two strings - shows a diff of the &#8230; <a href="http://shawphy.com/2008/12/fireunit.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>John Resig最近在他的博客中发表文章<a href="http://ejohn.org/blog/fireunit/">John Resig &#8211;   FireUnit: JavaScript Unit Testing Extension</a>.发布了他与<a href="http://www.softwareishard.com/">Jan Odvarko</a>合作开发的一款基于Firebug的扩展<a href="http://fireunit.org/">FireUnit</a>。(Firebug真是越来越强大了……)<br />
简单说来，FireUnit给Firebug增加了一个标签面板，并提供了一些简单的JavaScript API来记录和查看测试。<br />
举例来说：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">// Simple true-like/false-like testing</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">ok</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">true</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">I'm going to pass!</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">ok</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">false</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">I'm going to fail!</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">// Compare two strings - shows a diff of the</span></li>
<li><span style="color: #ffa500;">// results if they're different</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">compare</span><span style="color: Olive;">(</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">The lazy fox jumped over the log.</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">The lazy brown fox jumped the log.</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Are these two strings the same?</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">// Compare a string using a regular expression</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">reCompare</span><span style="color: Olive;">(</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">/</span><span style="color: Red;">The .* fox jumped the log.</span><span style="color: #8b0000;">/</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">The lazy brown fox jumped the log.</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Compare a string using a RegExp.</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">// Display the total results</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">testDone</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li></ol></div>
<p>就可以在Firebug中的Test标签面板中看到下图：</p>
<p style="text-align: center;"><a href="http://ejohn.org/blog/fireunit/"><img src="http://fireunit.org/fireunit-1.png" alt="fireunit测试" /></a></p>
<p>FireUnit还可以模拟触发原生浏览器事件：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">// You can also simulate browser events</span></li>
<li><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;"> = </span><span style="color: Teal;">document</span><span style="color: Gray;">.</span><span style="color: Blue;">getElementsByTagName</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">input</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)[</span><span style="color: Maroon;">0</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">mouseDown</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">focus</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">key</span><span style="color: Olive;">(</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p>此外，可以批量测试文件（每个文件都含有一些独立测试）</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">// Or run multiple pages of tests:</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">runTests</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">test2.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">test3.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">// Place at the end of every test file in order to continue</span></li>
<li><span style="color: Blue;">fireunit</span><span style="color: Gray;">.</span><span style="color: Blue;">testDone</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li></ol></div>
<p style="text-align: center;"><a href="http://ejohn.org/blog/fireunit/"><img src="http://www.softwareishard.com/images/posts/fireunit/fireunit-ui-thumb.png" alt="fireunit批量测试" /></a></p>
<p>推荐把测试代码包含在下面的if语句内</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Green;">typeof</span><span style="color: Gray;"> </span><span style="color: Blue;">fireunit</span><span style="color: Gray;"> === </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">object</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//Your code for test</span></li>
<li><span style="color: Olive;">}</span></li></ol></div>
<p>如果感兴趣，可以访问<a href="http://fireunit.org/">Fireunit.org</a>下载并测试（这个网站内就包含了测试代码，安装后即可看到第一张图的内容）<br />
可以在Github上获取<a href="http://github.com/jeresig/fireunit">源码</a>，得用git而不是svn<br />
Jan也写了一篇<a href="http://www.softwareishard.com/blog/firebug/fireunit-testing-in-the-firebug-world/">文章</a>，可以看看。</p>
]]></content:encoded>
			<wfw:commentRss>http://shawphy.com/2008/12/fireunit.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
