<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>diogogmt &#187; Open source</title>
	<atom:link href="http://diogogmt.wordpress.com/category/open-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://diogogmt.wordpress.com</link>
	<description>Just another WordPress.com site</description>
	<lastBuildDate>Mon, 21 May 2012 18:47:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='diogogmt.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>diogogmt &#187; Open source</title>
		<link>http://diogogmt.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://diogogmt.wordpress.com/osd.xml" title="diogogmt" />
	<atom:link rel='hub' href='http://diogogmt.wordpress.com/?pushpress=hub'/>
		<item>
		<title>VirtualBox and USB devices, vboxusers.</title>
		<link>http://diogogmt.wordpress.com/2012/05/21/virtualbox-and-usb-devices-vboxusers/</link>
		<comments>http://diogogmt.wordpress.com/2012/05/21/virtualbox-and-usb-devices-vboxusers/#comments</comments>
		<pubDate>Mon, 21 May 2012 18:47:20 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[devices]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vboxusers]]></category>
		<category><![CDATA[virtual box]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=907</guid>
		<description><![CDATA[By default when installing VirtualBox on Ubuntu, you won&#8217;t be able to access USB devices in the VM. To get around that problem is very simple, below are listed the steps needed to get access to USB devices in the VM. First, make sure you have the latest version of the software: Download VirtualBox You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=907&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>By default when installing VirtualBox on Ubuntu, you won&#8217;t be able to access USB devices in the VM.</p>
<p>To get around that problem is very simple, below are listed the steps needed to get access to USB devices in the VM.</p>
<p>First, make sure you have the latest version of the software:<br />
<a href="https://www.virtualbox.org/wiki/Linux_Downloads">Download VirtualBox</a></p>
<p>You also need to install the extension pack:<br />
<a href="http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html#extpack">Get Extension Pack</a></p>
<p>and the Guest Additions:<br />
<a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-guestadditions.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-guestadditions.png?w=300&h=225" alt="" title="virtualbox-guestAdditions" width="300" height="225" class="alignnone size-medium wp-image-908" /></a></p>
<p>Guest Additions <a href="http://www.virtualbox.org/manual/ch04.html">Manual</a></p>
<p>After installing all the extra dependencies, it is time to enable USB access to the VM.</p>
<h1> First </h1>
<p>Right click on the VM and select settings:</p>
<p>You will get this message:</p>
<p><b><i><br />
Failed to access the USB subsystem</p>
<p>VirtualBox is not currently allowed to access USB devices. You can change this by adding your user to the &#8216;vboxusers&#8217; group. Please see the user manual for a more detailed explanation.<br />
</i></b><br />
<a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-error.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-error.png?w=300&h=234" alt="" title="virtualbox-error" width="300" height="234" class="alignnone size-medium wp-image-909" /></a></p>
<p>It tells that you need to add your user to the vboxusers group.</p>
<h1> Second </h1>
<p>There are two ways to add users to groups in Ubuntu.<br />
Via the GUI</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups1.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups1.png?w=300&h=225" alt="" title="virtualbox-groups1" width="300" height="225" class="alignnone size-medium wp-image-910" /></a></p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups2.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups2.png?w=300&h=227" alt="" title="virtualbox-groups2" width="300" height="227" class="alignnone size-medium wp-image-911" /></a></p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups3.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups3.png?w=300&h=209" alt="" title="virtualbox-groups3" width="300" height="209" class="alignnone size-medium wp-image-912" /></a></p>
<p>If you want something faster, it is also possible to add a user to a group via the command line:<br />
<a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups4.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups4.png?w=300&h=211" alt="" title="virtualbox-groups4" width="300" height="211" class="alignnone size-medium wp-image-913" /></a></p>
<p>After adding the user to the vboxusers group you need to restart Ubuntu.</p>
<h1> Third </h1>
<p>Now after adding the user to the vboxusers group, it is time to select which USB device you want to mount in the VM</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb01.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb01.png?w=300&h=195" alt="" title="virtualbox-usb01" width="300" height="195" class="alignnone size-medium wp-image-914" /></a></p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb02.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb02.png?w=300&h=222" alt="" title="virtualbox-usb02" width="300" height="222" class="alignnone size-medium wp-image-915" /></a></p>
<h1> Forth </h1>
<p>Access USB devices in the VM</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb03.png"><img src="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb03.png?w=300&h=108" alt="" title="virtualbox-usb03" width="300" height="108" class="alignnone size-medium wp-image-916" /></a></p>
<p>More Info:<br />
<a href="http://www.howtogeek.com/howto/31726/mount-usb-devices-in-virtualbox-with-ubuntu/">http://www.howtogeek.com/howto/31726/mount-usb-devices-in-virtualbox-with-ubuntu/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/907/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/907/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/907/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=907&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/05/21/virtualbox-and-usb-devices-vboxusers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-guestadditions.png?w=300" medium="image">
			<media:title type="html">virtualbox-guestAdditions</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-error.png?w=300" medium="image">
			<media:title type="html">virtualbox-error</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups1.png?w=300" medium="image">
			<media:title type="html">virtualbox-groups1</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups2.png?w=300" medium="image">
			<media:title type="html">virtualbox-groups2</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups3.png?w=300" medium="image">
			<media:title type="html">virtualbox-groups3</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-groups4.png?w=300" medium="image">
			<media:title type="html">virtualbox-groups4</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb01.png?w=300" medium="image">
			<media:title type="html">virtualbox-usb01</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb02.png?w=300" medium="image">
			<media:title type="html">virtualbox-usb02</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/virtualbox-usb03.png?w=300" medium="image">
			<media:title type="html">virtualbox-usb03</media:title>
		</media:content>
	</item>
		<item>
		<title>Running node.js on port 80 with apache</title>
		<link>http://diogogmt.wordpress.com/2012/05/21/running-node-on-port-80-with-apache/</link>
		<comments>http://diogogmt.wordpress.com/2012/05/21/running-node-on-port-80-with-apache/#comments</comments>
		<pubDate>Mon, 21 May 2012 17:18:29 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[port 80]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[mod proxy]]></category>
		<category><![CDATA[vhost]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=898</guid>
		<description><![CDATA[This weekend I was faced with the task of putting a nodejs application into production mode. Most of the development happened offline with each developer running local instances of node and using git to synchronize the code, so we didn&#8217;t have the problem of configuring node in a centralized server. Now that the development stage [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=898&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This weekend I was faced with the task of putting a nodejs application into production mode.<br />
Most of the development happened offline with each developer running local instances of node and using git to synchronize the code, so we didn&#8217;t have the problem of configuring node in a centralized server. Now that the development stage is over, we needed to set the project into production mode.</p>
<p>We already use <a href="http://www.linode.com/">Linode</a> to host some of our projects, so we decided to host the nodejs project there as well.</p>
<p>All of our current projects are being served via apache.</p>
<p>The problem is that we can&#8217;t set apache and node to listen on the same port (80) and we didn&#8217;t have the option of deactivating apache to run just node.</p>
<p>We decided to implement a quick solution to get both apache and node working together: <b>Proxy mode</b></p>
<p>So apache can still listen on port 80, and whenever somebody requests the nodejs application we forward the request to the port node is listening, in our case 11342.</p>
<p>Below are the steps needed to get apache and node running on the same server:</p>
<p>Assuming you already have apache2 installed and the nodejs application set up.</p>
<h1> Load proxy modules </h1>
<p>Load the proxy modules that will forward the request to node:<br />
Open the file apache2.conf<br />
Usually the file is located in the dir /etc/apache2/<br />
If you not sure where the file is:<br />
<pre class="brush: bash;">
cd /
sudo find -name &quot;apache2.conf&quot;
</pre></p>
<p>After opening, append the following lines at the bottom of the file:</p>
<p><pre class="brush: bash;">
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
</pre></p>
<p>Without adding those modules, if you try to start apache you will get this message:<br />
<b><i><br />
Syntax error on line 6 of /etc/apache2/sites-enabled/mysite.com:<br />
Invalid command &#8216;ProxyRequests&#8217;, perhaps misspelled or defined by a module not included in the server configuration<br />
Action &#8216;configtest&#8217; failed.<br />
The Apache error log may have more information.<br />
&#8230;fail!<br />
</i></b></p>
<h1> Configure the vhost </h1>
<p>Now that you have the required modules running, it is time to configure the vhost</p>
<p>To add a vhost to apache you need to create a file in /etc/apache2/sites-available</p>
<p><pre class="brush: bash;">
&lt;VirtualHost *:80&gt;
     ServerAdmin your@email.com
     ServerName mysite.com
     ServerAlias www.mysite.com

     ProxyRequests off

     &lt;Proxy *&gt;
          Order deny,allow
          Allow from all
     &lt;/Proxy&gt;

     &lt;Location /&gt;
           ProxyPass http://localhost:11342/
           ProxyPassReverse http://localhost:11342/
     &lt;/Location&gt;
     DocumentRoot /srv/www/mysite/public_html/
     ErrorLog /srv/www/mysite/logs/error.log
     CustomLog /srv/www/mysite/logs/access.log combined
&lt;/VirtualHost&gt;
</pre></p>
<p>First you specify that all requests on port 80, to the domain mysite.com should be forward to localhost at port 11342</p>
<h1> Enable the vhost </h1>
<p>Now you need to enable the new vhost:</p>
<p><pre class="brush: bash;">
a2ensite siteName
</pre></p>
<p>A link will be created in the sites-enabled dir</p>
<p>to disable the site:</p>
<p><pre class="brush: bash;">
a2dissite siteName
</pre></p>
<h1> Restart apache </h1>
<p>Last thing you need to do is restart apache:</p>
<p><pre class="brush: bash;">
service apache2 reload
</pre></p>
<p><b><i><br />
You should get the message:<br />
* Reloading web server config apache2 [ OK ]<br />
</i></b></p>
<p>References:</p>
<p><a href="http://www.ehow.com/how_5458585_configure-modproxy.html">http://www.ehow.com/how_5458585_configure-modproxy.html</a><br />
<a href="http://karrigell.sourceforge.net/en/proxy.html">http://karrigell.sourceforge.net/en/proxy.html</a><br />
<a href="http://davybrion.com/blog/2012/01/hosting-a-node-js-site-through-apache/">http://davybrion.com/blog/2012/01/hosting-a-node-js-site-through-apache/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/898/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=898&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/05/21/running-node-on-port-80-with-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing Lua on Ubuntu</title>
		<link>http://diogogmt.wordpress.com/2012/05/14/installing-lua-on-ubuntu/</link>
		<comments>http://diogogmt.wordpress.com/2012/05/14/installing-lua-on-ubuntu/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:32:33 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[readline]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=869</guid>
		<description><![CDATA[I&#8217;ve been hearing about Lua for a few years now, but I never took the time to sit down and read more about the language, the only thing I knew was that WoW used it, and that it was created by a group of teachers in Brazil Speaking with my brother in law, that now [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=869&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hearing about Lua for a few years now, but I never took the time to sit down and read more about the language, the only thing I knew was that WoW used it, and that it was created by a <a href="http://www.lua.org/authors.html">group</a> of teachers in Brazil</p>
<p>Speaking with my brother in law, that now works in the same university as the teachers that created Lua, recommended to me a <a href="http://grokpodcast.com/2012/04/13/episodio-67-a-linguagem-lua-parte-1-de-3/">podcast</a> where the main creator of Lua talks about the language in general.</p>
<p>The podcast is VERY good, <a href="http://www.inf.puc-rio.br/~roberto/">Roberto Ierusalimschy</a> explains why he created Lua, all the architectural design behind it, his philosophy regarding the project, some good use cases for the language and the future for Lua(the podcast is in Portuguese)</p>
<p>After listening to the podcast, I was really surprised to hear that Lua&#8217;s only data structure is Tables, much like the object notation in javscript, and that a lot of features in the new JS engines today are somewhat derived from Lua.<br />
I decided to give a try and play a bit with the language.</p>
<p>Bellow is a simple tutorial to get Lua up and running on Ubuntu</p>
<h2>Installing Lua</h2>
<p>There are a few different ways you can install Lua on your machine, I decided to get the source code and compile it.<br />
Lua it self is not that big, ~20,000 lines of code.</p>
<p>You can download the code <a href="http://www.lua.org/ftp/">here</a>:</p>
<p>I downloaded the latest stable version, 5.2.0</p>
<p>After downloading/extracting, you&#8217;ll ge this files:</p>
<p><pre class="brush: bash;">
/doc
Makefile
README
src
</pre></p>
<p>All it takes to compile Lua is a simple:</p>
<p><pre class="brush: bash;">
make linux test
</pre></p>
<p><strong>linux</strong> species which platform you want to build.<br />
The complete list of supported platforms:</p>
<ul>
<li>aix</li>
<li>ansi</li>
<li>bsd</li>
<li>freebsd</li>
<li>generic</li>
<li>linux</li>
<li>macosx</li>
<li>mingw</li>
<li>posix</li>
<li>solaris</li>
</ul>
<p><strong>test</strong> just prints the version of Lua to stdout</p>
<p>After compiling, the Lua executable will be created in your /src dir</p>
<p>To open the Lua shell: <strong><em>./lua</em></strong></p>
<p>*If you want to add the lua executable to your path there are several different ways to do it. A simple way is to create a symbolic link to lua in your $HOME/bin dir. It will automatically add lua to your PATH next time you log in</p>
<p>**You might get this error if you don&#8217;t have the <a href="http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html">readline</a> lib installed:<br />
<a href="http://diogogmt.files.wordpress.com/2012/05/lua-install1.png"><img class="alignnone size-medium wp-image-870" title="lua-install1" src="http://diogogmt.files.wordpress.com/2012/05/lua-install1.png?w=238&h=300" alt="" width="238" height="300" /></a></p>
<p>To install the readline lib:</p>
<p><pre class="brush: bash;">
sudo apt-get install libreadline5-dev
</pre></p>
<p>After installing the lib, you should get this output:<br />
<a href="http://diogogmt.files.wordpress.com/2012/05/lua-install2.png"><img class="alignnone size-medium wp-image-871" title="lua-install2" src="http://diogogmt.files.wordpress.com/2012/05/lua-install2.png?w=300&h=109" alt="" width="300" height="109" /></a></p>
<p>If you don&#8217;t want to install the readline lib, you can make a few modifications to their build system:<br />
Changing src/Makefile</p>
<p><pre class="brush: bash;">
linux:
  $(MAKE) $(ALL) SYSCFLAGS=&quot;-DLUA_USE_LINUX&quot; SYSLIBS=&quot;-Wl,-E -ldl -lreadline -lncurses&quot;
</pre></p>
<p>to</p>
<p><pre class="brush: bash;">
linux:
  $(MAKE) $(ALL) SYSCFLAGS=&quot;-DLUA_USE_LINUX&quot; SYSLIBS=&quot;-Wl,-E -ldl -lncurses&quot;
</pre></p>
<p>also removing the lib from src/luaconf.h</p>
<p><pre class="brush: cpp;">
#if defined(Lua_USE_LINUX)
#define Lua_USE_POSIX
#define Lua_USE_DLOPEN    /* needs an extra library: -ldl */
#define Lua_USE_READLINE  /* needs some extra libraries */
#define Lua_USE_STRTODHEX /* assume 'strtod' handles hexa formats */
#define Lua_USE_AFORMAT   /* assume 'printf' handles 'aA' specifiers */
#define Lua_USE_LONGLONG  /* assume support for long long */
#endif
</pre></p>
<p>or just do a:</p>
<p><pre class="brush: bash;">
make ansi
</pre></p>
<p>More info <a href="http://lua-users.org/lists/lua-l/2008-05/msg00312.html">here.</a></p>
<h2>Running Some Programs:</h2>
<p>To get started, lets run the famous Hello World program.<br />
In Lua, all it takes is a simple:</p>
<p><pre class="brush: jscript;">
print(&quot;Hello World!&quot;)
</pre></p>
<p>To run the program:</p>
<p><pre class="brush: bash;">
lua hello-world.lua
</pre></p>
<p>Another example using tables:</p>
<p><pre class="brush: jscript;">
obj = {
  a = 1,
  b = {
    str = &quot;b1&quot;,
    dec = 2.1
  },
  c = 3,
  f = function (x)
        return x*2
      end
}

for index,value in pairs(obj) do print(index,value) end

print(obj.f(2))
print(obj.b.str)
print(obj.b.dec)
</pre></p>
<p><a href="http://diogogmt.files.wordpress.com/2012/05/lua-tables.png"><img class="alignnone size-medium wp-image-872" title="lua-tables" src="http://diogogmt.files.wordpress.com/2012/05/lua-tables.png?w=300&h=90" alt="" width="300" height="90" /></a></p>
<p>Much like in javascript, you can create tables using the object notation: { }</p>
<p>You can think of tables as an associative array, a key value pair structure, just like a hash.</p>
<p>That&#8217;s very powerful and gives a lot of flexibility when writing programs.<br />
You can create very complex data structures with a few lines of code.</p>
<h2>Use Cases</h2>
<p>The Lua project has more than 15 year of existence, being tested and used by several different companies</p>
<p>Adobe has more than 100 engineers working specifically with Lua.<br />
The Adobe Light Room was mainly written in Lua.</p>
<p><a href="http://en.wikipedia.org/wiki/Huawei">Huawei</a>, the second largest network and telecommunications equipment company in the world has more than 1 million lines of Lua written in their products</p>
<p>Some other well known projects that use Lua are:</p>
<ul>
<li><a href="http://www.wireshark.org/">Wireshark</a></li>
<li><a href="http://www.apache.org/">Apache</a></li>
<li><a href="http://redis.io/">Redis</a></li>
<li><a href="http://www.videolan.org/vlc/index.html">VLC player</a></li>
<li>+ a bunch of others</li>
</ul>
<p>The list of games is huge, close to a total of 160 different titles:</p>
<ul>
<li><a href="http://us.blizzard.com/en-us/games/wow/">World of WarCraft</a></li>
<li><a href="http://thesims2.ea.com/">The Sims 2</a></li>
<li><a href="http://www.starwars.com/explore/video-games/">Star Wars</a></li>
<li><a href="http://www.mafia2game.com/">Mafia ||</a></li>
<li><a href="http://www.rockstargames.com/lanoire/agegate/ref/?redirect=">L.A Noire</a></li>
<li><a href="http://farcry2game.com/">Far Cry</a></li>
<li><a href="http://www.ea.com/crysis">Crysis</a></li>
</ul>
<p>You can check the complete list <a href="https://sites.google.com/site/marbux/home/where-lua-is-used">here</a>:</p>
<h2>Lua and the Web</h2>
<p>What got me really excited about Lua, was the fact that it can also be used as a web server.<br />
Actually, some <a href="http://bnpcs.blogspot.ca/2010/05/nodejs-vs-lua-microbenchmarking.html">benchmarks</a> show that Lua can be up to 3 times faster than node.js and the VM is also a lot smaller than node.</p>
<p>There are a few projects that started porting Lua to be much like a nodejs server. Using the Lua VM instead of the V8 engine, but keeping all the awesome architecture existing in node</p>
<p>One of the projects is <a href="https://github.com/luvit/luvit">Luvit</a>.<br />
The project is still on its <a href="http://lua-list.2524044.n2.nabble.com/ANN-Luvit-Lua-UV-Jit-NodeJS-re-implemented-in-Lua-td7048032.html">early</a> stages of dev, but looks very promising <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Other cool projects involving Lua:<br />
<a href="https://github.com/javierguerragiraldez/lualibevent/">LuaLibEvent</a><br />
<a href="https://github.com/brimworks/lua-ev">lua-ev</a><br />
<a href="https://github.com/ignacio/LuaNode">LuaNode</a><br />
<a href="http://json.luaforge.net/">JSON4Lua</a><br />
<a href="http://www.nessie.de/mroth/lunit/">lunit</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/869/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=869&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/05/14/installing-lua-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/lua-install1.png?w=238" medium="image">
			<media:title type="html">lua-install1</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/lua-install2.png?w=300" medium="image">
			<media:title type="html">lua-install2</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/05/lua-tables.png?w=300" medium="image">
			<media:title type="html">lua-tables</media:title>
		</media:content>
	</item>
		<item>
		<title>DPS911 Summary</title>
		<link>http://diogogmt.wordpress.com/2012/04/18/dps911-summary/</link>
		<comments>http://diogogmt.wordpress.com/2012/04/18/dps911-summary/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 20:51:21 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=808</guid>
		<description><![CDATA[I wanted to do a quick summary of what I did this semester on the DPS911 course and what are my plans for the future. First, I want to talk about Firefox. Last semester I had the opportunity to get started with Firefox developemnt. The first bug I worked on was the PointerLock. We started [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=808&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to do a quick summary of what I did this semester on the DPS911 course and what are my plans for the future.</p>
<p>First, I want to talk about Firefox.<br />
Last semester I had the opportunity to get started with Firefox developemnt.<br />
The first bug I worked on was the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">PointerLock</a>. We started hacking PointerLock last November, and I&#8217;m really happy to say that after 6 months of hard work it finally landed and it&#8217;s expected to ship on firefox 14. Thanks for everybody involved on the bug, it was an awesome experience <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
** You can find more info about the whole process of the PointerLock implementation <a href="http://vocamus.net/dave/?cat=28">here.</a><br />
Now that it&#8217;s over, I realize how unique was this opportunity, and that was one of the reasons I kept pursuing it until the end. I learned so much and met so many smart people during the process that I&#8217;m glad to have chosen this path, and if I could I would do everything again.</p>
<p>Besides working on PointerLock, this semester for the DPS911 course I found some other bugs to hack.<br />
This is a list of all the bugs I was involved during the semester:</p>
<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=581863">Bug 581863</a> &#8211; gtk2/nsWindow::GetScreenBounds returns client window size instead of outer (frame) size</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=581866">Bug 581866</a> &#8211; outerWidth / outerHeight features in window.openDialog do not include window manager decorations</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">Bug 633602</a> &#8211; Implement Pointer Lock (Mouse Lock) API</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=712225">Bug 712225</a> &#8211; When element is in fullscreen mode, window.innerHeight is bigger than window.outerHeight</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=715141">Bug 715141</a> &#8211; Using keyboard to switch zoom level when viewing images directly</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=718133">Bug 718133</a> &#8211; Remove keyboard shortcuts for zooming to 1:1 scale when viewing standalone images</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=713383">Bug 713383</a> &#8211; Directly viewed images should be printed with a transparent background on the body</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=713608">Bug 713608</a> &#8211; HTML5 Video controls are missing in Fullscreen</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=714071">Bug 714071</a> &#8211; The Show Statistics setting is not preserved when toggling the full screen mode</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=728893">Bug 728893</a> &#8211; Allow mochitest iframe to go fullscreen</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=724108">Bug 724108</a> &#8211; Exception is thrown when showing statistics on a loading video</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=735031">Bug 735031</a> &#8211; Fullscreen API implementation assumes an HTML Element</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=739874">Bug 739874</a> &#8211; Input type &#8220;password&#8221; doesn&#8217;t receive Focus event with a mouse click</li>
</ul>
<h3>Status of the Bugs:</h3>
<p>From the list above, the following bugs were landed:</p>
<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"><strong>633602</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=715141"><strong>715141</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=718133"><strong>718133</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=713383"><strong>713383</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=714071"><strong>714071</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=728893"><strong>728893</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=735031"><strong>735031</strong></a></li>
</ul>
<p>I&#8217;m still working on bugs:</p>
<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=581863"><strong>581863</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=581866"><strong>581866</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=712225"><strong>712225</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=713608"><strong>713608</strong></a></li>
</ul>
<p>and I filed bugs:</p>
<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=712225"><strong>712225</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=728893"><strong>728893</strong></a></li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=724108"><strong>724108</strong></a></li>
</ul>
<h3>Blog posts related to Firefox development:</h3>
<p><a href="http://diogogmt.wordpress.com/2012/01/22/creating-my-first-firefox-patch/">Creating my first Firefox patch</a><br />
<a href="http://diogogmt.wordpress.com/2012/01/31/synthesizing-mouse-events-in-a-mochitest/">Synthesizing mouse events in a mochitest</a><br />
<a href="http://diogogmt.wordpress.com/2012/02/02/dps911-update/">DPS911 Update</a><br />
<a href="http://diogogmt.wordpress.com/2012/02/03/firefox-bug-714071/">Firefox Bug 714071</a><br />
<a href="http://diogogmt.wordpress.com/2012/02/13/bug-713608-update/">Bug 713608 Update</a><br />
<a href="http://diogogmt.wordpress.com/2012/02/15/updating-pointerlock-api-callbacks-events-and-threads/">Updating PointerLock API – Callbacks, Events and Threads</a><br />
<a href="http://diogogmt.wordpress.com/2012/02/21/pointerlock-api-updates/">PointerLock API Updates</a><br />
<a href="http://diogogmt.wordpress.com/2012/03/13/bug-728893-allow-mochitest-iframe-to-go-fullscreen/">Bug 728893 – Allow mochitest iframe to go fullscreen</a><br />
<a href="http://diogogmt.wordpress.com/2012/04/02/bug-735031-fullscreen-api-implementation-assumes-an-html-element/">Bug 735031 – Fullscreen API implementation assumes an HTML Element</a></p>
<h3>MongooseJS</h3>
<p>Besides working on Firefox bugs, I worked on a bug on the <a href="http://mongoosejs.com/">mongooseJS</a> library:</p>
<p><a href="https://github.com/LearnBoost/mongoose/issues/718">Ticket</a> <strong>#718</strong> &#8211; Add multiple validators to a Schema field<br />
<a href="https://github.com/LearnBoost/mongoose/pull/721"><strong>Solution</strong></a></p>
<p>I wrote about the bug fix here:<br />
<a href="http://diogogmt.wordpress.com/2012/02/06/contributing-to-an-open-source-project/">MongooseJs Validators &#8211; Contributing to an open source project</a></p>
<p>Some other projects I worked during the semester:<br />
<a href="http://diogogmt.wordpress.com/2012/03/19/simple-drawing-application-with-processingjs-part-i/">Simple Drawing Application with ProcessingJS, part I</a></p>
<p><a href="http://diogogmt.wordpress.com/2012/03/31/visualizing-algorithms-using-processing-js/">Visualizing algorithms using Processing.js</a></p>
<p><a href="http://diogogmt.wordpress.com/2012/04/18/visualizing-algorithms-using-processing-js-part-ii/">Visualizing algorithms using Processing.js , part II</a></p>
<h3>What&#8217;s next?</h3>
<ul>
<li>Finish the bugs I have started</li>
<li>Find more bugs</li>
<li>Keep hacking <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>One of the areas I want to get involved in Firefox is the <a href="https://developer.mozilla.org/en/SpiderMonkey">SpiderMonkey</a> Javascript engine<br />
I also want to keep working on bugs related to the DOM and Events in general.</p>
<p>**Two readings that I really recommend:<br />
<a href="http://jstenback.wordpress.com/2012/04/07/history-of-mozillas-dom-bindings/">History of Mozilla&#8217;s DOM bindings</a><br />
<a href="http://jstenback.wordpress.com/2012/04/11/new-dom-bindings/">New DOM bindings</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/808/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/808/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/808/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=808&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/04/18/dps911-summary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>
	</item>
		<item>
		<title>DPS911 Reflections</title>
		<link>http://diogogmt.wordpress.com/2012/04/12/dps911-reflections/</link>
		<comments>http://diogogmt.wordpress.com/2012/04/12/dps911-reflections/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 10:46:52 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=798</guid>
		<description><![CDATA[The DPS911 course is coming to an end and now it&#8217;s time to reflect on the whole semester. Personally, I couldn&#8217;t be happier with the results. I learned several things during the process, and most important, I was able to apply them in other courses as well. For example: Git GitHub Mercurial IRC Bugzilla Blog [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=798&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The DPS911 course is coming to an end and now it&#8217;s time to reflect on the whole semester.</p>
<p>Personally, I couldn&#8217;t be happier with the results.<br />
I learned several things during the process, and most important, I was able to apply them in other courses as well.<br />
For example:</p>
<ul>
<li>Git</li>
<li>GitHub</li>
<li>Mercurial</li>
<li>IRC</li>
<li>Bugzilla</li>
<li>Blog</li>
<li>Twitter</li>
<li>Javascript</li>
<li>OpenSource</li>
</ul>
<h3></h3>
<h3>GitHub</h3>
<p>After being introduced to GitHub last semester on the DPS901 class, I was able to apply that knowledge and use github to contribute to some projects and to use on personal projects as well</p>
<h3></h3>
<h3>GIT</h3>
<p>One of the things I always here is that schools don&#8217;t teach students how to use version control systems, and that usually turns out to be a problem when looking for a job. Well, I&#8217;m very fortunate to say that I had an awesome introduction to GIT on DPS901 that showed me not only how to use the tools in a technical perspective, but also how to use to organize a project and optimize the development time.</p>
<h3></h3>
<h3>Mercurial</h3>
<p>Since Mozilla uses mercurial as its version control software I had to quickly learn how to use the tool. It wasn&#8217;t easy, but applying the concepts I learned last semester with GIT and with the help of the Mozilla community I was able to get started.</p>
<h3></h3>
<h3>Bugzilla</h3>
<p>I still remember a few years ago when I first went to Bugzilla searching for a bug  and being totally overwhelmed. First I couldn&#8217;t understand how Buzilla worked and second every bug that I looked could have been from another world as far as I knew. Everything seemed so hard, to be honest not only there was a lack of knowledge on my side, but also a lack of confidence  knowing that I could contribute to a huge project like Firefox. The funny part is that now, if I look at other bug trackers for big systems, such as chromium, eclipse, fedora, etc. I&#8217;m not afraid anymore, even though I might not know how the project works I have the confidence that I can just dive in and start contributing.</p>
<h3></h3>
<h3>Javascript</h3>
<p>Before I took the DPS901 course, I thought javascript was a language that validated forms in a web page, little I knew about how powerful javascript really is. I couldn&#8217;t have asked for a better introduction to the real power of javscript.<br />
Thanks to the introduction to javascript last semester, this semester I was able to apply that knowledge in several different projects.<br />
A few tools I used this semester:</p>
<ul>
<li>NodeJS</li>
<li>MongoDB</li>
<li>Jquery</li>
<li>ProcessingJS</li>
<li>Mongoose</li>
<li>Other Node modules and client side javascript libs.</li>
</ul>
<h3></h3>
<h3>Blog</h3>
<p>This semester I had to put a lot of things into perspective, one of them was Blogging. Before DPS901 and DPS911 I never stopped to think that writing about the work I did was really important, and I can see from talking with my peers at Seneca that they also think the same. However, after listening to David Humphrey lectures I realized that it doesn&#8217;t matter what work you do, if you are not able to talk about it and present to other people it&#8217;s almost as if you didn&#8217;t do it. Now a days living in a society that have such powerful communication tools it is a must to take fully usage of them. It is really helpful to have a place where you can go and see the work you did in the past, when I look back to my first blog posts I can see what I was working at that time and even use that as a reference for some work I might be currently doing, Plus the fact that if you recorded a problem/solution that you&#8217;ve faced, it could also be helpful to other people that are facing the same problem. How many times you didn&#8217;t search for something and ended up finding the solution in a blog?</p>
<h3></h3>
<h3>Twitter</h3>
<p>Another social tool I was introduced last semester was Twitter. Even though I still haven&#8217;t put in my routine to tweet about things, I use twitter regularly to see the work other people are doing and get in touch with the news around the world.<br />
Twitter is an awesome tool that allows you not only to share with other people the work you&#8217;re doing, but also to keep updated with what is going on around you.<br />
One of my goals for the summer is to become more active on twitter and start tweeting more often</p>
<h3></h3>
<h3>Open source</h3>
<p>In 2009, my first year in college I went to the FSOSS hold here at Seneca College. Since then, I knew I wanted to get involved with open source development. I&#8217;m a big believer in the open source way, and that it can be applied not only on software but in other parts of our society as well, but that&#8217;s a topic for another post.</p>
<p>One of the things that really made me happy this semester was to see open source in action in one of the projects I&#8217;m working on.<br />
At the beginning of the project, one of the group members, a .NET developer was really skeptical about using NodeJS and MongoDB (both open source tools) in the project we were starting. After some good conversations he agreed and we dived into the challenge. During the way we had several road blocks, but every time we faced one I kept telling him that since all the tools we were using it were open source we could go and check the source code, and if we find a bug we could go and fix it, or change the code to do what we wanted, and that&#8217;s exactly what we DID!<br />
The first project we contributed to was MongooseJS.<br />
We faced a situation where we wanted to validate a Schema passing multiple validators during its initialization. However the library didn&#8217;t support that feature. We had two options in our hands:</p>
<ul>
<li>Move on and find another way to do it</li>
<li>Add the feature we wanted to Mongoose.</li>
</ul>
<p>We decided it was worth a try and opened a ticket on their repo on github: <a href="https://github.com/LearnBoost/mongoose/issues/718">ticket</a><br />
The we submitted a pull request with a possible fix: <a href="https://github.com/LearnBoost/mongoose/pull/721">pull request</a><br />
The solution was merged in their repo and now we and everybody else can use that feature <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It was also good to see my brother in law building Firefox and starting to get involved with the project, and seeing some friends file bugs on Bugzilla and contribute to other open source projects.<br />
Overall, I&#8217;m really happy to see more people understanding and getting involved in OpenSource projects.</p>
<p>To finish, I want to thank all my peers in the DPS911 course this semester, it was really inspiring to see the awesome work they did fixing bugs on Firefox and Popcorn.js</p>
<ul>
<li>Abhishek Bhatnagar (abhatnagar1)</li>
<li>Christopher De Cairos (cadecairos)</li>
<li>David Seifried (dseif)</li>
<li>Matthew Schranz (mjschranz)</li>
<li>Mohammed Buttu (mbuttu)</li>
<li>Raymond Hung (rhung)</li>
<li>Scott Downe (scott)</li>
<li>Steven Ching Wei Tseng (Anachid)</li>
</ul>
<p>And of course, a Big thanks to David Humphrey.<br />
I couldn&#8217;t have asked for a better teacher and a better introduction to OpenSource and Firefox development.</p>
<p>Sincerely, Thanks for everybody, and lets keep hacking <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/798/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/798/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/798/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=798&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/04/12/dps911-reflections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>
	</item>
		<item>
		<title>Bug 735031 &#8211; Fullscreen API implementation assumes an HTML Element</title>
		<link>http://diogogmt.wordpress.com/2012/04/02/bug-735031-fullscreen-api-implementation-assumes-an-html-element/</link>
		<comments>http://diogogmt.wordpress.com/2012/04/02/bug-735031-fullscreen-api-implementation-assumes-an-html-element/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 16:32:12 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[idl]]></category>
		<category><![CDATA[mozrequestfullscreen]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=782</guid>
		<description><![CDATA[Bug 735031 was to update the Firefox fullscreen implementation to allow SVG elements to receive fullscreen mode. An overview of the relationship between DOM Elements This is not a complete diagram, there are a bunch more elements inheriting from nsIDOMHTML/SVG/XULElement. However, It gives a nice visual representation showing that not all DOMElements are HTMLElements. Problem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=782&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Bug 735031 was to update the Firefox fullscreen implementation to allow SVG elements to receive fullscreen mode.</p>
<p>An overview of the relationship between DOM Elements<br />
<a href="http://diogogmt.files.wordpress.com/2012/04/requestfullscreen.jpg"><img class="alignnone size-full wp-image-783" title="RequestFullscreen" src="http://diogogmt.files.wordpress.com/2012/04/requestfullscreen.jpg?w=590&h=169" alt="" width="590" height="169" /></a></p>
<p>This is not a complete diagram, there are a bunch more elements inheriting from nsIDOMHTML/SVG/XULElement. However, It gives a nice visual representation showing that not all DOMElements are HTMLElements.</p>
<h1>Problem</h1>
<p><a href="http://diogogmt.files.wordpress.com/2012/04/requestfullscreenhtml-svg1.jpg"><img class="alignnone size-full wp-image-795" title="requestFullscreenHTML-SVG" src="http://diogogmt.files.wordpress.com/2012/04/requestfullscreenhtml-svg1.jpg?w=590&h=451" alt="" width="590" height="451" /></a></p>
<p>Only HTML Elements were allowed to receive fullscreen mode.<br />
SVG Elements didn&#8217;t know about mozRequestFullScreen since the implementation was done only for HTML Elements</p>
<p>Requesting mozFullScreen on a SVG element would give this error:</p>
<p><pre class="brush: plain;">
TypeError: svgElement.mozRequestFullScreen is not a function
</pre></p>
<p>The IDL declarion for mozRequestFullScreen was on: </p>
<div style="font-size:16px;font-weight:bold;">
dom/interface/ html /<a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/html/nsIDOMHTMLElement.idl">nsIDOMHTMLElement.idl</a>
</div>
<p>And MozRequestFullScreen was implemented on:</p>
<div style="font-size:16px;font-weight:bold;">content/html/content/src/<a href="http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsGenericHTMLElement.cpp">nsGenericHTMLElement.cpp</a>
</div>
<div style="height:30px;"></div>
<h1>Solution</h1>
<p>The solution was to move the declaration of mozRequestFullScreen to:</p>
<div style="font-size:16px;font-weight:bold;">
dom/interfaces/core/<a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMElement.idl">nsIDOMElement.idl</a>
</div>
<p>And the definition:</p>
<div style="font-size:16px;font-weight:bold;">
content/base/src/<a href="http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsGenericElement.cpp#6506">nsGenericElement.cpp</a>
</div>
<p>Now both HTML and SVG elements can request fullscreen mode.</p>
<div style="font-size:16px;"><em><strong><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=735031">Bug</a></strong></em><br />
<em><strong> <a href="https://bugzilla.mozilla.org/attachment.cgi?id=608734&amp;action=diff">Diff</a><br />
</strong></em></div>
<div style="height:30px;"></div>
<h1>Notes</h1>
<p>Since this fix had to change some IDLs, their UUID had to be updated. However, in this case, because the base IDL for all DOMElements was changed, the UUIDS for all the IDLs inheriting from nsIDOMElement had to be updated as well. The problem is that there are around 150 IDLs inheriting from nsIDOMElement, and to update each one by hand would have been CRAZY!<br />
Luckly, somebody must have faced this problem before and created a script to update the UUID of IDLs and all its children.</p>
<div style="font-size:16px;"><em><strong><a href="http://people.mozilla.com/~sfink/uploads/update-uuids">update-uuids</a></strong></em></div>
<p>To run the script:</p>
<p><pre class="brush: plain;">
update-uuids . nsIDOMElement nsIDOMDocument
</pre></p>
<p>The output:</p>
<p><pre class="brush: plain;">
  nsIDOMElement because it was given on command line
    f561753a-1d4f-40c1-b147-ea955fc6fd94 -&gt; a652db92-f8d4-47e0-bf8f-1ad72e6c083f
  nsIDOMDocument because it was given on command line
    d7cdd08e-1bfd-4bc3-9742-d66586781ee2 -&gt; ff3125e0-b1b5-467f-84ad-1d1eeafed595
  nsIDOMHTMLElement because it inherits from nsIDOMElement
    3de9f8c1-5d76-4d2e-b6b9-334c6eb0c113 -&gt; 5b703ce7-e551-41fa-b465-ff94aa3bdc66
  nsIDOMXULElement because it inherits from nsIDOMElement
    5e0a7c2c-fdb6-459d-a67b-549181218c31 -&gt; 42e74ec0-75c7-422c-b564-f853e3cbbb8b
  nsIDOMSVGElement because it inherits from nsIDOMElement
    dbb1b49c-dce5-43fe-97ea-e249b5620aa2 -&gt; d2900917-e0ce-4eb8-aaf9-7e021d45472a
  nsIDOMXMLDocument because it inherits from nsIDOMDocument
    b53a4bab-0065-468b-810a-4c4659a04f00 -&gt; b76ca016-46e8-4ee2-be3d-5b08b29afb72
  ....
  ...
  ..

Updated ./dom/interfaces/svg/nsIDOMSVGLineElement.idl with 1 changes
Updated ./dom/interfaces/svg/nsIDOMSVGStopElement.idl with 1 changes
Updated ./dom/interfaces/svg/nsIDOMSVGGElement.idl with 1 changes
Updated ./dom/interfaces/svg/nsIDOMSVGPatternElement.idl with 1 changes
Updated ./dom/interfaces/svg/nsIDOMSVGForeignObjectElem.idl with 1 changes
....
...
.
Originals are in *.idlbak
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/782/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=782&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/04/02/bug-735031-fullscreen-api-implementation-assumes-an-html-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/04/requestfullscreen.jpg" medium="image">
			<media:title type="html">RequestFullscreen</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/04/requestfullscreenhtml-svg1.jpg" medium="image">
			<media:title type="html">requestFullscreenHTML-SVG</media:title>
		</media:content>
	</item>
		<item>
		<title>Bug 728893 &#8211; Allow mochitest iframe to go fullscreen</title>
		<link>http://diogogmt.wordpress.com/2012/03/13/bug-728893-allow-mochitest-iframe-to-go-fullscreen/</link>
		<comments>http://diogogmt.wordpress.com/2012/03/13/bug-728893-allow-mochitest-iframe-to-go-fullscreen/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 05:06:29 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[firefrox]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[mochitest]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[pointerlock]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=706</guid>
		<description><![CDATA[Bug 728893 was encountered while implementing PointerLock. A Quick Overview on Mochitests By default an iframe is not allowed to go fullscreen mode, and since all the mochitests are run inside and iframe, if one of the mochitest needed to go fullscreen it would not work (pointerlock for example) There are two different ways to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=706&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Bug 728893 was encountered while implementing <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">PointerLock</a>.</p>
<h3>A Quick Overview on Mochitests</h3>
<p>By default an iframe is not allowed to go fullscreen mode, and since all the mochitests are run inside and iframe, if one of the mochitest needed to go fullscreen it would not work (pointerlock for example)<br />
<a href="http://diogogmt.files.wordpress.com/2012/03/mochitest.jpg"><img class="alignnone size-full wp-image-707" title="mochitest" src="http://diogogmt.files.wordpress.com/2012/03/mochitest.jpg?w=590&h=438" alt="" width="590" height="438" /></a></p>
<p>There are two different ways to run mochitests. With <a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/runtests.py">runtests.py</a> or mochitest-plain(ends up running runtests.py)</p>
<ol>
<li>python ./obj-dir/_tests/testing/mochitest/runtest.py &#8211;test-path=dom/tests/mochitest/pointerlock</li>
<li>TEST_PATH=/dom/test/mochitest/pointerlock make -C obj-dir/ mochitest-plain</li>
</ol>
<p>The first one calls explicit the runtests.py, that is the script that creates the http server<br />
The second one will run mochitest-plain.<br />
Now what is mochitest-plain?<br />
First we need to look at the root&#8217;s Makefile<br />
<a href="http://mxr.mozilla.org/mozilla-central/source/Makefile.in#127">/Makefile.in</a><br />
Line 129 is including testsuite-targets.mk, that&#8217;s where mochitest-plain is defined</p>
<p><pre class="brush: plain;">
127 ifdef ENABLE_TESTS
128 # Additional makefile targets to call automated test suites
129 include $(topsrcdir)/testing/testsuite-targets.mk
130 endif
</pre></p>
<p><a href="http://mxr.mozilla.org/mozilla-central/source/testing/testsuite-targets.mk#128">mochitest-plain</a><br />
Here is where mochitest-plain is defined, it calls $(RUN_MOCHITEST)</p>
<p><pre class="brush: plain;">
128 mochitest-plain:
129 	$(RUN_MOCHITEST)
130 	$(CHECK_TEST_ERROR)
</pre></p>
<p><a href="http://mxr.mozilla.org/mozilla-central/source/testing/testsuite-targets.mk#64">RUN_MOCHITEST</a><br />
In the end runtests.py is ran with some default flags</p>
<p><pre class="brush: plain;">
64 RUN_MOCHITEST = \
65 	rm -f ./$@.log &amp;&amp; \
66 	$(PYTHON) _tests/testing/mochitest/runtests.py --autorun --close-when-done \
67 	  --console-level=INFO --log-file=./$@.log --file-level=INFO \
68 	  --failure-file=$(call core_abspath,_tests/testing/mochitest/makefailures.json)  \
69 	  $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS)
</pre></p>
<p>**Running the tests with mochitest-plain will add some flags to the execution of runtest.py</p>
<blockquote><p>[diogogmt@rome mozilla-central-diogogmt]$ TEST_PATH=dom/tests/mochitest/pointerlock/ make -C ff-dbg/ mochitest-plain<br />
make: Entering directory `/home/diogogmt/mozilla-central-diogogmt/ff-dbg&#8217;<br />
rm -f ./mochitest-plain.log &amp;&amp; /usr/bin/python2.7 _tests/testing/mochitest/runtests.py <strong>&#8211;autorun </strong><strong>&#8211;close-when-done</strong> <strong>&#8211;console-level</strong>=INFO <strong>&#8211;log-file</strong>=./mochitest-plain.log <strong>&#8211;file-level</strong>=INFO <strong>&#8211;failure-file</strong>=/home/diogogmt/mozilla-central-diogogmt/ff-dbg/_tests/testing/mochitest/makefailures.json <strong>&#8211;symbols-path</strong>=./dist/crashreporter-symbols <strong>&#8211;test-path</strong>=dom/tests/mochitest/pointerlock/</p></blockquote>
<p>The flag <strong>&#8211;close-when-done</strong> is set by default. However sometimes you may want to leave the browser window open for debug purposes. I&#8217;m not sure if there is a way to tell mochitest-plain not run the runtests.py with the <strong>&#8211;close-when-done</strong> flag not set. What I usually do is run the tests calling directly runtest.py, since it runs withouth any flags, giving me more flexbility.</p>
<p>When not specifying a file, the mochitest will load all the files of the dir and run them inside the harness</p>
<p>For example:<br />
<a href="http://mxr.mozilla.org/mozilla-central/source/dom/tests/mochitest/Makefile.in#45">dom/tests/mochitest/Makefile.in</a><br />
The mochitest Makefile contains the list of the dirs of some tests</p>
<p><pre class="brush: plain;">
45 DIRS	+= \
46 	dom-level0 \
47 	dom-level1-core \
48 	dom-level2-core \
49 	dom-level2-html \
50 	ajax \
51 	bugs \
52 	chrome \
53 	general \
54 	whatwg \
55 	geolocation \
56 	localstorage \
57 	orientation \
58 	sessionstorage \
59 	storageevent \
60 	$(NULL
</pre></p>
<p><a href="http://mxr.mozilla.org/mozilla-central/source/dom/tests/mochitest/geolocation/Makefile.in#47">dom/test/mochitest/geolocation/Makefile.in</a><br />
In the geolocation Makefile all the tests for that module are listed</p>
<p><pre class="brush: plain;">
41 relativesrcdir	= dom/tests/mochitest/geolocation
42
43 include $(DEPTH)/config/autoconf.mk
44
45 include $(topsrcdir)/config/rules.mk
46
47 _TEST_FILES	= \
48 		test_allowCurrent.html \
49 		test_allowWatch.html \
50 		test_cancelCurrent.html \
51 		test_cancelWatch.html \
52 		test_clearWatch.html \
53 		test_clearWatch_invalid.html \
54 		test_manyCurrentConcurrent.html \
55 		test_manyCurrentSerial.html \
56 		test_manyWatchConcurrent.html \
57 		test_manyWatchSerial.html \
58 		test_manyWindows.html \
59 		test_optional_api_params.html \
60 		test_shutdown.html \
61 		test_windowClose.html \
62 		test_timerRestartWatch.html \
63 		test_worseAccuracyDoesNotBlockCallback.html \
64 		geolocation.html \
65 		geolocation_common.js  \
66 		network_geolocation.sjs \
67 		windowTest.html \
68 		$(NULL)
69
70 libs:: 	$(_TEST_FILES)
71 	$(INSTALL) $(foreach f,$^,&quot;$f&quot;) $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
</pre></p>
<p>From line 48 to 67 are listed all the test files<br />
Line 41 is defined the path where the files are located<br />
Line 71 is the path where the files will be copied after compiling firefox, for example:<br />
/obj-dir/_tests/testing/mochitest/tests/dom/tests/mochitest/geolocation</p>
<p><strong><em>Running single tests</em></strong><br />
When running the test as a stand alone, there is no need for an iframe, the test is loaded in the parent window, so the element is allowed to go fullscreen, different from when the tests are run inside the harness.</p>
<p>&nbsp;</p>
<h3>The Problem</h3>
<p>When we first started writing mochitests for pointerlock we had to find a way to run the tests inside the harness while setting them to fullscreen.<br />
The solution was to use the same approach as the fullscreen tests. To create a harness inside the harness, for example</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/03/pointerlock_harness2.jpg"><img class="alignnone size-full wp-image-718" title="pointerlock_harness2" src="http://diogogmt.files.wordpress.com/2012/03/pointerlock_harness2.jpg?w=590&h=429" alt="" width="590" height="429" /></a></p>
<h3>Solution</h3>
<p>The solution was simple, we just had to add the attribute mozallowfullscreen=true to the mochitest iframe.<br />
However, there are three places where the iframe gets defined:</p>
<ul>
<li><a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/server.js">server.js</a></li>
<li><a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/browser-harness.xul">browser_harness.xul</a></li>
<li><a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/plain-loop.html?force=1">plain-loop.html</a></li>
</ul>
<p>server.js is used for <a href="https://developer.mozilla.org/en/Mochitest">mochitest-plain</a><br />
browser_harness.xul is used for <a href="https://developer.mozilla.org/en/Chrome_tests">mochitest-chrome</a> and <a href="https://developer.mozilla.org/en/Browser_chrome_tests">mochitest-browser-chrome</a><br />
plain-loop remains a mystery <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>For server.js:</p>
<p><pre class="brush: plain;">
IFRAME({scrolling: &quot;no&quot;, id: &quot;testframe&quot;, width: &quot;500&quot;, height: &quot;300&quot;, mozallowfullscreen: &quot;true&quot;})
</pre></p>
<p>For browser_harness.xul</p>
<p><pre class="brush: xml;">
&lt;iframe id=&quot;testframe&quot; scrolling=&quot;no&quot; width=&quot;550&quot; height=&quot;350&quot;&gt;&lt;/iframe&gt;
</pre></p>
<p>You can find the complete patch <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=728893">here</a></p>
<h3>Sanity tests</h3>
<p>To make sure the mochitest framework works, before running all the tests a list of sanity tests is executed to test the framework itself.<br />
You can see the list of the tests in the <a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/Makefile.in#43">/testing/mochitest/tests/Makefile.in</a></p>
<p><pre class="brush: plain;">
43 relativesrcdir  = testing/mochitest/tests
44
45 include $(DEPTH)/config/autoconf.mk
46
47 PARALLEL_DIRS = \
48 	MochiKit-1.4.2 \
49 	SimpleTest \
50 	browser \
51 	$(NULL)
52
53 include $(topsrcdir)/config/rules.mk
54
55 _TEST_FILES = \
56   test_sanity.html \
57   test_sanityException.html \
58   test_sanityException2.html \
59   test_sanityWindowSnapshot.html \
60   test_SpecialPowersExtension.html \
61   test_SpecialPowersExtension2.html \
62   file_SpecialPowersFrame1.html \
63   $(NULL)
64
65 ifneq ($(OS_TARGET),Android)
66 # Disabled on Android for permaorange, see bug 688052
67   _TEST_FILES += \
68   test_sanityEventUtils.html \
69   test_sanitySimpletest.html
70 endif
71 # Copy the sanity tests into a subdirectory, so the top level is all dirs
72 # in the test screen.
73 libs:: $(_TEST_FILES)
74 	$(INSTALL) $(foreach f,$^,&quot;$f&quot;) $(DEPTH)/_tests/$(relativesrcdir)/Harness_sanity

</pre></p>
<p>One thing to notice is the folder the sanity tests are copied to: <strong>Harness_sanity</strong></p>
<p><a href="http://diogogmt.files.wordpress.com/2012/03/ff_mochitest_list.png"><img class="alignnone size-full wp-image-721" title="ff_Mochitest_list" src="http://diogogmt.files.wordpress.com/2012/03/ff_mochitest_list.png?w=590&h=331" alt="" width="590" height="331" /></a></p>
<p>After Firefox is compiled, all the tests are copied to /obj-dir/_tests/testing/mochitest/tests<br />
So to run the geolocation tests for example:</p>
<ul>
<li>TEST_PATH=dom/tests/mochitest/geolocation</li>
</ul>
<p>The Harness_sanity on the other hand:</p>
<ul>
<li>TEST_PATH=Harness_sanity</li>
</ul>
<p>Since allowing the iframe to go fullscreen mode could break other tests we decided to add a check on SimpleTest.finish() to cancel fullscreen mode if the test forgets to cancel it</p>
<p><pre class="brush: jscript;">
+    // Cancel element fullscreen mode due to Bug 728893
+    if (document &amp;&amp; document.mozFullScreenElement) {
+        document.mozCancelFullScreen();
+    }
</pre></p>
<p>So now we needed a test to make sure SimpleTest.finish was actually cancelling fullscreen.<br />
My first thought was to have two test files, test_fullscreen1.html and test_fullscreen2.html. On test_fullscreen1.html the element would be set to fullscreen mode and without cancelling call SimpleTest.finish(), then on test_fullscreen2.html would check the fullscreen status of the iframe, it should be false since SimpleTest.finish() supposed to cancel it.<br />
However, there was an easier way to write the test, with just one file instead of two.</p>
<p><pre class="brush: xml;">
+
+
+
+  Test for Bug 728893
+&lt;script type=&quot;text/javascript&quot; src=&quot;/tests/SimpleTest/SimpleTest.js&quot;&gt;&lt;/script&gt;+&lt;script type=&quot;text/javascript&quot; src=&quot;/tests/SimpleTest/EventUtils.js&quot;&gt;&lt;/script&gt;
+
+
+
+&lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=728893&quot; target=&quot;_blank&quot;&gt;
+ Mozilla Bug
+&lt;/a&gt;
+&lt;/pre&gt;
&lt;div id=&quot;div&quot;&gt;+&lt;/div&gt;
&lt;pre&gt;
+&lt;/pre&gt;
&lt;pre id=&quot;test&quot;&gt;+&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
+
+  /** Test for Bug 728893
+      Checks if SimpleTest.finish cancels fullscreen mode
+      The assertion happens after calling SimpleTest.finish
+      Running the test without the harness won't work
+  **/
+
+  SpecialPowers.setBoolPref(&quot;full-screen-api.enabled&quot;, true);
+  SpecialPowers.setBoolPref(&quot;full-screen-api.allow-trusted-requests-only&quot;,
+                                 false);
+
+  SimpleTest.waitForExplicitFinish();
+
+  var div = document.getElementById(&quot;div&quot;);
+
+  document.addEventListener(&quot;mozfullscreenchange&quot;, function (e) {
+    if (document.mozFullScreenElement === div) {
+      SimpleTest.finish();
+    }
+    else {
+      is(false, document.mozFullScreen,
+        &quot;SimpleTest.finish should cancel fullscreen mode&quot;);
+    }
+  }, false);
+
+  function start() {
+    SimpleTest.waitForFocus(function() {
+      div.mozRequestFullScreen();
+    });
+  }
+
+
// ]]&gt;&lt;/script&gt;
+
+
+
</pre></p>
<p>The assertion &#8220;<b>is(false, document.mozFullScreen, &#8220;SimpleTest.finish should cancel fullscreen mode&#8221;);</b>&#8221; is happening after SimpleTest.finish is called, the reason that it is possible to still make assertions after calling SimpleTest.finish is because the test itself is being run inside the mochitest harness</p>
<p><a href="http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/SimpleTest/SimpleTest.js#674">SimpleTest.js</a><br />
<pre class="brush: plain;">
678     if (parentRunner) {
679         /* We're running in an iframe, and the parent has a TestRunner */
680         parentRunner.testFinished(SimpleTest._tests);
681     } else {
682         SimpleTest.showReport();
683     }
</pre></p>
<p>Line 678 checks if the test is being run inside a harness, if true it goes to the next test, but it doesn&#8217;t terminates the current one.<br />
Different from line 682 that call showReport, terminating the current test and displaying the results.</p>
<p>**Big thans to <a href="http://cmtalbert.wordpress.com/">Clint(ctalbert)</a> for all the help with this bug</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/706/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/706/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=706&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/03/13/bug-728893-allow-mochitest-iframe-to-go-fullscreen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/03/mochitest.jpg" medium="image">
			<media:title type="html">mochitest</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/03/pointerlock_harness2.jpg" medium="image">
			<media:title type="html">pointerlock_harness2</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/03/ff_mochitest_list.png" medium="image">
			<media:title type="html">ff_Mochitest_list</media:title>
		</media:content>
	</item>
		<item>
		<title>PointerLock API Updates</title>
		<link>http://diogogmt.wordpress.com/2012/02/21/pointerlock-api-updates/</link>
		<comments>http://diogogmt.wordpress.com/2012/02/21/pointerlock-api-updates/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 06:18:30 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[mochitest]]></category>
		<category><![CDATA[mouselock]]></category>
		<category><![CDATA[mozfullscreen]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[mozpointerlock]]></category>
		<category><![CDATA[pointerlock]]></category>
		<category><![CDATA[pointerlockchange]]></category>
		<category><![CDATA[pointerlockerror]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=685</guid>
		<description><![CDATA[A quick update on the Firefox PointerLock API implementation Lets start with mochitests. While writing mochitests for pointerlock we stumbled on two problems Not being able to specify how many tests should run (different platforms were running different number of tests) Mochitest iframe not allowed to go fullscreen, making us run all the tests on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=685&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>A quick update on the Firefox PointerLock API implementation</h3>
<p>Lets start with mochitests. While writing mochitests for pointerlock we stumbled on two problems</p>
<ol>
<li>Not being able to specify how many tests should run (different platforms were running different number of tests)</li>
<li>Mochitest iframe not allowed to go fullscreen, making us run all the tests on a different window</li>
</ol>
<p><a href="http://vocamus.net/dave/">David Humphrey</a> came up with a solution for our first problem and added an &#8220;expect&#8221; functionality to the mochitest framework.<br />
So now we can specify how many tests should occur when making asynchronous tests, for example:<br />
SimpleTest.waitForExplicitFinish(3)<br />
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=724578">Bug 724578</a></p>
<p>For our second problem, I added the attribute mozallowfullscreen=true to the mochitest iframe that runs all tests.<br />
I&#8217;m not sure if there was a specific reason for not allowing fullscreen on the mochitest iframe, but if it wasn&#8217;t it will simplify a lot writing tests for pointerlock<br />
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=728893">Bug 728893</a></p>
<h3>Spec Updates</h3>
<p>The spec had two major changes</p>
<ol>
<li>Switching from callbacks to events</li>
<li>Moving functionality to the Document and Element</li>
</ol>
<p>For example:<br />
Everytime the pointer is locked/unlocked a mozpointerchange event will be dispatched to the document<br />
A mozpointererror event will be dispatched if there are any errors while locking the pointer<br />
Now It&#8217;s possible to access the element with the pointer locked via the document</p>
<p><pre class="brush: jscript;">
var div = document.createElement(&quot;div&quot;);

document.addEventListener(&quot;mozpointerlockchange&quot;, function (e) {
  if (document.mozPointerLockElement === div) {
    // Pointer is locked
  }
}, false);

document.addEventListener(&quot;mozpointerlockerror&quot;, function (e) {

}, false);

document.addEventListener(&quot;mozfullscreenchange&quot;, function (e) {
  if (document.mozFullScreen &amp;&amp;
      document.mozFullScreenElement === div) {
      div.mozRequestPointerLock();
  }
}, false);

div.mozRequestFullScreen();

</pre></p>
<p>Instead of something like this:<br />
<pre class="brush: jscript;">
var div = document.createElement(&quot;div&quot;);

div.addEventListener(&quot;mozpointerlocklost&quot;, function (e) {
  // Dispatched when pointer is unlocked
}, false);

document.addEventListener(&quot;mozfullscreenchange&quot;, function (e) {
  if (document.mozFullScreen &amp;&amp;
      document.mozFullScreenElement === div) {
      navigator.mozPointer.lock(
        div, // Element
        function () {
          // Success callback
        },
        function () {
          // Failure callback
        }
      );
  } 
}, false);

div.mozRequestFullScreen();

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/685/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=685&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/02/21/pointerlock-api-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>
	</item>
		<item>
		<title>Updating PointerLock API &#8211; Callbacks, Events and Threads</title>
		<link>http://diogogmt.wordpress.com/2012/02/15/updating-pointerlock-api-callbacks-events-and-threads/</link>
		<comments>http://diogogmt.wordpress.com/2012/02/15/updating-pointerlock-api-callbacks-events-and-threads/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 07:25:25 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[mouselock]]></category>
		<category><![CDATA[mozfullscreen]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[mozpointerlock]]></category>
		<category><![CDATA[pointerlock]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=660</guid>
		<description><![CDATA[The PointerLock implementation of Firefox is going great, we are close to having the patch ready to land, maybe Firefox 13. The work being done now is mainly some final touches, specially on the mochitests and on the API. Recently the W3C PointerLock spec has been updated, the changes are the following: When locking the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=660&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The PointerLock implementation of Firefox is going great, we are close to having the patch ready to land, maybe Firefox 13.</p>
<p>The work being done now is mainly some final touches, specially on the mochitests and on the API.</p>
<p>Recently the W3C PointerLock spec has been updated, the changes are the following:</p>
<ul>
<li>When locking the mouse, dispatch pointerlockchange/pointerlockerror events instead of firing callbacks</li>
<li>Locking the pointer by requesting pointer lock on the target element</li>
<li>Adding a reference to the locked element in the Document</li>
<li>Exiting pointerlock by calling exitPointerLock on the Document</li>
</ul>
<p>Those were significant changes, since it affected a big chunk of the code we had it implemented. However, I believe these updates to the API are beneficial, since with them developers will have an API similar to the fullscreen to work with.</p>
<p>The first bit I started working on was to dispatch the pointerlockchange/pointerlockerror instead of callbacks.</p>
<p>To Dispatch the events, the nsAsyncDOMEvent object was used:</p>
<p><pre class="brush: cpp;">
static void
DispatchPointerLockChange(nsINode* aTarget)
{
  nsRefPtr e =
    new nsAsyncDOMEvent(aTarget,
                        NS_LITERAL_STRING(&quot;mozpointerlockchange&quot;),
                        true,
                        false);
  e-&gt;PostDOMEvent();
}
</pre></p>
<p>Same logic to dispatch the pointerlockerror and pointerlocklost</p>
<p>One of the good things about having to go back and rewrite some code, is the fact that opens the possibility to analyse some of the decisions made before.<br />
Specifically in this case, the use of different threads when locking the pointer.<br />
At first, the callbacks were being fired on a different thread so the execution wouldn&#8217;t hang, and the Lock method would be able to return as soon as possible and not make the user wait for a result.</p>
<p>Before, the logic for callbacks was mainly based off the nsGeoLocation implementation. However, now with the pointerlock API looking more like the fullscreen api I went and looked how they handle setting the element into fullscreen.<br />
I had written a <a href="http://diogogmt.wordpress.com/2011/12/14/mouselock-fullscreen-2/">blog post a while back inspecting the fullscreen API</a>, so even with the API receiving some changes it was easy to locate the code path for requesting fullscreen on an element.</p>
<p>Here is a simple diagram I drew</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/02/mozfullscreenrequest.jpg"><img class="alignnone size-full wp-image-662" title="MozFullScreenRequest" src="http://diogogmt.files.wordpress.com/2012/02/mozfullscreenrequest.jpg?w=590&h=528" alt="" width="590" height="528" /></a></p>
<p>The diagram shows that once mozRequestFullScreen is called on an element, the method returns really fast and all the heavy processing happens on a separate thread.</p>
<p>On the other hand, this is how PointerLock does it:</p>
<p><a href="http://diogogmt.files.wordpress.com/2012/02/pointerlock_callbacks.jpg"><img class="alignnone size-full wp-image-663" title="Pointerlock_callbacks" src="http://diogogmt.files.wordpress.com/2012/02/pointerlock_callbacks.jpg?w=590&h=501" alt="" width="590" height="501" /></a></p>
<p>On PointerLock, different from the FullScreen, the heavy processing happens on the main thread, and the new thread only handles the callback firing. Now switching to events, even less processing happens on the new thread, so that made me rethink the logic for locking the pointer.</p>
<p>I remember hearing that all the code that involves changing the presentation, it needs to happen on the main thread, so maybe that&#8217;s why we&#8217;re not spinning the pointerlock check/validation to another thread, since it involves changing the UI presentation by hiding the pointer if the lock is successful.</p>
<p>Another thing that caught my attention was the fact that on the fullscreen code, the nsCallRequestFullScreen object was dispatched to a new thread using <strong>NS_DispatchToCurrentThread</strong> and on PointerLock we are using <strong>NS_DispatchToMainThread</strong></p>
<p><strong></strong><em></em><br />
<a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsThreadUtils.cpp#150">NS_DispatchToCurrentThread<br />
</a><a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsThreadUtils.cpp#96">NS_GetCurrentThread</a><br />
<a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/nsThreadManager.cpp#289">nsThreadManager::GetCurrentThread</a></p>
<p><a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsThreadUtils.cpp#164">NS_DispatchToMainThread</a><br />
<a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/nsThreadManager.cpp#101">mMainThread</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/660/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=660&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/02/15/updating-pointerlock-api-callbacks-events-and-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/02/mozfullscreenrequest.jpg" medium="image">
			<media:title type="html">MozFullScreenRequest</media:title>
		</media:content>

		<media:content url="http://diogogmt.files.wordpress.com/2012/02/pointerlock_callbacks.jpg" medium="image">
			<media:title type="html">Pointerlock_callbacks</media:title>
		</media:content>
	</item>
		<item>
		<title>Bug 713608 Update</title>
		<link>http://diogogmt.wordpress.com/2012/02/13/bug-713608-update/</link>
		<comments>http://diogogmt.wordpress.com/2012/02/13/bug-713608-update/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 02:05:44 +0000</pubDate>
		<dc:creator>diogogmt</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[videocontrols]]></category>
		<category><![CDATA[videocontrols.xml]]></category>

		<guid isPermaLink="false">http://diogogmt.wordpress.com/?p=649</guid>
		<description><![CDATA[One of the bugs I&#8217;m currently working on is: Bug 713608 &#8211; HTML5 Video controls are missing in Fullscreen A quick overview of the bug: This bug involves working with html5 video controls. The goal of the bug is to enable the stock controls when the video enters in fullscreen via the context menu. For [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=649&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the bugs I&#8217;m currently working on is: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=713608"><strong><em>Bug 713608 &#8211; HTML5 Video controls are missing in Fullscreen</em></strong></a><br />
A quick overview of the bug:<br />
This bug involves working with html5 video controls.<br />
The goal of the bug is to enable the stock controls when the video enters in fullscreen via the context menu. For example: the controls are hidden when the video isn&#8217;t in fullscreen, then the user right clicks on the video and selects enter fullscreen. When the video switches to fullscreen mode, the controls will be displayed, even though they weren&#8217;t before toggling fullscreen, and after exiting fullscreen mode, if the controls were disabled in the first place, disable them again.</p>
<p>After working on <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=714071"><strong><em>Bug 714071 &#8211; The Show Statistics setting is not preserved when toggling the full screen</em></strong></a> that also involved working on the videocontrols.xml file, I thought would be good to keep digging how XBL bindings work on firefox.<br />
So far Bug 713608 has proven to be more complicated than I thought it would be.<br />
At the beginning, I followed the same logic used on Bug 714071 and tried to find the method that shows/hides the controls. However, different from the Statistics menu option, it seems that hiding the controls uses a different approach.<br />
This is the code that displays the statistics of a video<br />
<pre class="brush: jscript;">
showStatistics : function(shouldShow) {
                    if (this.statsInterval) {
                        clearInterval(this.statsInterval);
                        this.statsInterval = null;
                    }

                    if (shouldShow) {
                        this.video.mozMediaStatisticsShowing = true;

                        this.statsOverlay.hidden = false;
                        this.statsInterval = setInterval(this.updateStats.bind(this), this.STATS_INTERVAL_MS);
                        this.updateStats();
                    } else {
                        delete this.video.mozMediaStatisticsShowing;
                        this.statsOverlay.hidden = true;
                    }
                },
</pre></p>
<p>But I couldn&#8217;t find the equivalent method for the video controls.</p>
<p>Browsing through the code, I was able to find the methods triggered by the event listeners for mousemove/over/out used by the video element:</p>
<h3>MouseMove</h3>
<p><pre class="brush: jscript;">
onMouseMove : function (event) {
                    // If the controls are static, don't change anything.
                    if (!this.dynamicControls)
                        return;

                    clearTimeout(this._hideControlsTimeout);

                    // Suppress fading out the controls until the video has rendered
                    // its first frame. But since autoplay videos start off with no
                    // controls, let them fade-out so the controls don't get stuck on.
                    if (!this.firstFrameShown &amp;&amp;
                        !(this.video.autoplay &amp;&amp; this.video.mozAutoplayEnabled))
                        return;

                    this.startFade(this.controlBar, true);
                    // Hide the controls if the mouse cursor is left on top of the video
                    // but above the control bar and if the click-to-play overlay is hidden.
                    if (event.clientY &lt; this.controlBar.getBoundingClientRect().top &amp;&amp; this.clickToPlay.hidden) {
                        this._hideControlsTimeout = setTimeout(this._hideControlsFn, this.HIDE_CONTROLS_TIMEOUT_MS);
                    }
                },
</pre></p>
<h3>MouseInOut</h3>
<p><pre class="brush: jscript;">
onMouseInOut : function (event) {
                    // If the controls are static, don't change anything.
                    if (!this.dynamicControls)
                        return;

                    clearTimeout(this._hideControlsTimeout);

                    // Ignore events caused by transitions between child nodes.
                    // Note that the videocontrols element is the same
                    // size as the *content area* of the video element,
                    // but this is not the same as the video element's
                    // border area if the video has border or padding.
                    if (this.isEventWithin(event, this.videocontrols))
                        return;

                    var isMouseOver = (event.type == &quot;mouseover&quot;);

                    // Suppress fading out the controls until the video has rendered
                    // its first frame. But since autoplay videos start off with no
                    // controls, let them fade-out so the controls don't get stuck on.
                    if (!this.firstFrameShown &amp;&amp; !isMouseOver &amp;&amp;
                        !(this.video.autoplay &amp;&amp; this.video.mozAutoplayEnabled))
                        return;

                    if (!isMouseOver) {
                        this.adjustControlSize();
                        
                        // Keep the controls visible if the click-to-play is visible.
                        if (!this.clickToPlay.hidden)
                            return;

                        // Setting a timer here to handle the case where the mouse leaves
                        // the video from hovering over the controls.
                        this._hideControlsTimeout = setTimeout(this._hideControlsFn, this.HIDE_CONTROLS_TIMEOUT_MS);
                    }
                },
</pre></p>
<p>My plan was to find the event listeners that trigger the display of the video controls, then find how those events are added/removed to element.</p>
<p>I found where the listeners were defined<br />
<pre class="brush: jscript;">
&lt;handlers&gt;
        &lt;handler event=&quot;mouseover&quot;&gt;
            if (!this.isTouchControl)
                this.Utils.onMouseInOut(event);
        &lt;/handler&gt;
        &lt;handler event=&quot;mouseout&quot;&gt;
            if (!this.isTouchControl)
                this.Utils.onMouseInOut(event);
        &lt;/handler&gt;
        &lt;handler event=&quot;mousemove&quot;&gt;
            if (!this.isTouchControl)
                this.Utils.onMouseMove(event);
        &lt;/handler&gt;
    &lt;/handlers&gt;
</pre></p>
<p>However, I couldn&#8217;t find where they are added/removed from the video element.</p>
<p>I feel that I&#8217;m getting close to finding a solution.</p>
<p>Big thanks to <a href="http://msujaws.wordpress.com/">Jared Wein (jaws)</a> for helping me with this and other bugs <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/diogogmt.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/diogogmt.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/diogogmt.wordpress.com/649/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=diogogmt.wordpress.com&#038;blog=19981611&#038;post=649&#038;subd=diogogmt&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://diogogmt.wordpress.com/2012/02/13/bug-713608-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4a92d73652c4e60b357c970a78d3e068?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">diogogmt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
