Opened 15 years ago
Closed 9 years ago
#3833 closed enhancement (wontfix)
[patch][cla] allow Dojo to work in Firefox extensions
Reported by: | guest | Owned by: | Bryan Forbes |
---|---|---|---|
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 )
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
Attachments (4)
Change History (23)
Changed 15 years ago by
Attachment: | Dojo-dojo-js-udiff added |
---|
Changed 15 years ago by
Attachment: | Dojo-src-io-ScriptSrcIO-js-udiff added |
---|
Changed 15 years ago by
Attachment: | Dojo-FirefoxExtensionPatch.zip added |
---|
comment:1 Changed 15 years ago by
Component: | General → IO |
---|---|
Keywords: | cometd added |
Milestone: | → 1.0 |
Owner: | changed from anonymous to alex |
comment:2 Changed 15 years ago by
Milestone: | 1.0 → 2.0 |
---|---|
Summary: | Patch to allow Dojo to work in Firefox extensions → [patch][cla needed?] allow Dojo to work in Firefox extensions |
comment:4 Changed 15 years ago by
Status: | new → assigned |
---|---|
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:6 Changed 14 years ago by
Cc: | James Burke added |
---|---|
Description: | modified (diff) |
comment:7 Changed 14 years ago by
comment:8 Changed 14 years ago by
alex: do you have a way to test this or some sort of instructions we could commit that would give a reproducible way to try out the code? There is another ticket open for a windows script host hostenv, and I am hoping to do the same for that one too. It is harder to support these other hostenvs without easy ways to jump in and test them. I am not smart enough to remember how it works unless there is a real test/instructions.
comment:9 Changed 14 years ago by
alex: a couple of other questions:
1) I haven't thought this all the way through, maybe this would not be good: there seems like a good amount of copy/paste with the hostenv_browser. I wonder if we could use some if statements in the hostenv_browser and then use some conditional build comments that test for kwArgs.profileProperties.hostenvType to strip out stuff not needed for normal browser builds. Maybe still need an FF hostenv but it might be smaller.
2) I don't get the buildUtil.js change. I don't see isBrowser defined anywhere in the buildscripts, and no where else in [15409]?
comment:10 Changed 14 years ago by
comment:11 Changed 14 years ago by
James:
WRT the isBrowser, there's a hostenv check on line 355 of buildUtil.js which sets dojo.isBrowser to make sure that you're using browser params for the package system to ensure that the right stuff gets loaded, particularly in _base.js where you might have requireIf statements that exclude some things in non-browser environments. Since FF extensions are "browser++" environments but don't use the browser hostenv, we need another way to set this.
comment:12 Changed 14 years ago by
Alex: what I cannot see is how isBrowser is ever set. Maybe you do this in the build profile perhaps? I wonder if it is worth just changing line 355 from this:
if(hostenvType == "browser" || isBrowser)
to something like this:
if(hostenvType == "browser" || hostenvType == "ff_ext")
comment:13 Changed 14 years ago by
Milestone: | 1.3 → future |
---|
Changed 13 years ago by
Attachment: | simpleSidebar.tgz added |
---|
FF extension example, provided by Allen Cypher (IBM, CCLA) See Readme.txt
comment:14 Changed 13 years ago by
comment:15 Changed 13 years ago by
The environment uses mozIJSSubScriptLoader to load other scripts, it seems the scriptloader doesn't support unicode. When i use it with dojo.currency the currency symbols are not displayed correct.
I removed the "monkey-patch" with the mozIJSSubScriptLoader and added a nsIScriptableUnicodeConverter to the _getText method and now it works fine.
The drawback is that you don't see any syntax errors with filename and line number anymore.
comment:16 Changed 11 years ago by
Owner: | alex deleted |
---|---|
Status: | assigned → new |
comment:17 Changed 11 years ago by
Owner: | set to dylan |
---|
comment:18 Changed 10 years ago by
Owner: | changed from dylan to Bryan Forbes |
---|
Bulk change to reassign IO tickets to Bryan, since he is working on new dojo/request module. Some of these tickets should probably be closed as already fixed, invalid, or wontfix.
comment:19 Changed 9 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I am afraid this a horribly stale ticket. Significant movement in Dojo and browser extensions would require a different approach for this patch or concept to work.
dbrown, have you signed a CLA?