开发者

Using MozMill for testing standalone XUL applications

As a follow-up of this question, I am trying MozMill for testing standalone XUL applications (not a firefox extension). However, I did not "get it" yet - more specifically, how to 开发者_如何学Pythontest a XULRunner-based application.

Consider this app, for example. For now, I can run it from command line, more or less this way:

$ /path/to/xulrunner /full/path/to/mozmillexample/application.ini

I would like to write Mozmill scripts to test it. For example, I would like to write a test such as this one, which has as "taste" of unit testing:

 Components.utils.import("chrome://mozmillexample/content/example.js", example);
 var setupModule = function(module) {
     module.controller = mozmill.getBrowserController(); // Or what?
 }

var testEquals = function() {
    jumlib.assertEqual(example.exHello(), "Hello, World!", "Should be equal");
}

I would like to write some functional tests, too:

 Components.utils.import("chrome://mozmillexample/content/example.js", example);
 var setupModule = function(module) {
     module.controller = mozmill.getBrowserController(); // Or what?
 }

var testAlerts = function() {
    var button = findElement.Elem(document.getElementById('button'));
    button.click();
    controller.window.assertAlert(); // I bet it does not exist but it gives the idea...
}

Unfortunately, however, I did not find any documentation about testing standalone apps, at least none explaining the basic steps. So I ask: is it possible to write tests like these ones? How could I do it, if it is possible?


I got it to work with the MozMill extension; unpack the extension and edit the following files:

  • add this to install.rdf at the right place:

    <em:targetApplication>
      <Description>
        <em:id>mozmill@example.com</em:id>
        <em:minVersion>0.9</em:minVersion>
        <em:maxVersion>1.1</em:maxVersion>
      </Description>
    </em:targetApplication>`
    
  • create a folder "extensions" in the application's root (where application.ini and the "chrome" and the "defaults" folder are); paste the unpacked mozmill extension there.

  • Enable the extension manager as described in MDC

  • embed the MozMill Extension code in your XULRunner app: <script src="chrome://mozmill/content/overlay.js"/>

  • Enable the extension by adding or modifying %appdata%\Adam Brandizzi\MozMill Example\Profiles\123455.default\extensions.ini: [ExtensionDirs] Extension0=C:\Users\John\Desktop\myXULApp\extensions\mozmill

    • Use the following JS code to open MozMill: MozMill.onMenuItemCommand(event);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