User:madarche

  • Revision slug: User:madarche
  • Revision title: User:madarche
  • Revision id: 73607
  • Created:
  • Creator: madarche
  • Is current revision? No
  • Comment Bug 568978 is now fixed and done: Mozmill is cool; 179 words removed

Revision Content

Marc-Aurèle Darche

Member of the French speaking Libre Software Users' Association (AFUL). I develop web standards valid and accessible web sites. And I'm in charge of developing the Fidesfit-client Firefox addon/extension for the Fidesfit company.

 On DevMo/MDC/MDN I'm adding notes or updating content as I stumble upon documents needing update or when I find difficulties developing something that could apparently be more documented.

My aims are to help others, as much as I have been helped by this very good collaborative documentation, and to make more and more people to decide on using the Mozilla platforms.

Lately I have been contributing to the following pages:

Mozilla bugs I've filled or that I'm following:

  • {{ Bug("596211") }}: [Linux] Wrong initial position for panel[noautohide="true"]
  • {{ Bug("560181") }}: Make it possible to copy paste the notificationbox content
  • {{ Bug("439323") }}: sizeToContent() not always working
  • {{ Bug("496653") }}: Command line option --class <WM_CLASS> does not work, proposed MOZ_WM_CLASS workaround
  • {{ Bug("320831") }}: Expose visit ID in result nodes

Unit and functional tests

Building applications without tests is a pain. Hopefully there are now usable tools to achieve that for Mozilla addons/extensions, such as Mozmill and UxU. Mozmill is not that easy to use at the beginning (the difficult part is to get how to retrieve the GUI elements references and there is also the recorder that produces a code-that-would-never-run-but-to-treat-as-an-example-to-get-elements-references) but once used to it, it's quite powerful.

What I miss in Mozmill

Mozmill would be easier to use with those little suggestions that I gather while I'm using it.

Textbox blanking method

A new method in the Mozmill Controller Object to blank a textbox, without having to use the controller keypress method with 'VK_BACK_SPACE' for each letter would be much welcome.

The keypress method is effective only on the input of the textfield element, which is impossible to get through the element id, one has to resort to use a mochi path. That's why this new blanking method should be given the textfield element, just like the type method.

See Bug 568961 - Need a function to clear a textbox

Running a specific test in a file

The possibility to run a specific test in a test file from the command line is a needed addition since otherwise one tends to write only one test per file.

