Archive for the ‘FireFox’ Category

Testing File Uploads with Selenium RC and Firefox(Or: Reducing Javascript Security in Firefox for fun and profit.)

Thursday, June 7th, 2007

People seem to have some problems when it comes to testing file uploads with Selenium RC. I’m not the first to provide a solution but making this work with Selenium RC might take a few more steps.

With Selenium RC you get a fresh browser each time you start a test run. So you’ll need to add this to your default profile in a You can upload files with Firefox if you build a custom profile with relaxed Javascript securities. You wouldn’t want to run this relaxed security version against any code that you don’t trust obviously, so be careful.

Step 1. Create a new Firefox profile. Step 2. Edit prefs.js to include:

user_pref("signed.applets.codebase_principal_support", true);

Step 3. Modify your AUT (this is why this is bad way to test file uploads via Selenium) to request enhanced permissions via:

netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead"); 
// This gives Javascript the ability to open file:// URI's.

Step 4. Visit your AUT using the profile you’ve just created, you’ll hopefully be greeted with a warning asking you if Javascript should be allowed UniversalFileRead permissions. Clicking yes will add entries to your prefs.js file that look like the following:

user_pref("capability.principal.codebase.p0.granted", "UniversalFileRead");
user_pref("capability.principal.codebase.p0.id", "http://your_aut_domain.com");
user_pref("capability.principal.codebase.p0.subjectName", "");

You can then edit your SeleniumRC instance to launch FireFox using this specific profile.

You can, and probably should, go farther with this by granting per file permissions.

More info:

Adding display names to Twitter icon images.

Thursday, February 8th, 2007

Jeff Barr talked about adding real names to Twitter via greasemonkey..

I’ve been writing lots of ridiculous Javascript to mess with an app I’ve been testing so I put together the quickest and ugliest GreaseMonkey script to do what Jeff asked for, real names on profile pictures.

So, here we are now…

twitter  greasemonkey before and after

Here is the script if you’re interested in it. If you can add CSS to make it look better please let me know.

// ==UserScript==
// @name          Twitter Real Name
// @description   Adds spans to twitter icons showing profile names.
// @include       http://twitter.com/*
// @exclude
// ==/UserScript==
var contacts = document.evaluate(
    "//a[@rel='contact']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

for(var i = 0; i < contacts.snapshotLength; i++)
{
  var friend = contacts.snapshotItem(i);
  var span = document.createElement('span');
  span.id = 'real-name-' + friend.id;
  span.innerHTML = friend.title;
  friend.parentNode.insertBefore(span, friend.nextSibling );
}

FireFox Tip: How to Enable the Marquee Tag

Thursday, October 5th, 2006

We all love the <marquee> tag, right? Been missing it in FireFox? Well, go edit your config prefs.js file while FireFox is closed and add the following lines…

// Enable the marquee tag (disabled by default): user_pref("browser.display.enable_marquee", true);

Presto! <marquee> is back!

For more fun options, check out http://www.mozilla.org/unix/customizing.html#prefs.