Opened 14 years ago

Last modified 9 years ago

#3833 closed enhancement

[patch][cla] allow Dojo to work in Firefox extensions — at Version 6

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

Description (last modified by James Burke)

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:
http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/dojo-firefox-extension

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:
http://www.port21.com/Code/Dojo/FirefoxExtensionPatch/Dojo-dojo-js-udiff
http://www.port21.com/Code/Dojo/FirefoxExtensionPatch/Dojo-src-io-ScriptSrcIO-js-udiff

Files Ziped:
http://www.port21.com/Code/Dojo/FirefoxExtensionPatch/Dojo-FirefoxExtensionPatch.zip

Change History (9)

Changed 14 years ago by guest

Attachment: Dojo-dojo-js-udiff added

Changed 14 years ago by guest

Changed 14 years ago by guest

comment:1 Changed 14 years ago by dylan

Component: GeneralIO
Keywords: cometd added
Milestone: 1.0
Owner: changed from anonymous to alex

comment:2 Changed 14 years ago by Adam Peller

Milestone: 1.02.0
Summary: Patch to allow Dojo to work in Firefox extensions[patch][cla needed?] allow Dojo to work in Firefox extensions

dbrown, have you signed a CLA?

comment:3 Changed 14 years ago by guest

Yes I signed one and faxed it in before I submitted this

comment:4 Changed 14 years ago by alex

Status: newassigned
Summary: [patch][cla needed?] allow Dojo to work in Firefox extensions[patch][cla] allow Dojo to work in Firefox extensions

thanks for confirming the CLA. Much appreciated.

comment:5 Changed 14 years ago by alex

Milestone: 2.01.3

Milestone 2.0 deleted

comment:6 Changed 13 years ago by James Burke

Cc: James Burke added
Description: modified (diff)
Note: See TracTickets for help on using tickets.