XUL Explorer:UseCases/Extension Testing

From MozillaWiki
Jump to: navigation, search

XUL Explorer:Planning

Extension Test mode

Brief Description

Allows a user to test their extension on Mozilla Firefox without having to package it up.

Precondition

User selects 'test extension' from a menuitem/button

Basic Flow

  1. Locate firefox executable
    1. Attempt to read the pref.js file for firefox directory (explorer_browser_path)
    2. Attempt to auto-locate the firefox directory. Save the browser path to prefs.js(?)
    3. Launch a file picker for a file. Save the browser path to prefs.js(?)
  2. Locate the profile
    1. Attempt to read the pref.js file for the profile directory (explorer_browser_profile_path)
    2. Gather all the profiles from ~/.mozilla/firefox/ or ~/Application Data/Mozilla/profile
      1. allow the user to select a profile, or pick the first one if there is only one
      2. save the profile path to prefs.js (?)
    3. Launch the file picker for a directory. Save the profile path to prefs.js (?)
  3. Locate the root directory of the extension
    1. This should probably be two directories up
  4. Locate the extension's id
    1. In the extension's root directory. Either in install.rdf or application.ini
    2. If we cannot find, throw a neat error
  5. Create firefox extension text file
    1. Check if the profile/extensions folder exists. if not, create it.
    2. Add a new plain text file to extensions/extension_id
    3. Add root directory to file (using trailing slash, if needed)
  6. Launch firefox with options -no-remote and -profile
    1. Pass profile directory
  7. Wait for firefox to be closed
  8. delete extensions/extension_id

Timeline

This is a timeline of what is left to do and when I should have that done

What is left to do?

Task Priority Status
Auto-locate Firefox profiles and Firefox executable Low
  • This is probably a more difficult and time consuming feature to do, since it depends on the platform and where to check.
  • Nice to have feature, but I will leave it to the end if I have time
Read values from prefs.js Done / Medium
  • Save information so app doesn't have to auto-locate executable/ask user each time
Pick files (firefox executable)/directories (profile directory) Done / High Done
Locate root directory of extension Done / High Needed to write in text file. This is tricky because it should point to the same directory as application.ini, but where that file is isn't always relative to the current file. So we have a few options
  • Go through each tab for a file named application.ini, and take it's document.title
  • Have the user locate by hand (but this shouldn't be saved to prefs.js

I am leaning towards option #1

Mark Finkle and shaver suggest option #2, but have also suggested defaulting to the last picked directory. Which seems fair
locate extension id Done / High Read application.ini/install.rdf, but how? I have managed to finish application.ini, since it only relies on undocumented interfaces. I have no clue right now on RDF, but Mark Finkle pointed to possible help.
create text file/directory Done / Medium Create a directory/text file. I don't think this will be difficult at all
Launch Firefox High / Medium Not sure how to do this yet
Wait for Firefox to close and delete file/directory Done poorly / High Important, but not sure how to do this either. If I figure out how to launch Firefox, there will probably be an easy way to catch when it is closed.

Welcome feedback received, which I am posting along here :

Task Priority Status
Move code out of extensionTestManager to XE for better reuse (for example, move out the UI code for CL interfaces, and prefs settings). Done / Medium prefs and prompts are in the utils/ directory.
Need more explanation about each step, since it is very subtle right now (dialog titlebar). Mark Finkle recommended a wizard. Done / High
  • A wizard has been completed. There is one shot for intro, 3 shots for executable/profile/root, and a window for confirmation. Maybe this is too much? Looking for suggestions!
  • Just finished localizing the parts that I have changed.

Pass “profile path” and “firefox path” to extensionTestManager, rather then extensionTestManager try to find these itself

Done(?) / Medium
  • this has sort of been done. Rather then trying to find out the executable/profile path in XE, it has been moved to the more logical place. The wizard. It passes back stuff. We like stuff.
Need to get rid of that rdf library Done / Low This is bothering the heck out of me. I shouldn't be using a 700 line rdf library and use it just once. But that would mean understanding RDF, which still isn't explained all that well, and even worse to try and develop with it.
Future suggestion : install other extensions to help debug the current extension. For example, add venkman support if it is not already present. Low Not Completed

Estimated Time of Delivery

  • I have had a hell of a time finding the title of another tab (when I did a “Save All” functionality), and I gave up. So finding the root directory will probably take half a day. Locating the extension id will probably take the other half.
  • Creating a text file and directory, I don't suspect will take very long. Maybe 2 hours at most.
  • finding out how to work with .ini and .rdf files is taking a long time. I am working on this earlier than planned, so I don't think the finish date will change.
  • Launching firefox and waiting for it will probably take a full day.

So two days? Meh, I'll make it Wednesday (Monday is a Canuck holiday)

Updated May 24, 2007

With feedback in mind :

  • I haven't done a wizard yet, but the documentation assures me its easy
  • Moving code around shouldn't take long

I'll try to make it a two day process (because it's a nice round number, unlike 1.5 days). I don't think it will take very long. Oh, but I have to read my own code. Make it 2.5 days. Round up. 3 days. Yeah. 3 days. Double it for debugging, 6 days. But wait for review 7 days. But I don't work weekends, so that's 1 week 2 days. But I have to go to the SSA office, and watch Building K, and I won't be productive, 8 days. Oh, but Monday is holiday, so I'll be finished in 1 week Thursday morning. But I said I like nice round numbers.

2 weeks.

Documentation

It is a pretty simple process.

The first time you run Extension Testing, it will prompt you for your firefox binary. It would also prompt for your profile that you would want to test under. This is suggested to be a different profile than your normal browsing profile. These two prompts are only asked once.

The last prompt will ask you for your extension directory, which should contain your install.rdf file. This would be asked each time. It will then try to run firefox with that extension. When you close firefox, that extension is removed from that profile (it should be safe, but I cannot guarantee anything :) )