Using MozMill for testing standalone XUL applications

六眼飞鱼酱① 提交于 2020-01-06 08:28:46

问题


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 test 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?


回答1:


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);


来源:https://stackoverflow.com/questions/6873945/using-mozmill-for-testing-standalone-xul-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!