Revision 73578 of User:madarche

  • Revision slug: User:madarche
  • Revision title: User:madarche
  • Revision id: 73578
  • Created:
  • Creator: madarche
  • Is current revision? No
  • Comment no wording changes

Revision Content

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've vote for:

 

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 but once used to it, it's quite powerful.

What I miss in Mozmill

New Textbox string setting

A method (for example in the Mozmill Controller Object) to set a string in a textbox, without having to use controller.keypress method for each letter would be much welcome. This method could also be used to blank a textbox.

boolean setText(in Elem element, in string text)

Running a specific test in a file

The possibility to run a specific test in a test file from the command line
(A -m and -t flags after the Python fashion): mozmill -m suite/test_statusbar.js -t testAllRedirects

(A -n flag after the Ruby on Rails fashion): mozmill -t suite/test_statusbar.js -n testAllRedirects

Better jum assertion failure message

having the line number printed when a jum.js assertions fails

New jum array equality assertion

having ans assertion able to compare 2 arrays and return true if they have the same values

Retrieving values from filesystem files

have an helper method to read values from the filessystem, to retrieve user ID and password or another mean to achieve that

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

<p>Member of the <a class=" external" href="http://aful.org/">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/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/XUL/Attribute/id" title="https://developer.mozilla.org/en/XUL/Attribute/id">XUL/Attribute/id</a></li>
</ul>
<p>Mozilla bugs I've filled or that I've vote for:</p>
<p> </p>
<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 but once used to it, it's quite powerful.</p>
<h3>What I miss in Mozmill</h3>
<h4>New Textbox string setting</h4>
<p>A method (for example in the <a href="../../../../en/Mozmill/Mozmill_Controller_Object" rel="internal">Mozmill Controller Object</a>) to set a string in a textbox, without having to use <code>controller.keypress</code> method for each letter would be much welcome. This method could also be used to blank a textbox.</p>
<p><code>boolean setText(in Elem element, in string text)</code></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 <br>
(A -m and -t flags after the Python fashion): mozmill -m suite/test_statusbar.js -t testAllRedirects</p>
<p>(A -n flag after the Ruby on Rails fashion): mozmill -t suite/test_statusbar.js -n testAllRedirects</p>
<h4>Better jum assertion failure message</h4>
<p>having the line number printed when a jum.js assertions fails</p>
<h4>New jum array equality assertion</h4>
<p>having ans assertion able to compare 2 arrays and return true if they have the same values</p>
<h4>Retrieving values from filesystem files</h4>
<p>have an helper method to read values from the filessystem, to retrieve user ID and password or another mean to achieve that</p>
<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