Prism/Scripting: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Important: The information on this page is out of date. Please refer to the Prism documentation [https://developer.mozilla.org/en/Prism] on the Mozilla Developer Center.'''
Prism allows for some client-side web application customization. The web application [[Prism/Bundle|bundle]] is allowed to hold a JavaScript file named '''webapp.js''' (called the webapp script). This file will be loaded into the Prism chrome window very much like a Firefox extension is loaded into the browser chrome window.
Prism allows for some client-side web application customization. The web application [[Prism/Bundle|bundle]] is allowed to hold a JavaScript file named '''webapp.js''' (called the webapp script). This file will be loaded into the Prism chrome window very much like a Firefox extension is loaded into the browser chrome window.


Line 28: Line 30:
};
};
</pre>
</pre>
==HostUI methods==
The methods exposed by the HostUI object allow interaction with the Prism runtime environment. 
; void log(aMsg);
: Logs a message to the Prism error console. 
; browser getBrowser();
: Returns a reference to the XUL [http://developer.mozilla.org/en/docs/XUL:browser Browser] object which displays the Prism documents
; showAlert(aImage, aTitle, aMsg);
: showAlert provides a thin wrapper around the [http://developer.mozilla.org/en/docs/nsIAlertsService nsIAlertsService.showAlertNotification] XPCOM method.
:; aImage
:: A URL to the image which should be displayed in the notification
:; aTitle
:: The string to be used as the title for the alert
:; aMsg
:: The text of the message to be displayed in the alert


There are also hooks that are called when Prism has loaded and when it is about to exit. You can declare these functions in the webapp script:
There are also hooks that are called when Prism has loaded and when it is about to exit. You can declare these functions in the webapp script:
Line 42: Line 60:
Currently, the webapp script also has access to full XPCOM functionality, just like a Firefox extension. This level of functionality is commonly called ''chrome-level'' privileges. It means that the script has a higher level of privilege than scripts in the web content and has access to the file system, clipboard and other parts of the native OS.
Currently, the webapp script also has access to full XPCOM functionality, just like a Firefox extension. This level of functionality is commonly called ''chrome-level'' privileges. It means that the script has a higher level of privilege than scripts in the web content and has access to the file system, clipboard and other parts of the native OS.
<div class="note">In the future, the webapp script may have lower privileges. We are looking into the security aspects of the higher privilege level.</div>
<div class="note">In the future, the webapp script may have lower privileges. We are looking into the security aspects of the higher privilege level.</div>
==Accessing HostUI methods==
This object can be accessed via ''''host'''' alias from webapp.js:
<pre>
function startup() {
  host.log("hello");
}
</pre>