mozilla

Revision 141270 of Automated testing tips and tricks

  • Revision slug: Automated_testing_tips_and_tricks
  • Revision title: Automated testing tips and tricks
  • Revision id: 141270
  • Created:
  • Creator: Davel
  • Is current revision? No
  • Comment

Revision Content

  • TODO:
    • check example code in to the tree somewhere
  • How to quit the browser on all platforms
  • How to create a new profile from the command line
    • First, use the -CreateProfile command line flag to add a profile entry to profiles.ini and populate the new profile directory with a prefs.js file
      • firefox-bin -CreateProfile "testprofile ${PROFILE_DIR}/testprofile"
    • Next, start firefox to populate the new profile directory with the rest of the default settings
      • firefox-bin -P testprofile -chrome chrome://tests/content/quit.xul<code>
      • the above process may exit before the profile is completely created. In test scripts, <code>sleep 5 after the above command should ensure the profile is created before the next command in the test script is run
  • How to enable dump in a new profile
    • add user_pref("browser.dom.window.dump.enabled", true); to profiledir/user.js
  • How to execute test code with chrome privileges
  • How to detect content onload event from chrome
    • use the DOMContentLoaded event
      • chromeWindow.addEventListener('DOMContentLoaded',callbackFunction,false);

Revision Source

<ul><li> TODO:
<ul><li> check example code in to the tree somewhere
</li></ul>
</li><li> How to quit the browser on all platforms
<ul><li> window.close() of the last open window does not quit the application on Mac
</li><li> <a class=" external" href="http://people.mozilla.com/~davel/scripts/" rel="freelink">http://people.mozilla.com/~davel/scripts/</a> - look at quit.js and quit.xul
</li><li> install manifest file in appdir/chrome to map <a class=" external" href="chrome://tests/content" rel="freelink">chrome://tests/content</a> to directory containing quit.js and quit.xul
<ul><li> example: <code>content tests <a class=" external" href="file:///Users/davel/Work/tests/" rel="freelink">file:///Users/davel/Work/tests/</a></code>
</li></ul>
</li><li> start app with command line flag <code>-chrome <a class=" external" href="chrome://tests/content/quit.xul" rel="freelink">chrome://tests/content/quit.xul</a></code>
</li></ul>
</li><li> How to create a new profile from the command line
<ul><li> First, use the <code>-CreateProfile</code> command line flag to add a profile entry to profiles.ini and populate the new profile directory with a prefs.js file
<ul><li> <code>firefox-bin -CreateProfile "testprofile ${PROFILE_DIR}/testprofile"</code>
</li></ul>
</li><li> Next, start firefox to populate the new profile directory with the rest of the default settings
<ul><li> <code>firefox-bin -P testprofile -chrome <a class=" external" href="chrome://tests/content/quit.xul" rel="freelink">chrome://tests/content/quit.xul</a>&lt;code&gt;
</code></li><li> the above process may exit before the profile is completely created. In test scripts, &lt;code&gt;sleep 5 after the above command should ensure the profile is created before the next command in the test script is run
</li></ul>
</li></ul>
</li><li> How to enable <code>dump</code> in a new profile
<ul><li> add <code>user_pref("browser.dom.window.dump.enabled", true);</code> to profiledir/user.js
</li></ul>
</li><li> How to execute test code with chrome privileges
<ul><li> using a chrome doc - see sbtests.xul in <a class=" external" href="http://people.mozilla.com/~davel/scripts/" rel="freelink">http://people.mozilla.com/~davel/scripts/</a> for an example
<ul><li> <code>firefox-bin -P sbtestprofile -chrome <a class=" external" href="chrome://sbtests/content/" rel="freelink">chrome://sbtests/content/</a></code>
</li></ul>
</li><li> above code calls the quit function in quit.js to exit after test is finished
</li></ul>
</li><li> How to detect content onload event from chrome
<ul><li> use the <code>DOMContentLoaded</code> event
<ul><li> <code>chromeWindow.addEventListener('DOMContentLoaded',callbackFunction,false);</code>
</li></ul>
</li></ul>
</li></ul>
Revert to this revision