MozillaZine

nsBrowserContentHandler.js is gibberish

Discuss building things with or for the Mozilla Platform.
Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 5th, 2014, 7:46 pm

I'd like to modify some lines in nsBrowserContentHandler.js.

I've extracted omni.ja.
JS files in "omni\jsloader\resource\app\components" are gibberish (using Notepad++).
I have no problem opening JS files in omni\chrome\browser\content\browser.

Any idea?

Thank you.

morat
 
Posts: 2686
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 6th, 2014, 1:16 pm

Dave Townsend wrote:Basically everything under the jsloader directory of omni.jar is a binary version of a shipped component or module.

https://bugzilla.mozilla.org/show_bug.cgi?id=691847#c50

Try deleting (1) and editing (2) in the browser/omni.ja archive.

1. jsloader/resource/app/components/nsBrowserContentHandler.js
2. components/nsBrowserContentHandler.js

And remember to purge the caches.

https://developer.mozilla.org/en/Extens ... _4#Caching

Override component - possible?
https://groups.google.com/forum/#!topic ... YEBviCniB8

Remember Passwords extension overrides components/nsLoginManager.js
https://addons.mozilla.org/firefox/addon/331315

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 6th, 2014, 1:56 pm

Thank you morat. I really appreciate your help.

I want to allow external links to open in a private window. I've changed the following lines in nsBrowserContentHandler.js ("omni\components"):

var allowPrivate = forcePrivate || PrivateBrowsingUtils.permanentPrivateBrowsing;
var navWin = RecentWindow.getMostRecentBrowserWindow({private: allowPrivate});

to:

// var allowPrivate = forcePrivate || PrivateBrowsingUtils.permanentPrivateBrowsing;
var navWin = RecentWindow.getMostRecentBrowserWindow({private: true});

***

If I delete the two files, how can I modify anything? I may have misunderstood you.
Purging the caches didn't help.
It seems that I have to modify the file in "omni\jsloader\resource\app\components" as well. I'm not a pro, and I don't know how to do that.

I'd appreciate your further assistance.

patrickjdempsey

User avatar
 
Posts: 23734
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted June 6th, 2014, 2:18 pm

Attempting to modify those files may be what has "scrambled" them, especially since you are running in a pre-release version that gets more updates than the release version.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/

morat
 
Posts: 2686
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 6th, 2014, 5:37 pm

You delete the binary file and edit the normal js file.

I edited the following line in the nsBrowserContentHandler.js file so that the preferences command line option opens the Page Info window instead of the Options dialog.

Code: Select all
- var url = "chrome://browser/content/preferences/preferences.xul";
+ var url = "chrome://browser/content/pageinfo/pageInfo.xul";

Code: Select all
optimizejars.py --deoptimize "E:" "C:\Program Files\Mozilla Firefox\browser" "E:" > nul
unzip -l omni.ja | find "nsBrowserContentHandler.js"
zip -d omni.ja jsloader/resource/app/components/nsBrowserContentHandler.js
unzip omni.ja components/nsBrowserContentHandler.js
gvim components/nsBrowserContentHandler.js
zip omni.ja components/nsBrowserContentHandler.js
ren "C:\Program Files\Mozilla Firefox\browser\omni.ja" omni.old
optimizejars.py --optimize "E:" "E:" "C:\Program Files\Mozilla Firefox\browser" > nul
"C:\Program Files\Mozilla Firefox\firefox.exe" -purgecaches
"C:\Program Files\Mozilla Firefox\firefox.exe" -preferences

It works here.

Firefox ESR 24.5.0
Windows 7 SP1

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 6th, 2014, 6:10 pm

Thanks again morat. It's really kind of you.

Could you please elaborate on the second section?
I'm not familiar with the commands 'optimizejars.py' and 'gvim'.
And what's '-preferences'?

I'd appreciate it if you could explain to me the steps you've taken.

Regards.

morat
 
Posts: 2686
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 6th, 2014, 8:10 pm

I use the optimizejars.py python script to deoptimize and optimize the omni.ja file.

Usage: --optimize|--deoptimize JAR_LOG_DIR IN_JAR_DIR OUT_JAR_DIR

viewtopic.php?f=23&t=2752877

I use info-zip.org utilities to unzip and zip files.

unzip -l switch = list files in a zip file
zip -d switch = delete files in a zip file

http://www.info-zip.org/

Graphical Vim (i.e. gvim) is a text editor.

http://www.vim.org/

About omni.ja
https://developer.mozilla.org/en-US/docs/Mozilla/About_omni.ja_(formerly_omni.jar)

Yaron10 wrote:And what's '-preferences'?

firefox.exe -help | more

Usage: firefox [ options ... ] [URL]
where options include:

