Opened 14 years ago

Last modified 9 years ago

#3833 closed enhancement

Patch to allow Dojo to work in Firefox extensions — at Initial Version

Reported by: guest Owned by: anonymous
Priority: high Milestone: future
Component: IO Version: 0.9
Keywords: firefox extension, cometd Cc: [email protected]…, James Burke
Blocked By: Blocking:


I have included a patch in unified diff format, that allows Dojo to work within a Firefox extension, while keeping normal browser functionality.

This is in relation to forum post:

This patch updates /dojo.js and /src/io/ScriptScrIO.js

The reason for this patch is that within a Firefox extension there is no Head element to attach the script element too.

ScriptScrIO.js goes one step further then dojo.js and implements the same code as dojo.js but then also implements the ability to use AJAX to get the JS file. The reasoning for this extra step is because the code to add the JS file to the Firefox XUL only allows for the loading of local files. This is a problem if the user is using the cometd section of Dojo. This is because cometd needs to talk to the server which in normal cases is not local to the extension user. Therefore it uses AJAX in to get the source of the external JS file (this AJAX is able to go to a different domain because it is being ran as a extension and therefore has higher security levels). Once AJAX can retrieved the source it URI encodes it and passes it in a, data URI to the Firefox JS load function.

This gives the ability for Dojo to be smart enough to know if it is running in a normal browser window or as a Firefox extension, and also smart enough to know if it needs to load the required JS files from the local machine or from a remote server.

The only other possible requirement to have Dojo work as a Firefox extension is to set the variable: baseRelativePath. This value will be dependent on the developer and therefore was not hard coded to allow developers to easily set this variable like the normally would. In my case I set the variable to:

var djConfig = {
baseRelativePath : "chrome://myExtension/content/dojo/",

Files Seperate:

Files Ziped:

Change History (3)

Changed 14 years ago by guest

Attachment: Dojo-dojo-js-udiff added

Changed 14 years ago by guest

Changed 14 years ago by guest

Note: See TracTickets for help on using tickets.