Since the mozmill command line tool is in Python I would recommend  on using the Python unit tests syntax (ie through a -m flag and -t flag:

$ mozmill -m suite/test_statusbar.js -t testAllRedirects

If the Mozmill team doesn't want to make an incompatible change (ie changing the use of the -t flag) [Note that the mozmill command line options have been changed recently with the renaming of the --plugins option into --addons ] a -n flag after the Ruby on Rails fashion could then be used:

$ mozmill -t suite/test_statusbar.js -n testAllRedirects

Better JUM assertion failure message

When a JUM assertion fails, having the line number printed is need. This is not the case presently and one cannot know which JUM assertion failed if there is more than one in a test (which is quite common).

Retrieving values from filesystem files

It would be great to have an helper method to read values/properties/prefs from the filesystem. A use case is to be able to use user ID and password, LDAP credentials, etc. from the filesystem (for example from a /home/joeuser/test_settings.js JavaScript file, such as a preferences file) without actually storing them in the source code that is likely to be public and distributed in various code repository.

Here is a proposition of a method to add to PrefsAPI preferences:

void loadPrefsFromFile(in file_path);

Bug 568943 - Add possibility to load account information from local files for restricted tests

 


UxU FAQ

I'm mainly using UxU for testing Firefox extensions and it's a pleasure to finally be able to do it. Testing XUL extensions is not that easy at the moment with the very few recent and working tools that one can find.

Question:

My XUL code has some alert('This is a confirmation message') calls that await a click on their "OK" buttons. In general my code uses prompts (@mozilla.org/embedcomp/prompt-service;1) for user interactions, but for lower level and debug stuffs it uses "alert" calls.

How should I produce the desired click on those popup windows?

So far I have no success with the following code below:

action.keypressOn($('input'), Ci.nsIDOMKeyEvent.DOM_VK_RETURN);
var windows = utils.getChromeWindows();
windows.forEach(function(window) {
    window.close();
});

Maybe I should only use prompts and not alert in the XUL code?

Answer:

Alert dialogs are opened as modal. So, if you call window.alert() (or a method of nsIPromptService) directly from the event handler for $('input'), the script will stop on the line 1 until the "OK" button in the alert is pressed (so lines 3-5 are never called!). 

You cannot solve this problem with the current version of UxU (UxU 0.7.6 - 2010-01-29 - at the time of this writing). New utilities in UxU for this problem are planed but not coded yet.

By the way, this problem also appear on dialogs to choose files (filechooser). Because their dialogs are not XUL windows, we cannot control them from JavaScript. It's a hard issue.

Revision Source

<h2>Marc-Aurèle Darche</h2>
<p>Member of the <a class=" external" href="http://aful.org/" hreflang="fr">French speaking Libre Software Users' Association (AFUL)</a>. I develop web standards valid and accessible web sites. And I'm in charge of developing the <a class=" external" href="http://sourceforge.net/projects/fidesfit-client/" title="http://sourceforge.net/projects/fidesfit-client/">Fidesfit-client</a> Firefox addon/extension for the Fidesfit company.</p>
<p> On <a href="/" title="https://developer.mozilla.org/">DevMo/MDC/MDN</a> I'm adding notes or updating content as I stumble upon documents needing update or when I find difficulties developing something that could apparently be more documented.</p>
<p>My aims are to help others, as much as I have been helped by this very good collaborative documentation, and to make more and more people to decide on using the Mozilla platforms.</p>
<p>Lately I have been contributing to the following pages:</p>
<ul> <li><a href="/Talk:en/XUL_School/JavaScript_Object_Management" title="https://developer.mozilla.org/Talk:en/XUL_School/JavaScript_Object_Management">Talk about JavaScript Object Management</a></li> <li><a href="/en/Code_snippets/Sidebar" title="https://developer.mozilla.org/en/Code_snippets/Sidebar">Sidebar code snippets</a></li> <li><a href="/en/Code_snippets/Tabbed_browser" title="https://developer.mozilla.org/en/Code_snippets/Tabbed_browser">Tabbed_browser</a> <a href="/en/Code_snippets/Tabbed_browser" title="https://developer.mozilla.org/en/Code_snippets/Tabbed_browser">code snippets</a></li> <li><a href="/en/Mozmill_Tests" title="https://developer.mozilla.org/en/Mozmill_Tests">Mozmill tests</a></li> <li><a href="/en/Mozmill/First_Steps/Tutorial:_Introduction_to_Mozmill" title="https://developer.mozilla.org/en/Mozmill/First_Steps/Tutorial:_Introduction_to_Mozmill">Tutorial: Introduction to Mozmill</a></li> <li><a href="/en/Mozmill/Mozmill_Controller_Object" title="https://developer.mozilla.org/en/Mozmill/Mozmill Controller Object">Mozmill Controller Object</a></li> <li><a href="/En/XMLHttpRequest/Using_XMLHttpRequest" title="https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest">Using XMLHttpRequest</a></li> <li><a href="/en/XUL_Tutorial/Element_Positioning" title="https://developer.mozilla.org/en/XUL_Tutorial/Element_Positioning">XUL Tutorial / Element_Positioning</a></li> <li><a href="/en/XUL/Attribute/id" title="https://developer.mozilla.org/en/XUL/Attribute/id">XUL/Attribute/id</a></li> <li><a href="/en/XUL/Attribute/disabled" title="https://developer.mozilla.org/en/XUL/Attribute/disabled">XUL/Attribute/disabled</a></li> <li><a href="/en/XUL/Property/disabled" title="https://developer.mozilla.org/en/XUL/Property/disabled">XUL/Property/disabled</a></li> <li><a href="/en/XUL/Attribute/oncommand" title="en/XUL/Attribute/oncommand">oncommand</a></li>
</ul>
<p>Mozilla bugs I've filled or that I'm following:</p>
<ul> <li>{{ Bug("596211") }}: <span id="summary_alias_container"> <span id="short_desc_nonedit_display">[Linux] Wrong initial position for panel[noautohide="true"]</span></span></li> <li>{{ Bug("560181") }}: <span id="summary_alias_container"> <span id="short_desc_nonedit_display">Make it possible to copy paste the notificationbox content</span></span></li> <li>{{ Bug("439323") }}: <span id="summary_alias_container"><span id="short_desc_nonedit_display">sizeToContent() not always working</span></span></li> <li>{{ Bug("496653") }}: <span id="summary_alias_container"><span id="short_desc_nonedit_display">Command line option --class &lt;WM_CLASS&gt; does not work, proposed MOZ_WM_CLASS workaround</span></span></li> <li>{{ Bug("320831") }}: <span id="summary_alias_container"><span id="short_desc_nonedit_display">Expose visit ID in result nodes</span></span></li>
</ul>
<h2>Unit and functional tests</h2>
<p>Building applications without tests is a pain. Hopefully there are now usable tools to achieve that for Mozilla addons/extensions, such as Mozmill and UxU. Mozmill is not that easy to use at the beginning (the difficult part is to get how to retrieve the GUI elements references and there is also the recorder that produces a code-that-would-never-run-but-to-treat-as-an-example-to-get-elements-references) but once used to it, it's quite powerful.</p>
<h3>What I miss in Mozmill</h3>
<p>Mozmill would be easier to use with those little suggestions that I gather while I'm using it.</p>
<h4>Textbox blanking method</h4>
<p>A new method in the <a href="../../../../en/Mozmill/Mozmill_Controller_Object" rel="internal">Mozmill Controller Object</a> to blank a textbox, without having to use the <code>controller <a href="/en/Mozmill/Mozmill_Controller_Object#keypress.28.29" title="https://developer.mozilla.org/en/Mozmill/Mozmill_Controller_Object#keypress.28.29">keypress</a></code> method with <code>'VK_BACK_SPACE'</code> for each letter would be much welcome.</p>
<p>The <a href="/en/Mozmill/Mozmill_Controller_Object#keypress.28.29" title="https://developer.mozilla.org/en/Mozmill/Mozmill_Controller_Object#keypress.28.29"><code>keypress</code></a> method is effective only on the input of the textfield element, which is impossible to get through the element id, one has to resort to use a mochi path. That's why this new blanking method should be given the textfield element, just like the <a href="/en/Mozmill/Mozmill_Controller_Object#type.28.29" title="https://developer.mozilla.org/en/Mozmill/Mozmill_Controller_Object#type.28.29"><code>type</code></a> method.</p>
<p>See <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=568961" title="https://bugzilla.mozilla.org/show_bug.cgi?id=568961">Bug 568961 - Need a function to clear a textbox</a></p>
<h4>Running a specific test in a file</h4>
<p>The possibility to run a specific test in a test file from the command line is a needed addition since otherwise one tends to write only one test per file.</p>
<p>Since the mozmill command line tool is in Python I would recommend  on using the Python unit tests syntax (ie through a <code>-m</code> flag and <code>-t</code> flag:</p>
<pre>$ mozmill -m suite/test_statusbar.js -t testAllRedirects</pre>
<p>If the Mozmill team doesn't want to make an incompatible change (ie changing the use of the <code>-t</code> flag) [Note that the mozmill command line options have been changed recently with the renaming of the <code>--plugins</code> option into <code>--addons</code> ] a <code>-n</code> flag after the Ruby on Rails fashion could then be used:</p>
<pre>$ mozmill -t suite/test_statusbar.js -n testAllRedirects</pre>
<h4>Better JUM assertion failure message</h4>
<p>When a <a href="/en/Mozmill/Mozmill_Unit_Test_Framework" title="en/Mozmill/Mozmill Unit Test Framework">JUM</a> assertion fails, having the line number printed is need. This is not the case presently and one cannot know which JUM assertion failed if there is more than one in a test (which is quite common).</p>
<h4>Retrieving values from filesystem files</h4>
<p>It would be great to have an helper method to read values/properties/prefs from the filesystem. A use case is to be able to use user ID and password, LDAP credentials, etc. from the filesystem (for example from a /home/joeuser/test_settings.js JavaScript file, such as a preferences file) without actually storing them in the source code that is likely to be public and distributed in various code repository.</p>
<p><code>Here is a proposition of a method to add to </code><a href="/en/Mozmill_Tests/Shared_Modules/PrefsAPI/preferences" title="en/Mozmill Tests/Shared Modules/PrefsAPI/preferences">PrefsAPI preferences</a>:</p>
<pre>void loadPrefsFromFile(in file_path);</pre>
<p><a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=568943">Bug 568943 - Add possibility to load account information from local files for restricted tests </a></p>
<p> </p>
<hr>
<h3>UxU FAQ</h3>
<p>I'm mainly using <a class=" external" href="http://www.clear-code.com/software/uxu/index.html.en" title="http://www.clear-code.com/software/uxu/index.html.en">UxU</a> for testing Firefox extensions and it's a pleasure to finally be able to do it. Testing XUL extensions is not that easy at the moment with the very few recent and working tools that one can find.</p>
<h4>Question:</h4>
<p>My XUL code has some <code>alert('This is a confirmation message') </code>calls that await a click on their "<code>OK</code>" buttons. In general my code uses prompts (<code>@mozilla.org/embedcomp/prompt-service;1</code>) for user interactions, but for lower level and debug stuffs it uses "alert" calls.</p>
<p>How should I produce the desired click on those popup windows?</p>
<p>So far I have no success with the following code below:</p>
<pre class="brush: js">action.keypressOn($('input'), Ci.nsIDOMKeyEvent.DOM_VK_RETURN);
var windows = utils.getChromeWindows();
windows.forEach(function(window) {
    window.close();
});<code><br></code></pre>
<p>Maybe I should only use prompts and not alert in the XUL code?</p>
<h4>Answer:</h4>
<p>Alert dialogs are opened as modal. So, if you call window.alert() (or a method of nsIPromptService) directly from the event handler for $('input'), the script will stop on the line 1 until the "<code>OK</code>" button in the alert is pressed (so lines 3-5 are never called!). </p>
<p>You cannot solve this problem with the current version of UxU (UxU 0.7.6 - 2010-01-29 - at the time of this writing). New utilities in UxU for this problem are planed but not coded yet.</p>
<p>By the way, this problem also appear on dialogs to choose files (filechooser). Because their dialogs are not XUL windows, we cannot control them from JavaScript. It's a hard issue.</p>
Revert to this revision