<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Software is hard » Planet Mozilla</title>
	
	<link>http://www.softwareishard.com/blog</link>
	<description>More musings on software development</description>
	<lastBuildDate>Mon, 14 May 2012 17:59:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SoftwareIsHardPlanetMozilla" /><feedburner:info uri="softwareishardplanetmozilla" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Monitor HTTP Traffic on Mobile/Fennec</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/f-ijpjOPJK4/</link>
		<comments>http://www.softwareishard.com/blog/planet-mozilla/monitor-http-traffic-on-mobilefennec/#comments</comments>
		<pubDate>Mon, 14 May 2012 11:19:04 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[HTTP Monitor]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=370</guid>
		<description><![CDATA[I have been recently working on an extension (code name HTTP Monitor) that can be used to intercept HTTP traffic of a browser tab. The extension is based on Firebug's Net panel and is on its way to be embedded in Firefox by default. This post explains how to use HTTP monitor to intercept HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>I have been recently <a href="http://www.softwareishard.com/blog/planet-mozilla/http-monitor/">working</a> on an extension (code name HTTP Monitor) that can be used to intercept HTTP traffic of a browser tab. The extension is based on Firebug's Net panel and is on its way to be embedded in Firefox by default.</p>
<p>This post explains how to use HTTP monitor to intercept HTTP traffic on mobile with Fennec (Firefox for Android) installed.</p>
<p><span id="more-370"></span></p>
<h3>Monitor HTTP traffic on mobile</h3>
<p>HTTP Monitor is Firefox extension and so, you need Fennec installed on your mobile phone. Fennec is compatible with Android 2.2 and above devices.</p>
<p>If you have a <a href="http://www.mozilla.org/en-US/mobile/platforms/">compatible device</a> go ahead and <a href="http://www.mozilla.org/en-US/m/">install Fennec</a> (you need the Nightly channel).</p>
<p>In case of remote debugging you need to <a href="https://github.com/firebug/httpmonitor/downloads">install HTTP Monitor extension</a> on both sides: client and server. In this case, we want to monitor HTTP traffic on mobile (server) and check all results on desktop machine (client).</p>
<p><img src='http://www.softwareishard.com/images/posts/mobile-http-traffic/mobile-http-traffic.png' alt='' class='center' /></p>
<p>There are couple of preferences you need to set through <code>about:config</code>.</p>
<p><strong>Server</strong> (mobile):<br />
<code>extensions.httpmonitor.serverMode</code> set to <strong>true</strong> (you need to restart the browser)<br />
<strong><br />
Client</strong> (desktop):<br />
<code>extensions.httpmonitor.serverHost</code> set to IP address of your phone (<strong>10.0.3.110</strong> in my case).</p>
<p class="bullet">&nbsp;</p>
<p><em>In order to find IP address of your phone follow <b>Settings > Wireless Controls > Wi-Fi settings</b> and tap on the network you are connected to. It'll pop up a dialog with network status, speed, signal strength, security type and IP address.</em></p>
<p class="bullet">&nbsp;</p>
<p>As soon as you are all set (extension installed and preferences set) you can start Fennec on the phone and load a page. In my case I loaded <code>mozilla.org</code>.</p>
<p>Start also Firefox on your desktop machine and open HTTP Monitor console: <em>Web Developer -> HTTP Monitor</em>. There should be a <em>Connect Me</em> button at top left corner of the window.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/mobile-http-traffic/connect-me.png" class="center" /></p>
<p>Both the IP address and port number comes from preferences. Connect your phone and click the other: <em>Select Tab</em> button to pick a tab opened on your phone.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/mobile-http-traffic/select-tab.png" class="center" /></p>
<p>Now reload the tab on your phone and watch the result on the desktop!</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/mobile-http-traffic/watch-results.png" class="center" /></p>
<h3>Mobile HAR File</h3>
<p>Here is an online HAR file showing mozilla.org page load on Samsung Galaxy Nexus:</p>
<div class='harPreviewBox'><iframe class='harPreviewFrame' frameborder='0' height='415px' border='0' src='http://www.janodvarko.cz/har/viewer//preview.php?expand=true&amp;path=/har/examples/posts/mobile-http-traffic/mozilla.org.har'></iframe><div class='harPreviewResizer'></div></div>
<h3>Further Resources</h3>
<ul>
<li><a href="https://github.com/firebug/httpmonitor">Source code</a></li>
<li><a href="https://github.com/firebug/httpmonitor/downloads">Download</a> (always use the latest release)</li>
<li><a href="https://github.com/firebug/httpmonitor/issues">Report</a> an issue</li>
</ul>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/f-ijpjOPJK4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/planet-mozilla/monitor-http-traffic-on-mobilefennec/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/planet-mozilla/monitor-http-traffic-on-mobilefennec/</feedburner:origLink></item>
		<item>
		<title>HTTP Monitor</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/QfEmjFkoiQo/</link>
		<comments>http://www.softwareishard.com/blog/planet-mozilla/http-monitor/#comments</comments>
		<pubDate>Tue, 01 May 2012 08:15:24 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[HTTP Monitor]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=334</guid>
		<description><![CDATA[We have decided to extend cooperation between Firebug and Firefox dev-tools teams (I am a member of both) and so, discussed this topic about four weeks ago at our meeting in London. We agreed that we want to have an effective and synchronized strategy when working on in-browser developer tools. One pillar of the plan [...]]]></description>
			<content:encoded><![CDATA[<p>We have decided to extend cooperation between Firebug and Firefox dev-tools teams (I am a member of both) and so, discussed this topic about four weeks ago at our <a href="http://www.flickr.com/photos/robceemoz/6860765358/in/photostream/lightbox/">meeting</a> in London.</p>
<p>We agreed that we want to have an effective and synchronized strategy when working on in-browser developer tools. One pillar of the plan is sharing APIs, components, modules, code maintenance, etc. to avoid duplicate development effort.</p>
<p>The first step is sharing an independent <em>HTTP tracking component</em> that is based on Firebug's <a href="http://www.softwareishard.com/blog/firebug/introduction-to-firebug-net-panel/">Net panel</a> and can be shared among all tools that want to intercept an analyze HTTP traffic. Firebug and (built-in tools in) Firefox will be its first clients.</p>
<p>So take a look at what we have managed to implement and demonstrate for our Toronto <a href="http://www.flickr.com/photos/robceemoz/7113855919/in/photostream/lightbox/">meeting</a> last week.</p>
<p><span id="more-334"></span></p>
<h3>HTTP Monitor</h3>
<p>We have been hardworking on extracting the Net panel logic since the London meetup and result of the effort is an extension called <em>HTTP Monitor</em>. It's based on Firebug's Net panel and has exactly the same purpose - display HTTP activity of the selected tab to the user. This extension has very simple UI (a XUL window) with content corresponding to what you know from the Net panel.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/httpmonitor/http-monitor-and-firebug.png" class="center" width="520" height="327" /></p>
<p>The extension has two main parts: front-end and a back-end. Both independent and customizable so other tools can use, for example, only the back-end.</p>
<p>Especially tools that are used to automatically collect page performance data (often with Selenium) and don't need the UI can profit from having reliable, simple and built-in HTTP monitor API. Customization of the front-end will be based on Firefox themes (design) and <a href="http://www.softwareishard.com/blog/category/domplate/">Domplate</a> (layout).</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/httpmonitor/http-monitor-architecture.png" class="center" /></p>
<p>These two parts compose the entire <strong>HTTP Monitor component</strong>.</p>
<h3>Local &#038; Remote Monitoring</h3>
<p>As the previous architecture diagram already indicates, support for remote HTTP monitoring is also covered in the concept. Here is a simple list of scenarios that are already supported by HTTP Monitor (beta phase):</p>
<ol>
<li>Tracking HTTP activity of a browser tab running on the same machine.</li>
<li>Tracking HTTP activity of a browser tab running on another machine.</li>
<li>Tracking HTTP activity of a browser tab running on mobile</li>
</ol>
<p><img alt="" src="http://www.softwareishard.com/images/posts/httpmonitor/http-monitor-remoting.png" class="center" /></p>
<p><em>Note: HTTP Monitor extension must be installed on both sides (client/server), see <a href="https://github.com/firebug/httpmonitor/blob/master/README.md">instructions</a>.</em></p>
<p>Communication between Firefox/Fennec instances is based on <a href="http://getfirebug.com/wiki/index.php/Net_Panel_Remoting">HTTP Monitor Remote Protocol</a> (TCP/IP).</p>
<p>Using the extension should be fairly easy for those who are already familiar with the Net panel. The UI/UX is exactly the same, just available in separate XUL window. In order to open the HTTP console window pick <em>Web Developer -> HTTP Monitor</em> (you need to have the extension installed at this moment, it's not yet build in Firefox).</p>
<p>Remote HTTP tracking on Fennec requires Fennec Nightly build.</p>
<h3>Further Resources</h3>
<ul>
<li><a href="https://github.com/firebug/httpmonitor">Source code</a> (GIT, pull requests welcome!)</li>
<li><a href="http://getfirebug.com/wiki/index.php/HTTP_Monitor">Wiki page</a></li>
<li><a href="https://github.com/firebug/httpmonitor/downloads">Download</a> (always use the latest release)</li>
<li><a href="http://getfirebug.com/wiki/index.php/Net_Panel_Remoting">Remote Protocol</a></li>
</ul>
<p>Are you involved in page load performance area? Are you working on HTTP traffic analyzer tools? Do you want to see specific features as part of the HTTP Monitor component?</p>
<p>Then you could be involved in:</p>
<ul>
<li>Automation (<a href="http://www.softwareishard.com/blog/netexport/">NetExport</a>)</li>
<li>Export (HAR) (<a href="http://www.softwareishard.com/blog/netexport/">NetExport</a>)</li>
<li>Remoting</li>
</ul>
<p>Stay tuned! (or <a href="https://github.com/firebug/httpmonitor">watch the repo</a>)</p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/QfEmjFkoiQo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/planet-mozilla/http-monitor/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/planet-mozilla/http-monitor/</feedburner:origLink></item>
		<item>
		<title>MozCamp CZ 2012</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/tcy27i0FBak/</link>
		<comments>http://www.softwareishard.com/blog/firebug/mozcamp-cz-2012/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 07:27:57 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=324</guid>
		<description><![CDATA[I had a chance to attend MozCamp CZ 2012 that happened in Brno last Saturday. It was one day meeting filled with sessions and discussions about Mozilla related stuff. I had also great opportunity to lead a session about Firebug Tips &#038; Tricks where I also mentioned some useful Firebug extensions. Check out my slides [...]]]></description>
			<content:encoded><![CDATA[<p>I had a chance to attend <a href="http://www.mozilla.cz/mozilla/mozcamp-cz-2012/">MozCamp CZ 2012</a> that happened in <a href="http://maps.google.com/maps?oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a&#038;q=brno&#038;um=1&#038;ie=UTF-8&#038;hq=&#038;hnear=0x4712943ac03f5111:0x400af0f6614b1b0,Brno,+Czech+Republic&#038;ei=zPhuT7qkHKmw0QXB8ayNAg&#038;sa=X&#038;oi=geocode_result&#038;ct=title&#038;resnum=2&#038;ved=0CD8Q8gEwAQ">Brno</a> last Saturday. It was one day meeting filled with sessions and discussions about Mozilla related stuff.</p>
<p>I had also great opportunity to lead a session about <strong>Firebug Tips &#038; Tricks</strong> where I also mentioned some useful Firebug <a href="http://getfirebug.com/wiki/index.php/Firebug_Extensions">extensions</a>. Check out my <a href="http://www.softwareishard.com/slides/firebug/MozCampCZ2012/">slides</a> (en-US), but I am not sure how useful they are without me talking <img src='http://www.softwareishard.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>We discussed many interesting topics and here is a brief summary of what stuck in my memory.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/mozcampcz2012/mozcampcz1.png" class="aligncenter" width="520" height="227" /></p>
<ul>
<li>There is <a href="https://affiliates.mozilla.org/en-US/">Firefox Affiliates</a> program for everyone who want to share Firefox with the world</li>
<li>It would be great if US Mozilla dev folks could attend the next time and talk about Firefox related technologies.</li>
<li><strong>Pavel Cvrcek</strong> and <strong>Pavel Franc</strong> spoke about Mozilla in 2012: <a href="http://dnt.mozilla.org/">do not track</a>, <a href="https://browserid.org/">browser ID</a>, <a href="https://www.mozilla.org/en-US/apps/">apps</a>, <a href="https://wiki.mozilla.org/B2G">B2G</a>, <a href="https://www.mozilla.org/cs/mobile/">Firefox for Android</a>
<li>Mozilla's <a href="http://www.mozilla.org/about/mission.html">mission</a> is to promote openness, innovation and opportunity on the web.</li>
<li><strong>Jaroslav Souček</strong> from Seznam.cz spoke about <a href="http://software.seznam.cz/listicka">Seznam Listicka</a> (Firefox extension) and custom <a href="http://software.seznam.cz/firefox">Firefox build</a></li>
<li>Especially B2G got a lot of interest</li>
<li>Transfer my mobile apps from my old phone to a new one easily (across devices)</li>
<li>HTML5 &#038; Video (btw. this <a href="http://hacks.mozilla.org/2012/03/video-mobile-and-the-open-web/">post</a> is quite related)</li>
<li>And of course, <a href="http://getfirebug.com/">Firebug</a> and dev-tools built in Firefox.</li>
</ul>
<p><img alt="" src="http://www.softwareishard.com/images/posts/mozcampcz2012/mozcampcz2.png" class="aligncenter" width="520" height="227" /></p>
<p>If it sounds interesting to you, you should join us the next time! Follow <a href="http://www.mozilla.cz/">Mozilla.cz</a> to know when the next MozCamp CZ happens.</p>
<p><em>Photos provided by Jan Horák (Red Hat)</em></p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/tcy27i0FBak" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug/mozcamp-cz-2012/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug/mozcamp-cz-2012/</feedburner:origLink></item>
		<item>
		<title>Extending Firebug, Hello AMD! (part XII.)</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/aj5K7soo3i0/</link>
		<comments>http://www.softwareishard.com/blog/firebug-tutorial/extending-firebug-hello-amd-part-xii/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 09:33:46 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Extending Firebug Tutorial]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=304</guid>
		<description><![CDATA[Firebug 1.10 introduces new API for building extensions based on Asynchronous Module Definition (AMD) syntax. Firebug itself is already using AMD to improve its internal structure and modularization of the code base. The Asynchronous Module Definition (AMD) API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded. [...]]]></description>
			<content:encoded><![CDATA[<p>Firebug 1.10 introduces new API for building extensions based on <strong>Asynchronous Module Definition</strong> (<a href="https://github.com/amdjs/amdjs-api/wiki/AMD">AMD</a>) syntax. Firebug itself is already using AMD to improve its internal structure and modularization of the code base.</p>
<p><em>The Asynchronous Module Definition (AMD) API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded.</em></p>
<p>One reason why Firebug uses AMD syntax is to support module sharing between Firebug and Firebug Lite. This post explains how to build Firebug extension based on AMD.</p>
<p><span id="more-304"></span></p>
<h3>Hello AMD!</h3>
<p>Let's start with an example extension. It'll be based on XUL Overlay for now to focus only on AMD in this post (next part of the tutorial will be about how to build <em>a bootstrapped</em> Firebug extension based on AMD).</p>
<p>The structure of the extension is following (it's just like standard XUL based extension, you can compare with the one from the <a href="http://www.softwareishard.com/blog/?p=3">first part</a>):</p>
<div class="dean_ch" style="white-space: wrap;">- &lt;extension-directory&gt;<br />
&nbsp; &nbsp; - chrome<br />
&nbsp; &nbsp; &nbsp; &nbsp; - content<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * main.<span class="me1">js</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * mainOverlay.<span class="me1">js</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * mainOverlay.<span class="me1">xul</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * myPanel.<span class="me1">js</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; * chrome.<span class="me1">manifest</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; * install.<span class="me1">rdf</span></div>
<h3>Initialization Sequence</h3>
<p>We are using XUL Overlay to load our extension. See how <em>mainOverlay.xul</em> and <em>mainOverlay.js</em> files look like.</p>
<p><em>mainOverlay.xul</em></p>
<div class="dean_ch" style="white-space: wrap;"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span><span class="re2">?&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;overlay</span> <span class="re0">xmlns</span>=<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;script</span> <span class="re0">type</span>=<span class="st0">&quot;application/x-javascript&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">src</span>=<span class="st0">&quot;chrome://helloamd/content/mainOverlay.js&quot;</span><span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/overlay<span class="re2">&gt;</span></span></span></div>
<p>The overlay loads only <em>mainOverlay.js</em> script file, which looks as follows:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">var</span> config = <span class="br0">&#123;</span>id: <span class="st0">&quot;helloamd@janodvarko.cz&quot;</span><span class="br0">&#125;</span>;<br />
Firebug.<span class="me1">registerExtension</span><span class="br0">&#40;</span><span class="st0">&quot;helloamd&quot;</span>, config<span class="br0">&#41;</span>;</div>
<p>The only thing the extension really needs to do is to register itself, by calling <em>Firebug.registerExtension</em> and Firebug will automatically look for a <em>main</em> module in the same directory to load it.</p>
<p>The first <code>helloamd</code> argument represents extension's name (<em>extName</em>) and is used to construct chrome URL for the main module as follows:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="st0">&quot;chrome://&quot;</span> + extName + <span class="st0">&quot;/content/main&quot;</span></div>
<p>In fact, the loader maps <em>extName</em> to:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="st0">&quot;chrome://&quot;</span> + extName + <span class="st0">&quot;/content&quot;</span></div>
<p>So, <code>helloamd/myPanel</code> module ID is automatically translated to:</p>
<div class="dean_ch" style="white-space: wrap;">chrome://helloamd/content/myPanel.js</div>
<p>(the loader also appends the <em>js</em> file extension)</p>
<p>The main module is using AMD syntax and is responsible for loading further extension modules. In our case we want to load <em>a panel</em> module.</p>
<div class="dean_ch" style="white-space: wrap;">define<span class="br0">&#40;</span><span class="br0">&#91;</span><br />
&nbsp; &nbsp; <span class="st0">&quot;helloamd/myPanel&quot;</span>,<br />
<span class="br0">&#93;</span>,<br />
<span class="kw2">function</span><span class="br0">&#40;</span>MyPanel<span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p><span class="kw2">var</span> theApp =<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; initialize: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// TODO: Extension initialization</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,</p>
<p>&nbsp; &nbsp; shutdown: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// TODO: Extension shutdown</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw1">return</span> theApp;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
<p><em>You'll see in the next part of this tutorial, that the main module looks exactly the same for bootstrapped extensions. Just the Firebug registration won't be done in an overlay.</em></p>
<h3>Panel Implementation</h3>
<p>You should be already familiar with how to implement a new Firebug panel and Firebug model (<a href="http://www.softwareishard.com/blog/firebug-tutorial/extending-firebug-hello-world-part-i/">Part I.</a>) so, the rest of the extension should be very easy. The only difference is that we are using AMD syntax.</p>
<div class="dean_ch" style="white-space: wrap;">define<span class="br0">&#40;</span><span class="br0">&#91;</span><br />
&nbsp; &nbsp; <span class="st0">&quot;firebug/lib/lib&quot;</span>,<br />
&nbsp; &nbsp; <span class="st0">&quot;firebug/lib/trace&quot;</span>,<br />
<span class="br0">&#93;</span>,<br />
<span class="kw2">function</span><span class="br0">&#40;</span>FBL, FBTrace<span class="br0">&#41;</span> <span class="br0">&#123;</span></p>
<p><span class="kw2">function</span> MyPanel<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span><br />
MyPanel.<span class="me1">prototype</span> = FBL.<span class="me1">extend</span><span class="br0">&#40;</span>Firebug.<span class="me1">Panel</span>,<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw3">name</span>: <span class="st0">&quot;helloamd&quot;</span>,<br />
&nbsp; &nbsp; title: <span class="st0">&quot;Hello AMD World!&quot;</span>,</p>
<p>&nbsp; &nbsp; initialize: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Firebug.<span class="me1">Panel</span>.<span class="me1">initialize</span>.<span class="me1">apply</span><span class="br0">&#40;</span><span class="kw1">this</span>, arguments<span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// TODO: Panel initialization (there is one</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// panel instance per browser tab)</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,</p>
<p>&nbsp; &nbsp; destroy: <span class="kw2">function</span><span class="br0">&#40;</span>state<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Firebug.<span class="me1">Panel</span>.<span class="me1">destroy</span>.<span class="me1">apply</span><span class="br0">&#40;</span><span class="kw1">this</span>, arguments<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;</p>
<p>Firebug.<span class="me1">registerPanel</span><span class="br0">&#40;</span>MyPanel<span class="br0">&#41;</span>;<br />
<span class="kw1">return</span> MyPanel;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
<h3>Get HelloAMD! Example Source</h3>
<p>Full source of the example extension is available on <a href="https://github.com/firebug/extension-examples/tree/master/HelloAMD">GitHub</a>.</p>
<p>The example shows also how to:</p>
<ul>
<li>Use Firebug tracing console API (<a href="http://getfirebug.com/wiki/index.php/FBTrace">FBTrace</a>) (logging)</li>
<li>Implement also a new Firebug module</li>
<li>Register a custom stylesheet and use styles in a domplate template.</li>
<li>Localize strings.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/aj5K7soo3i0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug-tutorial/extending-firebug-hello-amd-part-xii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug-tutorial/extending-firebug-hello-amd-part-xii/</feedburner:origLink></item>
		<item>
		<title>Firebug Tip: What font-family is rendered?</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/oUAwoBxPn64/</link>
		<comments>http://www.softwareishard.com/blog/firebug/firebug-tip-what-font-family-is-rendered/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 12:07:08 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firebug Tip]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=269</guid>
		<description><![CDATA[If you are a web designer or if you are at least dealing with fonts time to time, this neat feature should come in handy. The feature is implemented by FireFontFamily, which is a Firebug extension created by Heather Arthur (also a member of the devtools team). So, you need to install it first if [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a web designer or if you are at least dealing with fonts time to time, this neat feature should come in handy.</p>
<p>The feature is implemented by <a href="https://addons.mozilla.org/en-US/firefox/addon/firefontfamily/">FireFontFamily</a>, which is a Firebug extension created by <a href="http://harthur.wordpress.com/">Heather Arthur</a> (also a member of the devtools team). So, you need to install it first if you are interested.<br />
<br/></p>
<p>Simple feature description:</p>
<p style="color: green">Highlights the rendered font-family from the list of font-families for a CSS 'font' or 'font-family' property in Firebug's CSS panel.</p>
<p>And couple of explanatory screenshots. The first one shows the <em>Style</em> side panel when <em>FireFontFamily</em> extension is <strong>not</strong> installed.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/firefontfamily/not-installed.png" class="center sihImageBorder" width="400" height="111" /><br />
<br/></p>
<p>The other one shows the same when <em>FireFontFamily</em> <strong>is</strong> installed.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/firefontfamily/installed.png" class="center sihImageBorder" width="400" height="113" /></p>
<p>See that highlighted font, it's the one actually rendered.</p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/oUAwoBxPn64" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug/firebug-tip-what-font-family-is-rendered/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug/firebug-tip-what-font-family-is-rendered/</feedburner:origLink></item>
		<item>
		<title>Hacking on Firebug</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/ca0TMu90ZR0/</link>
		<comments>http://www.softwareishard.com/blog/firebug/hacking-on-firebug/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 08:42:25 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=261</guid>
		<description><![CDATA[Entire Firebug source base has been moved on github.com last week and we are also adopting a new GIT development workflow. So far, everyone has been truly excited by this change and I believe that it's also much better way how to collaborate with other coders. Firebug is an open source project after all. So, [...]]]></description>
			<content:encoded><![CDATA[<p>Entire Firebug source base has been moved on <a href="https://github.com/firebug/">github.com</a> last week and we are also adopting a new <a href="http://getfirebug.com/wiki/index.php/GIT_Development_Workflow#6._Create_a_Release_Branch.2FTag">GIT development workflow</a>. So far, everyone has been truly excited by this change and I believe that it's also much better way how to collaborate with other coders. Firebug is an open source project after all.</p>
<p>So, for those who are interested at forking Firebug repository, issuing a pull request, developing Firebug extension, etc. here are some basic things to know before you start.</p>
<h3>Firebug Repository</h3>
<p>There are already several repositories in Firebug's account, but the one you are probably interested the most is <strong>firebug</strong></p>
<p><a href="https://github.com/firebug/firebug">https://github.com/firebug/firebug</a></p>
<p>The structure of the repo is following:</p>
<ul>
<li><strong>extension</strong> Firebug extension directory</li>
<li><strong>tests</strong> Firebug automated test files and test harness - <a href="http://getfirebug.com/wiki/index.php/Running_Automated_Test_Suite">FBTest</a></li>
<li><strong>trace</strong> Firebug tracing console - <a href="http://getfirebug.com/wiki/index.php/FBTrace">FBTrace</a></li>
</ul>
<p>Here is how to clone the repository (read only):</p>
<div class="dean_ch" style="white-space: wrap;">$ git clone git://github.com/firebug/firebug.git<br />
$ cd firebug/extension</div>
<h3>Run Firebug From Source</h3>
<p>The <strong>extension</strong> directory contains Firebug extension files and so, you can run Firebug off of it. It's also the best way how to quickly check your code changes.</p>
<ol>
<li>Locate your Firefox <a href="http://kb.mozillazine.org/Profile_folder">profile folder</a></li>
<li>Open <code>extensions/</code> folder, create if it doesn't exist.</li>
<li>Create a new text file and put the full path to your development folder inside. (e.g. <code>C:\firebug\extension\</code> or <code>~/firebug/extension/</code>). Windows users should retain the OS' slash direction, and everyone should remember to include a closing slash and remove any trailing spaces.</li>
<li>Save the file with Firebug ID as it's name <code>firebug@software.joehewitt.com</code></li>
</ol>
<p>Now you can modify the code base, restart Firefox (with Firebug extension installed) and see your changes live.</p>
<h3>Build Firebug XPI</h3>
<p>You probably don't need this that often, but you can also easily build Firebug XPI package. All you need is <a href="http://ant.apache.org/">Apache Ant</a> installed on your machine.</p>
<div class="dean_ch" style="white-space: wrap;">$ cd firebug/extension<br />
$ ant</div>
<p>The result XPI file should be located in <code>./release</code> directory.</p>
<h3>Push!</h3>
<p>And now the most interesting part. You fixed a bug or implemented new API you need in your extension and you want us to pull your changes, commit into Firebug master branch and release! Let's see what you need to do.</p>
<p><em>Update: it's useful to create a separate branch for every contribution you make. (related to #4 and #5)</em></p>
<ol>
<li>First, you need a <a href="http://github.com/signup">GitHub account</a>. It's simple and all the cool kids are already there <img src='http://www.softwareishard.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<br/>
</li>
<li>Fork <a href="https://github.com/firebug/firebug">Firebug repository</a> (see how to <a href="http://help.github.com/fork-a-repo/">fork a repo</a>).<br />
<br/>
</li>
<li>Clone your fork onto your local machine (your URL will be different):
<div class="dean_ch" style="white-space: wrap;">$ git clone git@github.com:janodvarko/firebug.git</div>
</li>
<li>Create a new branch, make your changes, stage/add modified files (e.g. <em>firebug.js</em>) and commit:
<div class="dean_ch" style="white-space: wrap;">$ cd firebug/extension<br />
$ git checkout -b myNewAPI<br />
# Make your changes in firebug.js file now<br />
$ git add content/firebug/firebug.js<br />
$ git commit -m &quot;New API for my extension&quot;</div>
</li>
<li>Push to origin (your public fork), the local branch myNewAPI to the remote branch myNewAPI:
<div class="dean_ch" style="white-space: wrap;">$ git push -u origin myNewAPI</div>
</li>
<li>Send a <a href="http://help.github.com/send-pull-requests/">pull request</a>. We'll review your changes and accept if all is OK!</li>
</ol>
<p>Our release cycle is quick (a release at least every other week) so, your changes can be publicly available pretty soon!</p>
<h3>Or Create a Patch</h3>
<p>If you don't like github.com from some reason you can always create read-only clone (see at the beginning of this post), make your changes and generate a patch:</p>
<div class="dean_ch" style="white-space: wrap;">$ git diff &gt; my-new-api.js</div>
<p>... or using svn:</p>
<div class="dean_ch" style="white-space: wrap;">$ svn diff &gt; my-new-api.js</div>
<p>Finally, create a <a href="http://code.google.com/p/fbug/issues/list">new issue</a> report (Firebug official issue list is still at the same location) and attach your patch. Again, we'll review your changes and accept if all is OK!</p>
<h3>Further Resources</h3>
<ul>
<li>Home: <a href="http://getfirebug.com/">http://getfirebug.com/</a></li>
<li>  Blog: <a href="http://blog.getfirebug.com/">http://blog.getfirebug.com/</a></li>
<li>Twitter: <a href="http://twitter.com/#!/firebugnews">http://twitter.com/#!/firebugnews</a></li>
<li>Discussion Group: <a href="https://groups.google.com/forum/?fromgroups#!forum/firebug">https://groups.google.com/forum/?fromgroups#!forum/firebug</a></li>
<li>Wiki: <a href="http://getfirebug.com/wiki">http://getfirebug.com/wiki</a></li>
<li>Report an Issue: <a href="http://code.google.com/p/fbug/issues/list">http://code.google.com/p/fbug/issues/list</a></li>
<li>Firebug Extensions: <a href="http://getfirebug.com/wiki/index.php/Firebug_Extensions">http://getfirebug.com/wiki/index.php/Firebug_Extensions</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/ca0TMu90ZR0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug/hacking-on-firebug/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug/hacking-on-firebug/</feedburner:origLink></item>
		<item>
		<title>Hunting Zombie Memory Leaks in Firefox</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/LdeoYw63qgs/</link>
		<comments>http://www.softwareishard.com/blog/planet-mozilla/hunting-zombie-memory-leaks-in-firefox/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 07:38:10 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Memory Leaks]]></category>
		<category><![CDATA[Planet Mozilla]]></category>
		<category><![CDATA[Release]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=224</guid>
		<description><![CDATA[I have recently spent some time hunting down memory leaks in Firebug and the most successful way I have found so far has been analyzing CC (Cycle Collector) object graph - graph of objects that are cycle collected. The particular memory leak I have been looking for is called a zombie compartment. In my case, [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently spent some time hunting down memory leaks in Firebug and the most successful way I have found so far has been analyzing CC (Cycle Collector) object graph - graph of objects that are cycle collected.</p>
<p>The particular memory leak I have been looking for is called a <a href="https://developer.mozilla.org/en/Zombie_compartments">zombie compartment</a>. In my case, there is a document living in the memory even if the parent tab has been closed long time ago. Something is still referencing that document object so, it can't be released. The goal here is usually to find that referent. And this is when the CC heap debugging comes to rescue.</p>
<p>The rest of this post describes my extension <a href="https://addons.mozilla.org/en-US/firefox/addon/cycle-collector-analyzer/">CCDump</a> that allows to dynamically analyze CC object graph.<br />
<span id="more-224"></span></p>
<h3>Manual Analysis</h3>
<p>CC heap dump log can be created manually using the following script (you can evaluate it in Firefox Error Console).</p>
<div class="dean_ch" style="white-space: wrap;">window.<span class="me1">QueryInterface</span><span class="br0">&#40;</span>Components.<span class="me1">interfaces</span>.<span class="me1">nsIInterfaceRequestor</span><span class="br0">&#41;</span>.<br />
&nbsp; <span class="me1">getInterface</span><span class="br0">&#40;</span>Components.<span class="me1">interfaces</span>.<span class="me1">nsIDOMWindowUtils</span><span class="br0">&#41;</span>.<br />
&nbsp; <span class="me1">garbageCollect</span><span class="br0">&#40;</span>Components.<span class="me1">classes</span><span class="br0">&#91;</span><span class="st0">&quot;@mozilla.org/cycle-collector-logger;1&quot;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; .<span class="me1">createInstance</span><span class="br0">&#40;</span>Components.<span class="me1">interfaces</span>.<span class="me1">nsICycleCollectorListener</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
<p>A file, something like: <em>cc-edges-1.7104.log</em> is created and path to it logged into the Error Console. This file contains text representation of the entire graph and you can use any text editor to search it.</p>
<p>Manual creation and search is tedious and you can easily spent hours and hours by repeating manual steps: open Firefox, reproduce a memory leak, execute the script to get the log, open the text file, search for zombie document, search for related objects, etc. - without any satisfying results.</p>
<p>That's why I decided to automate the entire process. Thanks to <strong>Olli Pettay</strong> who <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=726346">implemented</a> a new API (introduced in Firefox 13, current Nightly) that allows to dynamically analyze the CC object graph from within an extension.</p>
<h3>Dynamic Analysis</h3>
<p>I implemented a bootstrapped (restart-less) extension that can be installed at the moment when you are experiencing a zombie compartment in your browser session - and immediately (without restart) analyze the current CC graph.</p>
<p><em>You can also use <code>about:memory</code> I order to see zombie compartments.</em></p>
<p><strong>CCDump</strong> extension can be used to search within the object graph and execute queries to get the information you need.</p>
<p>You can download from <a href="https://addons.mozilla.org/en-US/firefox/addon/cycle-collector-analyzer/">AMO</a>, get the <a href="https://github.com/janodvarko/ccdump/downloads">latest build</a>, or <a href="https://github.com/janodvarko/ccdump">clone</a> the source code (BSD License).</p>
<h3>CCDump</h3>
<p>After you install the extension, open: <code>about:ccdump</code></p>
<p>You should see something as follows:</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/ccdump/home.png" class="aligncenter" width="519" height="230" /></p>
<p>You mostly want to start by clicking on <strong>Run CC Analysis</strong> button in the <strong>Home</strong> tab. After you do it, Firefox cycle collector runs three times to clean up garbage and consequently once, with a listener, to collect entire CC graph of objects in the memory. The result object graph is immediately displayed as a table where each entry represents an object.</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/ccdump/graph.png" class="aligncenter" /></p>
<p>Every object has a context menu, just click the black triangle next to the green object label. There are three ways how to query the graph.</p>
<ul>
<li><strong>Show Details</strong> - see detailed information about the object</li>
<li><strong>Show Roots</strong> - get roots that keep this object in the memory</li>
<li><strong>Show Graph</strong> - get all objects that are directly or indirectly related to the object (the result is displayed as an expandable tree).</li>
</ul>
<p><strong>Show Graph</strong> allows to dramatically reduce the object graph to see only related objects and search further only in the sub-graph result.</p>
<p>You can also search the graph. Use a <strong>search box</strong> located at the top right corner. Note that if there is a string in the box the search runs automatically just after analysis (I am typically keeping <code>nsDocument</code> text in the box).</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/ccdump/search-box.png" align="center" /></p>
<p>There are some options:</p>
<ul>
<li><strong>Find Zombie Documents</strong> - search for objects with <code>nsDocument</code> string in the name (i.e. for zombie content documents)</li>
<li><strong>Find Zombie HTTP Elements</strong> - search for objects with <code>http</code> string in the name (i.e. for zombie content nodes)</li>
<li><strong>Clear Search Results</strong> - trash the current search results and show the original table with entire graph.</li>
<li><strong>Case Sensitive</strong> - case sensitive search</li>
<li><strong>Use Regular Expression</strong> - you can also use regular expression to search the graph</li>
</ul>
<p>The next screenshot shows object detail view:</p>
<p><img alt="" src="http://www.softwareishard.com/images/posts/ccdump/details.png" class="aligncenter" /></p>
<ul>
<li><strong>address</strong> unique hexadecimal address of the object. Always clickable thorough the UI</li>
<li><strong>refcount</strong> number of referents</li>
<li><strong>gcmarked</strong> if false CC is OK with freeing the object</li>
<li><strong>root</strong> if true the object is a root</li>
<li><strong>edges</strong> array of objects referenced by this object</li>
<li><strong>owners</strong> array of parent objects referencing this object</li>
</ul>
<p>Where <strong>edges</strong> and <strong>owners</strong> represent relations in the graph.</p>
<p>Any feedback is welcome!</p>
<p><em>What could be yet improved in the UI?<br />
What other queries could be made to the graph?<br />
What other information in the CC graph would help to find and fix a memory leak?</em></p>
<h3>Usage Scenario</h3>
<p>My typical scenario when hunting down zombie compartments looks briefly as follows:</p>
<ol>
<li>Run the browser, reproduce a memory leak</li>
<li>Open <code>about:ccdump</code></li>
<li>Click <code>Run CC Analysis</code> to get the current object graph</li>
<li>Search for <code>nsDocument</code> to see a zombie document object</li>
<li>Show Graph for the zombie document</li>
<li>Search within the result graph for objects that keep it alive</li>
</ol>
<p>The challenge is usually successful identification of an object in the graph and matching it with the corresponding object in the source code. Having more identity information would certainly help. Anyway, this problem should be dramatically reduced as soon as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=722749">Bug 722749</a> i fixed - <em>provide information about where JS object was allocated (source URL &#038; line number).</em></p>
<h3>Resources</h3>
<p>Related resources you might find useful:</p>
<ul>
<li>CCDump Download: <a href="https://github.com/janodvarko/ccdump/downloads/">github.com/janodvarko/ccdump/downloads</a> and <a href="https://addons.mozilla.org/en-US/firefox/addon/cycle-collector-analyzer/">AMO</a></li>
<li>Source Code: <a href="https://github.com/janodvarko/ccdump/">github.com/janodvarko/ccdump</a></li>
<li>Report issue/enhancement: <a href="https://github.com/janodvarko/ccdump/issues/">github.com/janodvarko/ccdump/issues</a></li>
<li><a href="https://wiki.mozilla.org/Performance:Leak_Tools#Cycle_collector_heap_dump">Cycle collector heap dump</a></li>
<li><a href="https://developer.mozilla.org/en/Extensions/Common_causes_of_memory_leaks_in_extensions">Common causes of memory leaks in extensions</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/LdeoYw63qgs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/planet-mozilla/hunting-zombie-memory-leaks-in-firefox/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/planet-mozilla/hunting-zombie-memory-leaks-in-firefox/</feedburner:origLink></item>
		<item>
		<title>Firebug Tip: Observe page redirects</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/iVjTq1Tdy58/</link>
		<comments>http://www.softwareishard.com/blog/firebug/firebug-tip-observe-page-redirects/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 13:10:19 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firebug Tip]]></category>
		<category><![CDATA[NetExport]]></category>
		<category><![CDATA[Planet Mozilla]]></category>
		<category><![CDATA[Net panel]]></category>
		<category><![CDATA[Persist]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=137</guid>
		<description><![CDATA[The Persist feature has been available in Firebug for some time already, but I recently got several questions indicating that it doesn't have the visibility it deserves. So, let's introduce it quickly. Firebug UI resets every time the current browser tab is refreshed or navigated to another page - to show the new state. The [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>Persist</strong> feature has been available in Firebug for some time already, but I recently got several questions indicating that it doesn't have the visibility it deserves. So, let's introduce it quickly.</p>
<p>Firebug UI resets every time the current browser tab is refreshed or navigated to another page - to show the new state. The consequence  is that all Firebug panels trash the content (i.e. the Net or Console panel entries are lost).</p>
<p>This is fine since usually the user doesn't want to keep the entire history. But what in the case when you want to debug the transition process between page loads or <strong>redirects</strong>?</p>
<p>And this is exactly when the <strong>Persist</strong> button becomes practical...</p>
<p><img src="http://www.softwareishard.com/images/posts/persist/persist-button.png" alt="The Persist button" align="center"/></p>
<p><span id="more-137"></span></p>
<h3>Console Panel</h3>
<p>Let's see a simple <a href="http://www.softwareishard.com/images/posts/persist/example.html">example</a> that shows how to utilize the Persist button when debugging <em>onUnload</em> event.</p>
<p>This is a script on our test page</p>
<div class="dean_ch" style="white-space: wrap;">&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;onLoad()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;onUnload()&quot;</span>&gt;<br />
&lt;script type=<span class="st0">&quot;application/javascript&quot;</span>&gt;<br />
<span class="kw2">function</span> <span class="kw3">onLoad</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span><span class="st0">&quot;onLoad&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">function</span> <span class="kw3">onUnload</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span><span class="st0">&quot;onUnload&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
&lt;/script&gt;<br />
&lt;/body&gt;</div>
<p>This is what the Console panel displays if you refresh the page (still the same even if you refresh several times):</p>
<p><img src="http://www.softwareishard.com/images/posts/persist/console-panel1.png" alt="Console panel with Persist disabled." align="center"/></p>
<p>The <em>onUnload</em> log is not displayed since immediately after the page is unloaded the Console panel is cleared - yep a new page is loaded.</p>
<p>And this is what you can see in the Console if you check the Persist button and refresh one more time.</p>
<p><img src="http://www.softwareishard.com/images/posts/persist/console-panel2.png" alt="Console panel with Persist enabled." align="center"/></p>
<p>The clear part is not happening now.</p>
<h3>Net Panel</h3>
<p>Let's use the same <a href="http://www.softwareishard.com/images/posts/persist/example.html">example</a> page and see what the Persist button does in context of the Net panel.</p>
<p>Again, this is what the Net panel shows if you refresh the page:</p>
<p><img src="http://www.softwareishard.com/images/posts/persist/net-panel1.png" alt="Net panel with Persist disabled." align="center"/></p>
<p>And now with Persist mode enabled:</p>
<p><img src="http://www.softwareishard.com/images/posts/persist/net-panel2.png" alt="Net panel with Persist enabled." align="center"/></p>
<p>The previous entries (just one in this particular case) are kept under a special  expandable entry at the top of the Net panel. You can refresh more times or even navigate to a different page and all the HTTP page load history is there.</p>
<p>Note, that the entire Net panel history (multiple page loads) can be exported using <a href="http://www.softwareishard.com/blog/netexport/">NetExport</a> extension and displayed using <a href="http://www.softwareishard.com/blog/har-viewer/">HAR Viewer</a> online tool (individual page loads are preserved and you can compare).</p>
<p><em>Do you think it would make sense to support the Persist feature on another panel too?</em></p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/iVjTq1Tdy58" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug/firebug-tip-observe-page-redirects/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug/firebug-tip-observe-page-redirects/</feedburner:origLink></item>
		<item>
		<title>Firebug 1.8: console.timeStamp()</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/F00bxVnQtzA/</link>
		<comments>http://www.softwareishard.com/blog/firebug/firebug-1-8-console-timestamp/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 11:22:44 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[HAR]]></category>
		<category><![CDATA[NetExport]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=118</guid>
		<description><![CDATA[Firebug 1.8b3 introduces a new API that can be used to create time-stamps during Javascript execution and compare them together with HTTP traffic timing on the timeline in the Net panel: console.timeStamp(); This feature is useful in cases where the developer needs to know when particular piece of Javascript code is executed relatively to the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://getfirebug.com/releases/firebug/1.8/firebug-1.8.0b3.xpi">Firebug 1.8b3</a> introduces a new API that can be used to create time-stamps during Javascript execution and compare them together with HTTP traffic timing on the timeline in the Net panel: <code>console.timeStamp();</code></p>
<p>This feature is useful in cases where the developer needs to know when particular piece of Javascript code is executed relatively to the HTTP request made by web page. Especially in cases when Javascript is loaded through dynamically appended <code>&lt;script&gt;</code> tags or through XHR and evaluated using <code>eval()</code>.</p>
<p>See the following screenshot that shows a time-stamp generated during a page load.</p>
<p><img src="http://www.softwareishard.com/images/posts/timestamp/timestamp.png" alt="Time-stamp generated using console.timeStamp() method." align="center"/></p>
<p>The time stamp is also displayed in the Console panel so, you can compare with other logs.</p>
<p>The rest of this post demonstrates this feature on couple of live examples in detail. So, if you are interested what you can do with Firebug 1.8, read further!</p>
<p><span id="more-118"></span></p>
<h3>Script used in examples</h3>
<p>Before we dive into details, let's define some basic functions used in the examples below.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> addExternalScript<span class="br0">&#40;</span>url<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> script = document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">&quot;script&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; script.<span class="me1">src</span> = url;<br />
&nbsp; &nbsp; document.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">&quot;head&quot;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">appendChild</span><span class="br0">&#40;</span>script<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> sleep<span class="br0">&#40;</span>ms<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> now = <span class="br0">&#40;</span><span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>now + ms<span class="br0">&#41;</span> &gt; <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<ul>
<li><code>addExternalScript</code> This function creates a <code>&lt;script&gt;</code> element and appends it into the document. The element asynchronously fetches the script from an external URL.</li>
<li><code>sleep</code> This functions freezes the JS execution for specified amount of time [ms].</li>
</ul>
<h3>Example 1</h3>
<p>The first <a href="http://www.janodvarko.cz/har/examples/posts/timestamp/example1/example.html">example</a> shows basic usage of <code>console.timeStamp()</code> method. The preview below is the Net panel content (exported using <a href="http://www.softwareishard.com/blog/netexport/">NetExport</a> Firebug extension) when the example page is loaded:</p>
<p>Script on the page looks like as follows:</p>
<div class="dean_ch" style="white-space: wrap;">console.<span class="me1">timeStamp</span><span class="br0">&#40;</span><span class="st0">&quot;Script on the page executed&quot;</span><span class="br0">&#41;</span>;<br />
sleep<span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span>;</div>
<p>The Net panel content (<em>move mouse over the vertical lines to see detailed timing info.</em>):<br />
<div class='harPreviewBox'><iframe class='harPreviewFrame' frameborder='0' height='100px' border='0' src='http://www.janodvarko.cz/har/viewer//preview.php?expand=true&amp;path=/har/examples/posts/timestamp/example1/example.har'></iframe><div class='harPreviewResizer'></div></div></p>
<ul>
<li>Two HTTP requests displayed. One for page document (<em>example.html</em>) and one for attached CSS file (<em>testcase.css</em>).</li>
<li>After the CSS file is loaded, script on the page is executed. This is depicted by the <span style="color:olive">Script on the page executed</span> time-stamp (lines produced by <em>console.timeStamp</em> use olive color).</li>
<li>Javascript execution is frozen for 100 milliseconds.</li>
<li>The page fires <span style="color:blue">DOMContentLoad</span> event.</li>
<li>The page fires <span style="color:red">load</span> event.</li>
</ul>
<h3>Example 2</h3>
<p>This <a href="http://www.janodvarko.cz/har/examples/posts/timestamp/example2/example.html">example</a> demonstrates dynamically inserted <code>&lt;script&gt;</code> element.</p>
<p>Script on the page looks like as follows:</p>
<div class="dean_ch" style="white-space: wrap;">console.<span class="me1">timeStamp</span><span class="br0">&#40;</span><span class="st0">&quot;Script on the page executed&quot;</span><span class="br0">&#41;</span>;<br />
addExternalScript<span class="br0">&#40;</span><span class="st0">&quot;example.js&quot;</span><span class="br0">&#41;</span>;<br />
console.<span class="me1">timeStamp</span><span class="br0">&#40;</span><span class="st0">&quot;External script added&quot;</span><span class="br0">&#41;</span>;<br />
sleep<span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span>;</div>
<p>The <em>example.js</em> file:</p>
<div class="dean_ch" style="white-space: wrap;">console.<span class="me1">timeStamp</span><span class="br0">&#40;</span><span class="st0">'External script executed'</span><span class="br0">&#41;</span>;<br />
sleep<span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="st0">&quot;;</span></div>
<div class='harPreviewBox'><iframe class='harPreviewFrame' frameborder='0' height='100px' border='0' src='http://www.janodvarko.cz/har/viewer//preview.php?expand=true&amp;path=/har/examples/posts/timestamp/example2/example.har'></iframe><div class='harPreviewResizer'></div></div>
<ul>
<li>Three HTTP requests displayed. One for page document (<em>example.html</em>), one for attached CSS file (<em>testcase.css</em>) and one for dynamically inserted script element (<em>example.js</em>).</li>
<li>Just like in the previous example, the first <span style="color:olive">Script on the page executed</span> time-stamp is generated when script on the page is executed.</li>
<li>An external script is added, but it's loaded asynchronously so, we can see the <span style="color:olive">External script added</span> time-stamp immediately after <span style="color:olive">Script on the page executed</span>.</li>
<li>The <em>example.js</em> file starts loading.</li>
<li>The page fires <span style="color:blue">DOMContentLoad</span> event.</li>
<li>The <em>example.js</em> file is loaded and its script evaluated. The result is new <span style="color:olive">External script executed</span> time-stamp.</li>
<li>The external script freezes the page for 100 milliseconds.</li>
<li>The page fires <span style="color:red">load</span> event.</li>
</ul>
<h3>Timeline extent &#038; request grouping</h3>
<p>Let's see yet another <a href="http://www.janodvarko.cz/har/examples/posts/timestamp/example3/example.html">example</a> that explains how requests in the Net panel are grouped in order to preserve reasonable time-extent for the timeline.</p>
<p>In order to avoid endless extent for the waterfall diagram, the Net panel is grouping requests that belongs together (starting a new group if there is a pause in HTTP traffic). Where each group's waterfall starts again from the beginning of the graph. See also <a href="http://www.softwareishard.com/blog/firebug/firebug-net-panel-timings/">this post</a>.</p>
<p>Created time stamps and page events lines are always rendered across request entries in the last group. </p>
<p>See this Net panel log (one group):</p>
<div class='harPreviewBox'><iframe class='harPreviewFrame' frameborder='0' height='100px' border='0' src='http://www.janodvarko.cz/har/viewer//preview.php?expand=true&amp;path=/har/examples/posts/timestamp/example3/example1.har'></iframe><div class='harPreviewResizer'></div></div>
<ul>
<li>There is a <span style="color:olive">time stamp</span> generated long time after the page load event. The timeline extent has been extended to display the <span style="color:olive">time stamp</span>.</li>
<li>Both requests have been done in the same time period and so they belong to the same group.
</ul>
<p>See another Net panel log (two groups):</p>
<div class='harPreviewBox'><iframe class='harPreviewFrame' frameborder='0' height='150px' border='0' src='http://www.janodvarko.cz/har/viewer//preview.php?expand=true&amp;path=/har/examples/posts/timestamp/example3/example2.har'></iframe><div class='harPreviewResizer'></div></div>
<ul>
<li>Two requests executed to load the page (just like in the previous example). Both belong to the same group.</li>
<li>There are another three requests fired some time later. These form a new group.</li>
<li>There is a <span style="color:olive">time stamp</span>, rendered across requests in the last group.</li>
</ul>
<h3>Addendum</h3>
<p>HTTP traffic timing data displayed in the Net panel comes from Firefox network layer (Necko). Unfortunately, the network layer uses different timer than Javascript Date object and these timers can provide a bit different results. Since the <code>console.timeStamp()</code> method is based on the JS Date object, you could notice sometimes that time-stamps is delayed about ~10-30 ms. This should be fixed as soon as <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=570341">bug 570341</a> in Firefox is fixed.</p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/F00bxVnQtzA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/firebug/firebug-1-8-console-timestamp/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/firebug/firebug-1-8-console-timestamp/</feedburner:origLink></item>
		<item>
		<title>Firebug tip: Re-run this stack</title>
		<link>http://feedproxy.google.com/~r/SoftwareIsHardPlanetMozilla/~3/N3AigGlP0yc/</link>
		<comments>http://www.softwareishard.com/blog/planet-mozilla/firebug-tip-re-run-this-stack/#comments</comments>
		<pubDate>Mon, 23 May 2011 18:56:50 +0000</pubDate>
		<dc:creator>Honza</dc:creator>
				<category><![CDATA[Firebug Tip]]></category>
		<category><![CDATA[Planet Mozilla]]></category>

		<guid isPermaLink="false">http://www.softwareishard.com/blog/?p=102</guid>
		<description><![CDATA[Another Firebug feature that would deserve more attention is re-run (introduced here). This neat feature represented by a simple button on Script panel toolbar allows re-execution of the current call-stack you are halted on in the debugger. This helps especially in cases where it's hard to reproduce an action in the UI in order to [...]]]></description>
			<content:encoded><![CDATA[<p>Another Firebug feature that would deserve more attention is <strong>re-run</strong> (introduced <a href="http://blog.getfirebug.com/2010/08/31/firebug-1-7a1/">here</a>). This neat feature represented by a simple button on Script panel toolbar allows re-execution of the current call-stack you are halted on in the debugger. This helps especially in cases where it's hard to reproduce an action in the UI in order to execute specific Javascript function implemented on a page.</p>
<p>Of course, this button is only available when you are stopped at a breakpoint.</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/rerun-button.png" title="Rerun this stack" align="center" /></p>
<p>Lets go through <a href="http://www.softwareishard.com/firebug/tips/rerun/test.html">real example</a> step by step.</p>
<p><span id="more-102"></span></p>
<p class="bullet" />
<p>First, we need to create a breakpoint to break on.</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/example1.png" align="center" /></p>
<p>We have created a breakpoint in a JS function that is called when you press a button on the <a href="http://www.softwareishard.com/firebug/tips/rerun/test.html">example page</a>. Let's pretend that execution of this function is not that simple and the developer needs to go through a complicated scenario to hit the breakpoint.</p>
<p class="bullet" />
<p>Click the button on the example page to hit our breakpoint.</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/example2.png" align="center" /></p>
<p>As you can see within the <strong>Stack</strong> side-panel, there is several function calls on the stack. The bottom/oldest stack is the click event handler that has been executed upon our mouse click.</p>
<p>Since the debugger is sitting at the second <code>console.log</code>, the Console panel contains just one log.</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/example3.png" align="center" /></p>
<p>Now let's imagine the developer wants to perform the execution again. Perhaps another function has been already called and it's necessary to debug that call too. This would require creating another breakpoint higher in the stack and <em>re-execute</em>.</p>
<p><em>Re-execution:  instead of pressing the <em>Continue</em> <img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/continue-btn.png"/> button and so, be forced to repeate the user scenario again, let's click the <b>Rerun</b> <img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/rerun-btn.png"/> button!</em></p>
<p class="bullet" />
<p>Yes, we are again at the same spot.</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/example2.png" align="center" /></p>
<p class="bullet" />
<p>The only evidence that we previously stopped the execution at line 28 and re-ran the stack is the Console Panel that clearly shows only the <em>Hello!</em> text - <em>twice</em>, since the other log has never been reached!</p>
<p><img alt="" src="http://www.softwareishard.com/firebug/tips/rerun/example4.png" align="center" /></p>
<p>Isn't that cool? <img src='http://www.softwareishard.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p class="bullet" />
<p><em>* Firebug 1.7 contains a little bug related to the stack frame list. There are couple more helper frames displayed (used to implement this feature) that should never be visible. <a href="http://getfirebug.com/releases/firebug/1.8/">Firebug 1.8</a> fixes it.</em></p>
<img src="http://feeds.feedburner.com/~r/SoftwareIsHardPlanetMozilla/~4/N3AigGlP0yc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.softwareishard.com/blog/planet-mozilla/firebug-tip-re-run-this-stack/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.softwareishard.com/blog/planet-mozilla/firebug-tip-re-run-this-stack/</feedburner:origLink></item>
	</channel>
</rss>

