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: , , , , , ,