-h or -help Print this message.
-v or -version Print Firefox version.
-P <profile> Start with <profile>.
-migration Start with migration wizard.
-ProfileManager Start with ProfileManager.
-no-remote Do not accept or send remote commands; implies -new-instance.
-new-instance Open new instance, not a new window in running instance.
-UILocale <locale> Start with <locale> resources as UI Locale.
-safe-mode Disables extensions and themes for this session.
-console Start Firefox with a debugging console.
-jsconsole Open the Error console.
-browser Open a browser window.
-new-window <url> Open <url> in a new window.
-new-tab <url> Open <url> in a new tab.
-preferences Open Options dialog.
-search <term> Search <term> with your default search engine.
-recording <file> Record drawing for a given URL.
-recording-output <file> Specify destination file for a drawing recording.
-setDefaultBrowser Set this app as the default browser.

I just picked something at random to test...

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 7th, 2014, 7:54 am

Hi morat,

I appreciate your patience and apologize for the late reply (time zone).

With your permission, some more questions:
1) If I use optimizejars.py - should I delete the binary nsBrowserContentHandler.js file, or I get it as a text file and should modify it?
2) Is the following order correct? * deoptimize omni.ja * unzip omni.ja * modify the js files * optimize omni.ja * zip omni.ja *
3) I understand I should run optimizejars.py from the command line. What's the '> nul' parameter?
4) Should optimizejars.py work with FF 30?

Thanks again.

morat
 
Posts: 2686
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 8th, 2014, 8:39 am

There are 2 nsBrowserContentHandler.js files in the browser/omni.ja archive in FF ESR 24.

gibberish file: jsloader/resource/app/components/nsBrowserContentHandler.js
text file: components/nsBrowserContentHandler.js

You need to delete the gibberish file and edit the text file in the browser/omni.ja archive. I assume it's the same for FF 30.

What's the '> nul' parameter?

Batch How To
http://www.robvanderwoude.com/battech_redirection.php

I would think hacking an omni.ja archive is too difficult for someone who does not know how to use the command line.

Should optimizejars.py work with FF 30?

I don't know. marty60 said it works with FF 27.

I get a warning if I list the files in an optimized omni.ja archive in FF ESR 24.

Code: Select all
unzip -l omni.ja | find "nsBrowserContentHandler.js"

warning [omni.ja]:  4253366 extra bytes at beginning or within zipfile
  (attempting to process anyway)
error [omni.ja]:  reported length of central directory is
  -4253366 bytes too long (Atari STZip zipfile?  J.H.Holm ZIPSPLIT 1.1
  zipfile?).  Compensating...
    31449  01/01/2010 00:00   jsloader/resource/app/components/nsBrowserContentHandler.js
    30629  01/01/2010 00:00   components/nsBrowserContentHandler.js

And no warning if I list the files in a deoptimized omni.ja archive in FF ESR 24.

Code: Select all
unzip -l omni.ja | find "nsBrowserContentHandler.js"

    31449  01/01/2010 00:00   jsloader/resource/app/components/nsBrowserContentHandler.js
    30629  01/01/2010 00:00   components/nsBrowserContentHandler.js

If I deoptimize then optimize without deleting or editing a file in the archive then compare the archives - there would be no differences encountered in FF ESR 24.

FC command
http://www.computerhope.com/fchlp.htm

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 8th, 2014, 5:40 pm

Thanks again. I appreciate it.

I told you I wasn't a pro. But I can learn fast with a good teacher. :)


I deleted the binary file and edited the text file. I then re-zipped the files to omni.ja and placed the new file in the 'browser' folder.
It worked as I wanted and external links opened in a private window.

I didn't use optimizejars.py. I would have installed Python and used it, but meanwhile I found out that I could add '-private-window' to my Email Client and get what I want without modifying 'nsBrowserContentHandler.js'.

So - just for the knowledge - allow me to conclude with one last question:
If Firefox can work without the JS binary files, I assume that they're included in omni.ja for a better performance. Is that correct?


Best regards.

morat
 
Posts: 2686
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 9th, 2014, 4:35 am

I think omni.ja and jsloader exists solely to make Firefox start faster.

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 9th, 2014, 7:38 am

Thank you. It's been a pleasure.

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted June 9th, 2014, 11:56 am

morat wrote:I think omni.ja and jsloader exists solely to make Firefox start faster.

The jsloader files are pre-compiled Javascript byte-code. These allow Firefox to startup faster as the JS engine doesn't have to JIT compile the real .js files.

Phil

Yaron10
 
Posts: 439
Joined: July 5th, 2011, 6:32 am

Post Posted June 9th, 2014, 12:17 pm

Thank you Phil.

Return to Mozilla Development


Who is online

Users browsing this forum: No registered users and 1 guest