Mission: run a web application without the normal browser UI, as a XULRunner application but using Firefox (version 3 and above).

I am a Firefox funboy. So I want to use Gecko rather than WebKit (Electron).

Idea

XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox and Thunderbird.

Firefox (from version 3) ships with a private XULRunner package, which can run any compatible XULRunner application using the -app switch: firefox -app application.ini is equivalent to xulrunner -app application.ini

Prism is a simple XULRunner-based browser that hosts web applications without the normal web browser user interface.

Solution

Example: view https://www.google.com/ without the normal browser UI.

Souce code is available on github cat-in-136/study-for-xulrunner-as-prism-using-firefox.

Normal approach

Open app.xul when the XULRunner_as_prism application is lanched. And then app.xul load the web page – https://www.google.com/

  • application.ini

    [App]
    Vendor=cat_in_136
    Name=XULRunner_as_prism
    Version=0.0
    BuildID=20160206
    Copyright=Copyright (c) 2016 @cat_in_136
    ID=xulrunner_as_prism@cat-in-136.github.io
    
    [Gecko]
    MinVersion=38
    MaxVersion=*
  • defaults/preferences/prefs.js

    pref("toolkit.defaultChromeURI", "chrome://xrap/content/app.xul");
  • chrome.manifest

    content xrap content/
    
  • content/app.xul

    <?xml version="1.0"?>
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    <window id="main" width="400" height="300" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <browser id="browser" flex="1" type="content-primary" src="https://www.google.co.jp/"/>
    <findbar id="findbar" hidden="false" browserid="browser"/>
    </window>

How to run: firefox -app application.ini

Minimum code solution

XULRunner FAQ says:

If I use XULRunner do I have to write my application in XUL?
No! You can write your application in any language supported by the Mozilla web platform, including HTML, XHTML, SVG, or XUL.

Wow!

  • application.ini (No Change)

    [App]
    Vendor=cat_in_136
    Name=XULRunner_as_prism
    Version=0.0
    BuildID=20160206
    Copyright=Copyright (c) 2016 @cat_in_136
    ID=xulrunner_as_prism@cat-in-136.github.io
    
    [Gecko]
    MinVersion=38
    MaxVersion=*
  • defaults/preferences/prefs.js

    pref("toolkit.defaultChromeURI", "https://www.google.com/");

How to run: firefox -app application.ini

Note: profile folder location

The profile folder is placed in %APPDATA%\cat_in_136 (for windows) or ~/.cat_in_136 (for unix). You may remove this folder after you close this XULRunner_as_prism application.

References