Saturday, October 20, 2007

Session 13 - the new tab lab

Now, I work at my brother's Windows XP computer and everything works fine!!

I'm trying the Dave's new tab solution,(the solution is not updated but it is illustrative), I had few looks here and there since I already tried this lab last week, I knew what to do but after this humongous number of hours in front of the computer doing Mozilla development labs, I am feeling pretty tired (I started at 11am and is 11pm)

Let's get started:

  • open the file: /c/ff/mozilla/browser/base/content/tabbrowser.xml
  • I've commented the following line and I added the rest:
    // Insert tab after current tab, not at end.
    var currentTabIndex = this.mTabContainer.selectedIndex;
    this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes.item(currentTabIndex + 1));
    //pay attention it is a whole tab (the next after the current one) what it gets added as the second parameter
  • I've also modified this:
    // wire up a progress listener for the new browser object.
    // var position = this.mTabContainer.childNodes.length-1;
    // the tab has been added beside the currentTab rather than the end
    var position = currentTabIndex + 1;
    var tabListener = this.mTabProgressListener(t, b, blank);
  • I did a make in the objdir parallel folder: (I chose one folder above)
    $> make /c/ff/ff-debug-/browser/base
  • Then I run minefield:
    $> /c/ff/ff-debug-/dist/bin/firefox.exe -no-remote -P development
  • and it works (well, the deletion of the tabs is kind of screwed up but no energy to think why)

Create the patch - here's the patch
  • I did it from browser/base/content - Dave's going to kick my butt
    cvs diff -u8p . > tabPatch.txt
  • Save the file into the mozilla source folder and type this:
    patch browser/base/content/tabbrowser.xml <>
  • The patch will get applied and that's it!!!

Session 8 -Modifying the Browser Lab

I'm trying to do this lab:
but I don't have the build on the computer and trying to get through DVD or my iPod says that will take 50 minutes!!!!
I will try to use my laptop, which has the source code BUT I had so many problems trying to build on VISTA (let's try again)
  • On this file:
  • t is a XUL:tab (
    1091 var t = document.createElementNS(
    1092 ",="">",
    1093 "tab");
    1111 this.mTabContainer.appendChild(t);
  • mTabContainer is a:
    160 document.getAnonymousElementByAttribute(this, "anonid", "tabcontainer");
  • Instead of appending to the end, I want to place it just beside the current tab
  • There are few ideas I have:
    • In,
      I have found selectedIndex and insertItemAt
    • this.mTabContainer.insertItemAt(this.mTabContainer.selectedIndex+1, t);

I never finished this lab, continue reading session 13

Session 10 - Download manager - incremental patch

I took some notes in class of the incremental build that Chris and Dave had and I decided to do it since I couldn't make it work the lab of modifying the behaviour of the "new tab"

  • I modified /c/ff/mozilla/toolkit/components/download/nsDownloadManager.cpp
  • Added these lines:
    nsDownloadManager::InitDB(PRBool *aDoImport)
    #ifdef DEBUG_ARMEN
    printf("\n\n\n\n*************\N\NStarting Init in nsDownloadManager\n\n*****\n\n\n\n");
  • cd /c/ff3/obj-i686-pc-mingw32/toolkit/components/download
  • export DEBUG_ARMEN
  • make

  • After a lot of work, I got tired and I got rid of #ifdef DEBUG_ARMEN
    First, my brother's account was called "Zambrano brothers", therfore, I created an account "Armen"
  • On the Mingw32 I appear as: Armen@DAVID, when before it was Zambrano brothers@DAVID
  • but #ifdef did not work either, I tried DEBUG_ARMEN and DEBUG_Armen

  • Anyways, now the changes are reflected without the #ifdef statement

Session 12 - Incremental build lab + Shaver's patch

Proffesor Humphrey's lab - Incremental Build Lab
  • cd netwerk/protocol/http/src/
  • Added these lines to nsHttp.cpp
HttpHeapAtom *
NewHeapAtom(const char *value) {
/* DEBUG_ is defined at build time, and Faculty is the username in the lab */
#ifdef DEBUG_Faculty
printf("Hello World!\n");
  • cd /c/ff/ff-debug-/netwerk/protocol/http/src/
  • make
  • cd /c/ff/mozilla/ //it's better to get your patch from the MOZILLA folder
  • time cvs diff -u8p . > patch.txt // this way people don't have to wonder where you made the changes - 2 minutes wait
  • You can find my patch here

To apply the patch, put it in your c:\ff\mozilla folder and type this:
  • patch -p0 <>
  • Because I alread had the changes, it will reply to me saying:
patching file `netwerk/protocol/http/src/nsHttp.cpp'
Reversed (or previously applied) patch detected! Assume -R? [n]

I typed "y" to revert the changes
  • After reverting if I type it again:
patching file `netwerk/protocol/http/src/nsHttp.cpp'

I also applied Shaver's patch!!!!
can't find file to patch at input line 9
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|? threads/.gdb_history
|Index: threads/nsThread.cpp
|RCS file: /cvsroot/mozilla/xpcom/threads/nsThread.cpp,v
|retrieving revision 1.70
|diff -u -p -5 -r1.70 nsThread.cpp
|--- threads/nsThread.cpp 11 Jul 2007 03:01:56 -0000 1.70
|+++ threads/nsThread.cpp 25 Aug 2007 15:53:36 -0000
File to patch:
  • It seems that I'm not in the right folder (Shaver didn't follow the suggestion of Dave's lab!!; After all, the suggestion is for learners), after thinking a little bit:
    cd xpcom/threads/
    patch -p0 --dry-run < ../../latency-tracing-patch.txt
  • But I got the same error, I move once up
    cd ..
    patch -p0 --dry-run < ../latency-tracing-patch.txt
  • It worked!!! Now without faking the patch, making and running
    patch -p0 < ../latency-tracing-patch.txt
    cd ../../ff-debug-/xpcom
    ../dist/bin/firefox.exe -no-remote -ProfileManager
  • Dave said about: "Run your browser and watch for messages in stderr" but I don't what to look for
  • How do I really know if it all worked??? not sure; I don't know if the changes are running in the instance right now; I think I will find out in the next incremental lab that I will be going which affects the download manager

My personal Mozilla development status

Today, Saturday 20th of October, is the day that I'm going to do all the labs that I did not have enough time before to work on, and in which I will try once more to build on Vista, since, I know it worked in Vince's laptop and I think I never installed the Windows SDK, but, before that I will finish the incremental build lab and the extension's lab.

On Tuesday, we will celebrate our second coding party and hopefully get our 0.2 release almost done, stayed tuned!

Monday, October 15, 2007

Session 11 - MozillaBuild in Vista - nsinstall giving me problems

I deleted my whole objdir because I couldn't make it work an incremental build and now I find myself not being able to build on Vista.
What's wrong? After the weekend developing for the 0.1 release, now I can't build anymore on Vista AGAIN, could it has to do with it?
The last time I only had to "run as administrator" the msvc8.bat

Could it has to do that at some point I decided to update my source tree without checking tinderbox first?

I'm trying to understand this Bug 388543[MozillaBuild] nsinstall on vista dies due to UAC

Everytime, I try to run the make -f build, I get a different error, why?:
  • nsinstall: cannot copy c:\ff\mozilla\js\src\jsapi.h to ..\..\dist\include\js\jsapi.h: The system cannot find the file specified
  • nsinstall: cannot copy c:\ff\mozilla\nsprpub\pr\include\prbit.h to c:\ff\mozilla\objdir\dist\sdk\include\prbit.h: The system cannot find the file specified
  • nsinstall: cannot copy c:\ff\mozilla\xpcom\string\public\nsObsoleteAString.h to ..\..\..\dist\include\string\nsObsoleteAString.h: The system cannot find the file specified
  • nsinstall: cannot copy c:\ff\mozilla\nsprpub\pr\include\prclist.h to c:\ff\mozilla\objdir\dist\include\nspr\prclist.h: The system cannot find the file specified

Which has this ApplyManifesto.vbs, which I do not know what to do with it!!!:
Dim objFSO, objShell, objProc, objManifestFile
Dim strPathMozBuild, strPathMT, strPathExe, strArgs, strPathManifest

strPathMozBuild = "c:\mozilla-build"
strPathMT = "c:\Program Files\Microsoft Visual Studio 8\VC\bin\mt.exe"

'*** Nothing below this line should need to be modified

set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")
strPathManifest = strPathMozBuild & "\tmp.manifest"

strPathMT = Chr(34) & strPathMT & Chr(34)

AddManifestToExes strPathMozBuild & "\msys\bin"
AddManifestToExes strPathMozBuild & "\moztools\bin"
AddManifestToExes strPathMozBuild & "\moztools-180compat\bin"

Sub AddManifestToExes(byval strDirectory)
Dim fileExt
Set objFolder = objFSO.GetFolder(strDirectory)
For Each objFile In objFolder.Files
fileExt = objFSO.GetExtensionName(objFile.Path)
If fileExt = "exe" Then
AddManifest objFile
End If
For Each objFolder In objFolder.SubFolders
GetFiles objFolder.Path
End Sub

Sub AddManifest(oFile)
WScript.echo "Adding manifest to: " & oFile.Path
strPathExe = oFile.Path
Set objManifestFile = objFSO.CreateTextFile(strPathManifest, True)
objManifestFile.WriteLine ""
objManifestFile.WriteLine ""
objManifestFile.WriteLine " objManifestFile.WriteLine " processorArchitecture=""X86"""
objManifestFile.WriteLine " name=""" & oFile.Name & """"
objManifestFile.WriteLine " type=""win32""/>"
objManifestFile.WriteLine " "
objManifestFile.WriteLine " "
objManifestFile.WriteLine " "
objManifestFile.WriteLine " objManifestFile.WriteLine " level=""asInvoker"""
objManifestFile.WriteLine " uiAccess=""false""/>"
objManifestFile.WriteLine "
objManifestFile.WriteLine "
objManifestFile.WriteLine "
objManifestFile.WriteLine "

strArgs = " -outputresource:" & strPathExe & ";#1 -manifest " & strPathManifest

set objProc = objShell.Exec(strPathMT & strArgs)

WScript.Sleep 100
Loop Until objProc.Status <> 0

If objProc.ExitCode <> 0 Then
WScript.Echo "EXIT CODE: " & objProc.ExitCode
WScript.Echo "ERROR: " & objProc.StdErr.ReadAll
End If

End Sub

I also tried nsinstall.manifest to put this beside C:\mozilla-build\moztools\bin\nsinstall.exe, according to this post


Description of your application


My .mozconfig:
#mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir
. $topsrcdir/browser/config/mozconfig
# the line before sets the project as browser and enable the application
mk_add_options MOZ_MAKE_FLAGS=-j4

# Options for 'configure' (same as command-line options).
ac_add_options --enable-debug
ac_add_options --disable-static --enable-shared
ac_add_options --disable-optimize

Saturday, October 13, 2007

Experience with bugzlla

I made another post about the bugs I received because I was watching Axel (localization owner) and Dave told me that I didn't really do what he was expecting

Then I decided to add another user to watch, since I had only few bugs. I chose Ted (luser in IRC) who came to give a speech and after two days I realized I chose the wrong one; do you know why? Because I got 130+ bugs notifications in two days :P - How does he manage them? I really don't know

I've also understood now the concept of voting, which allows the users to vote for the bugs they think are more important to get fixed

I've also learned that you can save certain searches like the blocking bugs

I'm thinking that I haven't found a way to see which bugs I'm subscribed to or to see which bugs have filled others (let's say the use I want to watch) or to find users to follow (as it was mentioned in class). I have to bookmark them or use a filter on Thunderbird to direct them to a folder and then look email per email

It is insane to handle so many bugs and to receive so many emails, an interface like facebook that gives you more control on what things you are subscribed to (groups in the case of facebook), the notifications (types and frequency) of bugs activity and a long etcetera

Bugzilla won't change since it is too much work to redesign it and all the developers that have been using it for years have found many ways around to get the job just done.

Regular Expressions

"In your face regular expressions!" (shaking head)
"I don't care how many hours I spent but I defeated you"
Before our code will ruin every DTD since it would change the entity name and the value, when we only want to change the values of each entity that matches the pattern
import re

print "BEGIN"
instring = 'colorsDialog.title "asdColors">\ncolorsDialog.title "Link Colors">'
# usinf Python's raw reg exp
newstring = re.sub(r'(".*)([Cc])olor', r'\1\2olour', instring)
wrongstring = re.sub(r'([Cc])olor', r'\1olour', instring)

print instring
print newstring
print wronstring
print "END"

l10n-merge tool update

This last Friday for around six hours three fellows were trying to figure out "what are we trying to write" and on Saturday we said "man, we have something!"
In the first few hours we went over emails, python samples, etc... and then after dinner we coded a python code that reads the .dtd files from the current folder makes a regular expression substitution:
re.sub(r'([Cc])olor', r'\1olour', instring)
and saves the file with a extension .bak with the changes made

The features we want to add are:
  • More regular expressions substitutions!
    • >> color(s) -> colour(s) -- re.sub(r'([Cc])olor', r'\1olour', instring)
      >> dialogue -> dialog -- re.sub(r'([Dd])ialogue', r'\1ialog', instring)
      >> Go forward -> Go forwards -- ??, etc
      >> Minimize -> Minimise
      >> Center -> Centre
      >> Organize -> Organise
      >> Customize -> Customise
  • Read the regular expression substitutions from a file and apply them
  • Go recursively into folders with .dtd and .properties files and make the changes there too, rather than just the current folder
  • Give two parameters: where to read from and where to write the changed source - this will require a parallel creation

Thursday, October 11, 2007

Session 9 - what does it take to start again on Vista?

NOTE=I've skipped session 8 until I have the lab done

Well, I wanted to do the lab that my professor told us to do (Modify the browser ) and I normally bring a hard drive with my source and build there so I can pour into the class' computer but I forgot it!!

I had three options:
  • Build on the PC from the lab (get the source code again and build), but this required too much time!!
  • Get the source code and the build from somebody else, I tried to get it by using my iPod (the transfer said that it would take 50 miuntes!!) and through a DVD (which was only finalized by the end of the class)
  • Or just work on the research that required the lab (which I did and I got the answer but couldn't test it)

Afterwards, I got angry and I said: why other people have been able to build on Vista and not me?????

It was over, I had to tackle this and stop building at my brother's computer or on the borrowed mac!!!
"Today, I should have the minefield build running on my laptop (which uses Vista)!!"

  • I deleted the whole source code
  • I ran the environment as administrator (right click on msvc8.bat and "run as administrator")
  • I got it again
  • new .mozconfig
  • build a debug-build
  • and voila!!!!
    • real 232m57.500s (232/60=3h52min)
      user 4m56.726s
      sys 13m46.088s
    • this long time might be that I had something running wrong on Vista, since the CPU wasn't being used more than 10%. I closed some programs and killed some processed and it seemed to go faster, but I did this almost like 3 hours and half after started
    • TODO - Research on how to take advantage of my dual core and build below 60 minutes
  • I run this:
    $> ../obj-i686-pc-mingw32/dist/bin/firefox.exe -no-remote -ProfileManager
    and did not run properly
  • The I run this:
    $> export XPCOM_DEBUG_BREAK=warn
    $> ../obj-i686-pc-mingw32/dist/bin/firefox.exe -no-remote -ProfileManager
    It run but it looked like this:

  • pretty empty, isn't?
  • Look at this screenshots of the errors I saw behind the screen (it shows Leaks or something):
  • Then I did this:
    $> obj-i686-pc-mingw32/dist/bin/firefox.exe -no-remote -ProfileManager > afterRun.log
    The contents below:
  • ++WEBSHELL 014192F8 == 1
    ++DOMWINDOW == 1
    ++DOMWINDOW == 2
    --WEBSHELL 014192F8 == 0
    --DOMWINDOW == 1
    --DOMWINDOW == 0
    => mAllocCount: 7042
    => mReallocCount: 636
    => mFreeCount: 7042
    => mShareCount: 6015
    => mAdoptCount: 1380
    => mAdoptFreeCount: 1380
    ++WEBSHELL 02FD6008 == 1
    ++DOMWINDOW == 1
    * Call to xpconnect wrapped JSObject produced this error: *
    [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]" nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" location: "JS frame :: file:///c:/ff3/obj-i686-pc-mingw32/dist/bin/components/nsBrowserGlue.js :: bg__initPlaces :: line 297" data: no]
    ++DOMWINDOW == 2
    ++WEBSHELL 04519E00 == 2
    ++DOMWINDOW == 3
    ++DOMWINDOW == 4
    ++WEBSHELL 06478C18 == 3
    ++DOMWINDOW == 5
    ++DOMWINDOW == 6
    --WEBSHELL 02FD6008 == 2
    --WEBSHELL 04519E00 == 1
    --WEBSHELL 06478C18 == 0
    --DOMWINDOW == 5
    --DOMWINDOW == 4
    --DOMWINDOW == 3
    --DOMWINDOW == 2
    => mAllocCount: 16815
    => mReallocCount: 2957
    => mFreeCount: 16092 -- LEAKED 723 !!!
    => mShareCount: 14500
    => mAdoptCount: 2038
    => mAdoptFreeCount: 2024 -- LEAKED 14 !!!
  • I still had the weird leaks and the weird run of minefield, which would still work

  • It works!!!!!
    But I have to raise some things I realized:
    • When I run the corrupted profile, I get these leaks:
      => mFreeCount: 15663 -- LEAKED 666 !!!
      => mShareCount: 14267
      => mAdoptCount: 2003
      => mAdoptFreeCount: 1989 -- LEAKED 14 !!
    • The first time I run a just create a profile and use it:
      It asks me twice for a profile to select and the warnings dialog boxes appeared as if I didn't call export XPCOM_DEBUG_BREAK=warn

I hope you enjoyed this post and my next adventure would be to add that patch that I have to create for the lab; See you soon!

Monday, October 08, 2007

Session 7 - building on MacOS X 10.4

  • Building on MacOSX
  • I've installed Xcode Tools 2.4.1 and Fink 0.8.1 // I don't know why but is says on instructions // What is Xcode? how do I run it?

  • Opened terminal
  • created .cvspass on my home folder since it wouldn't allow me to use cvs //I don't know why
  • cvs -d co mozilla/
    cd mozilla
    make -f checkout MOZ_CO_PROJECT=browser //started 10:33-10:42pm
  • cvs -d co mozilla/browser/config/mozconfig
  • Create .mozconfig - firefox-static-build
  • make -f build MOZ_CURRENT_PROJECT=browser
  • The pkg-config script could not be found. Make sure it is
    *** in your path, or set the PKG_CONFIG environment variable
    *** to the full path to pkg-config to get pkg-config
  • I've updated some libraries that I didn't and when I get to the build I get this message:
    checking whether the C compiler (gcc ) works... no
    configure: error: installation or configuration problem: C compiler cannot create executables.
  • I asked in the Google Groups in the build channel and I realized that I typed:
    $> sudo gcc_select 3.3
    and for MacOS in Intel has to be 4.0, therefore:
    $> sudo gcc_select 4.0
  • It build!!
  • To run /sandbox/firefox/dist/ -no-remote -ProfileManager
  • If you try to use the finder, you have to select and browse to show contents; if you double-click it will run minefield
  • If you do /sandbox/firefox/dist/bin/firefox you won't be able to type without going the characters to the terminal rather than to Minefield
Now I can work on the mac rather than on Vista!!!

Session 6 - trying to build en-GB

  • At home, following this tutorial but to build en-GB:
  • cvs -z3 co -r MOZILLA_1_8_BRANCH mozilla/
  • cvs -z3 co mozilla/tools/l10n mozilla/testing/tests/l10n
  • cd mozilla
  • make -f l10n-checkout MOZ_CO_PROJECT=browser MOZ_CO_LOCALES=en-GB LOCALES_CO_TAG=HEAD
  • vi .mozconfig
    • . $topsrcdir/browser/config/mozconfig
      mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../en-GB
      mk_add_options MOZ_CO_LOCALES=en-GB
  • Link to source code of tools/l10n/

38 include
40 .PHONY : check-l10n
42 check-l10n:

//We have set in the .mozconfig the value MOZ_CO_LOCALES to en-GB
43 for loc in $(MOZ_CO_LOCALES); do \
44 for mod in $(sort $(foreach project,$(MOZ_PROJECT_LIST),$(LOCALES_$(project)))); do \
45 echo Comparing $(TOPSRCDIR)/$$mod/locales/en-US with $(TOPSRCDIR)/../l10n/$$loc/$$mod; \
46 perl $(TOPSRCDIR)/toolkit/locales/ $(TOPSRCDIR)/$$mod/locales/en-US $(TOPSRCDIR)/../l10n/$$loc/$$mod; \
47 done; \
48 done;
50 create-%:
51 for mod in $(sort $(foreach project,$(MOZ_PROJECT_LIST),$(LOCALES_$(project)))); do \
52 if test -d $(TOPSRCDIR)/../l10n/$*/$$mod; then \
53 echo $(TOPSRCDIR)/../l10n/$*/$$mod already exists; \
54 else \
55 echo Creating $(TOPSRCDIR)/../l10n/$*/$$mod from $(TOPSRCDIR)/$$mod/locales/en-US; \
56 mkdir -p ../l10n/$*/$$mod; \
57 cp -r $(TOPSRCDIR)/$$mod/locales/en-US/* $(TOPSRCDIR)/../l10n/$*/$$mod; \
58 find $(TOPSRCDIR)/../l10n/$*/$$mod -name CVS | xargs rm -rf; \
59 fi; \
60 done;

  • To check the completness of your localization //takes long
    • make -f tools/l10n/ check-l10n //as long as you have a .mozconfig described as above
  • The simplest tool is the makefile that we already mentioned above. It offers two targets, check-l10n and create-%.
  • MOZ_CO_PROJECT=browser make -f tools/l10n/ create-en-GB // why for l10n projects I have to set the project as browser only when I build?? It helps you to bootstrap your localization
    • make -f tools/l10n/ check-l10n
  • time MOZ_CO_PROJECT=browser make -f build
  • ERROR - configure: error: Building crypto support requires a valid version of
    the standalone assembler (ml.exe for MSVC).
    • Added this line to .mozconfig: ac_add_options --disable-crypto
  • Building again
It has actually build but it doesn't look like en-GB, I will try to build at home or at school

Bugs subscribed to

These are the bugs that I've received so far by following (

I'm also subscribed to: armenian.hy-AM@localization.bugs, but this is not part of my DPS909 project

Monday, October 01, 2007

auto l10n build tool: considerations

In Axel's email there was a lot that it is said and at the bottom of this post you can read some things I have highlighted. I'm going to send an email out and maybe file a bug to track things about this project.

Chris Hoffman had been working on an en-IN (india) localization from the en-GB and there are some bugs you can read about.

Our 0.1 milestone might be to create the X-dude langpack; I have to find out what the l10n tools and/or scripts can do for me. I also have to learn python.

Chris Hoffman's en-IN langpack and the X-dude langpack:
Chris's blog

The bug talking about en-IN:
and another one about en-CA, that mentions the necessity of automated l10n build tool:

Some of the things I want to highlight from Axel's email:
I envision this code to be python code. We have some existing python code that can extract the localization strings from a working copy,
we're using that to compare localizations, and other tests.

You can find the supporting code on, together with other tools. The scripts are in 'scripts', the modules in lib.

I think that just overwrites are likely not good enough, at least not on
a file level. One way to start would be to just specify the changed entities and use dynamis' l10n-merge work to fill in the rest, if that
could pick strings from other localizations than just en-US. More
flexibility would be a plus, though.

Try to automate localizations like en-IN or en-CA from en-GB

once you installed the modules via, you should be able to just run it, say
$> python l10n-diff mozilla/browser/locales/en-US l10n/en-GB/browser
It will spit something out that looks like a unified diff, but really isn't.

I'd say that the first good step would be to actually try to reproduce en-IN from en-GB
the next would be to create en-GB from en-US, up to points like accesskey upper-lower-case.

For en-CA and fr-CA, I guess that the language differences are none, so
you'd really only have to do the post-processing that Chris Hofmann did
for en-IN. seems to be a candidate,,
too, the two and bookmarks.html (the links need to have the
locale name twice).