27/04/2009

Headless gecko browser attempt 1

I want to be able to run selenium in a headless browser without xvfb. While I searched the googlenet to find someone having done the same thing, I came upon this : https://bugzilla.mozilla.org/show_bug.cgi?id=446591 Which basically proposes to add a headless renderer to gecko. sounds exactly like what I need, following various indications here and there, I finally got the monster to compile and give me a supposedly headless xulrunner. here are the steps I took for this :
hg clone http://hg.mozilla.org/incubator/offscreen
cd offscreen
hg checkout headless
wget -O mozconfig https://bug446591.bugzilla.mozilla.org/attachment.cgi?id=350162
make -f client.mk build
cd ../obj-x86_64-unknown-linux-gnu
This got me my headless enabled xulrunner. Then I started trying to make a xul application with an embedded browser which I could send to the selenium core url I have a main.xul with a window, a script and a browser. The script only contains the onload of the window and gets the arguments from the command line to load the browser to the given url
function onLoad() {
  var browser = document.getElementById("browser");
  var windows = document.getElementById("main");
  var url = window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine).getArgument(0);
alert(url);
  browser.loadURI(url, null, null) 
}
Works like a charm with the standard xulrunner, but when I run it headless :
jean@xps:~/dev/embedding/offbrowse$ ../obj-x86_64-unknown-linux-gnu/dist/bin/xulrunner ./application.ini http://localhost:7080/tester/
it fails with the following error :
 JavaScript error: , line 0: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMChromeWindow.getAttention]"  nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)"  location: "JS frame :: chrome://global/content/commonDialog.js :: commonDialogOnLoad :: line 195"  data: no]
and I have no idea what it means. It's been a looong time since I have felt like I was playing with unknown forces of terrible power. I don't like the look of " chrome://global/content/commonDialog.js " sounds like it is somehow trying to read something from my "production" environment ( aka my normal firefox installation) buy I have no idea how to prevent it from doing that :( A zip with all the files can be found there

Aucun commentaire: