Convert Firefox extension to XULRunner

Changes that take place in the XULRunner Applicaiton.

    * The id of menupopup should be same in the MainWindow.xul and browserOverlay.xul

    In MainWindow.xul

        *  Place the following statements in the 
   
            <vbox id=”appcontent” flex=”1″/>
   
            <statusbar id=”status-bar” hidden=”true”>
                <statusbarpanel id=”statusbar-display” flex=”1″/>
            </statusbar>

    In application.ini

        * Place the following statement at the end
            [XRE]
            EnableExtensionManager=true

   
    In  MainWindow.js

        * Add the following function
   
            function getBrowser() { return document.getElementById(presentUser); }

        * Place the FirebugChrome.initialize();  statement at the end of the function userChanged(userName)

How to change a Firefox extension to XULRunner extension

* Firebug uses DOM Inspector, without it won’t show style elements in CSS panel.
 
* Firebug expects TabBrowser because Firefox uses tabbed browser, so if your application has single browser then replaces TabBrowser with your browser element.

* See whether the logs are working properly

* Make an application recognize the extension by adding the following content to the install.rdf file in the root folder.

     <em:targetApplication>
        <Description>
            <em:id>xxxx@xxxx.com</em:id> // App ID that you specified in the application.ini file
            <em:minVersion>1.0</em:minVersion>
            <em:maxVersion>2.0</em:maxVersion>
            </Description>
     </em:targetApplication>

2 >     Check the chrome.manifest in the root folder. In that see which file is overlaid on browser.xul file.  Replace the chrome://browser/content/browser.xul with the URI that points to your main file and updated the overlaid file.

Adaptation of Firebug to XULRunner

    In tabWatcher.js
           
        The content id in the following code should be changed to presentUser.
                const tabBrowser = $(“content”);
                                   
                const tabBrowser = $(presentUser);

       
        In the destroy function, getBrowserByWindow and deactivate function remove the loop and replace browser with tabBrowser, cos tabBrowser is the browser object.

        Replace all occurrences of  tabBrowser.selectedBrowser with tabBrowser
   

    In Firebug.xul

        * Remove all menu items except close menu item of File menu

    In firebug.js

        * Comment out the nsIPermissionManager affected code.

        * The content id in the following code should be changed to presentUser.
                const tabBrowser = $(“content”);
                                   
                const tabBrowser = $(presentUser);

        * Replace all occurrences of  tabBrowser.selectedBrowser with tabBrowser

        * In the disableAlways function, disableSite and deactivate function remove the loop and replace browser with tabBrowser, cos tabBrowser is the browser object.

        * Return true in the isURIAllowed function

        * Return false in the isURIDenied function
In browserOverlay.xul
   
    * Remove the menupopups with ids menu_viewPopup and menu_ToolsPopup and add the following menupopup.   

    <menupopup id=”menu-popup”>
                <menuitem id=”menu_detachFirebug” insertbefore=”sanitizeSeparator”
                    label=”&firebug.Firebug;” type=”checkbox”
                    key=”key_toggleFirebug” command=”cmd_toggleDetachFirebug”/>
    </menupopup>

   
In chrome.js

•    In initialize method add the following as first line

        if (waitingPanelBarCount != 0)
            return;

In /Preferences/firebug.js

    pref(“extensions.firebug.disabledAlways”, false);

    pref(“extensions.firebug.openInWindow”, true);

Adaptation of DOM Inspector to XULRunner

      Just follow the instructions specified in the “How to change a Firefox extension to XULRunner extension”.

      For XULRunner framework version 1.8.0.* need Inspector component i.e.. inspector.dll for windows and inspector.dylib for mac. To get the inspector component you need to build the xulrunner source code because the inspector component source code is available in the source code.

Adaptation of Selenium to XULRunner

        In selenium-runner.js

            * Remove selectedBrowser reference because getBrowser return browser only not Tab Browser.

        In selenium-ide-overlay.xul
       
            * Remove unnecessary menu items
            * Replace menupopup id “menu_ToolsPopup” with “menu-popup”
       
        In selenuin-ide-loader.js
           
            * Add the following function

                function toOpenWindowByType(inType, uri) {
                      var winopts = “chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar”;
                      window.open(uri, “_blank”, winopts);
                }

        In selenuin-ide-overlay.js

            * In SeleniumIDE.Overlay.init function, the statement
                    var appcontent = window.document.getElementById(“appcontent”);
                 should be replaced with
                    var appcontent = window.document.getElementById(“MainBox”); here MainBox is a vbox which holds the browser.

            * In SeleniumIDE.Overlay.onContentLoaded function, remove the loop because we have single browser.
                window.getBrowser() return the browser.
           
        In recorder.js

            * In Recorder.forEachTab function, remove the for loop and replace the browsers array with your browser.

        In editor.js       
            * In Editor.prototype.showInBrowser function just keep the statement in the if condition part and remove everything else, because we need to open it in a new window always.

Blogged with Flock

Tags: , , , , , ,

Advertisements

10 Responses to “Convert Firefox extension to XULRunner”

  1. Mahalakshmi Says:

    Hi Praveen,

    we have a XulRunner based JAvaXPCom application in whihc am trying to enable extensions. As you know, JavaXPcom do not have application.ini and other stuff! am using SWT.MOZILLA for browser and Xulrunner 1.8.1.3.

    [XRE]
    EnableExtensionManager=true

    how do I enable this in JavaXPCom? pelase do help me.

  2. Rajesh Says:

    I want to support Selenium to our XULRunner application.
    I have followed all the steps mentioned as above. still i am not able to invoke selenium window.
    Extension gets added successfully to my app.
    In my application i have done below changes mainWindow.xul

    JavaScript function

    function getBrowser()
    {
    return document.getElementById(‘browser’);
    }

  3. Rajesh Says:

    <![CDATA[
    mainWindow.xul

    ]]>

  4. Rajesh Says:

    On mainWindow.xul i have added following code. I have removed xml tag which gets filtered on blog.

    menu id=”btnTool” accesskey=”n” label=”Tool”
    menupopup id=”menu_popup”
    menuitem label=”Options” oncommand=”” accesskey=”o”
    menupopup
    menu

    browser flex=”1″ id=”browser” src=”” type=”content-primary”

    vbox id=”appcontent” flex=”1″
    statusbar id=”status-bar” hidden=”true”
    statusbarpanel id=”statusbar-display” flex=”1″
    statusbar

    Could you help me what’s wrong in my code. And why i am not able to launch selenium

  5. praveenmatanam Says:

    The code in this post is developed for XULRunner 1.8.0.9.

  6. Rajesh Says:

    Thanks for reply.
    Is it possible to integrate selenium with xulrunner 1.9.1 application. if so what steps i need to take care.

  7. Victor Says:

    Hi, very useful article, good job.
    But actually I am using xulrunner 1.9.* and looking for solution how to adapt greasemonkey extension in my application using GeckoFX browser component.

    Could you please give me advise how to do this?

    Thanks in advance!

  8. Gabe Says:

    Any of you ever have any luck with running a XULRunner extension while using SWT? Particularly, I’d be interested if anyone was able to get Selenium running under XULRunner and SWT.

  9. Malpani Siddhesh Says:

    Praveen sir,
    I want to do a similar type of thing as your article aims. But I want this to be done in a java application.
    How can I manipulate Selenium IDE addon using my own java application..?? Is there any .jar file available for it..?? Actually I’m working on a project of automation framework. For this I want to link the “Record” button and “Menu bar”(at the top of the IDE). I’m using Eclipse on Win7 Ultimate(x64).

    Please provide the required links or documentations. I would really appreciate your kind help..
    Thanking you.

  10. Aleksandar Says:

    Dear Praveen Kumar Matanam,

    I’m trying to add Firefox extension (grab & drag) to my simple web browser based on xulrunner 25.0. I’m not familiar with XUL and not able to make things work just based on your explanation (too advanced for me :).
    Could you release, or send to me directly, complete source tree example where you have enabled firefox extension so I can apply same approach on my browser.
    Thank you in advance!

    P.S. if anybody looking at this post can provide their own xulrunner browser with firefox extension as example it helps equaly.

    Regards,
    Aleksandar


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: