Skip to content

Instantly share code, notes, and snippets.

@gregglind
Last active August 29, 2015 14:21
Show Gist options
  • Save gregglind/ac5f75ef655b10c92095 to your computer and use it in GitHub Desktop.
Save gregglind/ac5f75ef655b10c92095 to your computer and use it in GitHub Desktop.
Learn To Hack Firefox Notes

Baked Firefox, For the Busy Cook.

Or, how to make make a Telemetry Probe Cake, using modern kitchen techniques.

cats in the kitchen, claimed public domain cat kitchen school

Mise en Place

Good prep is 90% of success in cooking.

Original recipe: https://developer.mozilla.org/en-US/docs/Simple_Firefox_build

Slow cookers:

  1. Get a modern OSX (10.9+). (or windows) (1-2 hours)
  2. Get XCode from https://itunes.apple.com/us/app/xcode/id497799835# (1 hour)
  3. https://developer.mozilla.org/en-US/docs/Simple_Firefox_build
  4. Get mach (the Mozilla build helper)
    curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py > bootstrap.py && python bootstrap.py
    
  5. Checkout mozilla-central (1 hour+) OR try bash InitFromBundle.sh (untested)
mkdir -p ~/hgs/ && cd ~/hgs
hg clone https://hg.mozilla.org/mozilla-central && cd mozilla-central

First Compile.

./mach build
# this will take an hour

./mach run --profile aProfile

Now relax. You have a working Firefox

Attacking a Bug

We are going to fix a telemetry bug.

Claim: SEARCH_DEFAULT_ENGINE should be a count var, not a flag

Filing the Bug

(I like do to this at bugzilla. However, bzexport can also file bugs.)

Fixing the Bug

Prove it's a problem.

Test Script:

let Probe = Services.telemetry.getKeyedHistogramById("")...

// change default engine a few times

// get counts back.


Edit!

  1. In your editor, edit toolkit/components/telemetry/Histograms.json.

  2. Partial Recompile, and run.:

./mach build toolkit/componenents/telemetry
./mach run --profile aProfile

Verify!

about:addons  (or scratchpad)
let S = Services.telemetry.getKeyedHistogramById

// re-run the local script.

Asking for feedback (bzexport)

bzexport

Asking for review

Do it from bzexport, or from the website

set -x nounset
# init from bundle
# https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Mercurial/Bundles
cat << END
0. Warnings:
- will need a few GB of space. Repo is big.
END
## could be a case block for 'which'
echo "1. this might take 10 mins or so. watch 'Time Left' below"
## should this only 'reget?' maybe with 'forced override'
curl "http://ftp.mozilla.org/pub/mozilla.org/firefox/bundles/mozilla-central.hg" -o "/tmp/mozilla-central.hg"
# 1. Initialize a new repository (in a directory called mozilla-central here):
# fail if it exists?
mkdir mozilla-central
hg init mozilla-central
# 2. Un-bundle the bundle file to that repository:
#To use the below command in Windows, export the \path\to\hg and invoke the command from command prompt.
echo "2. Get comfortable. Grab a coffee (or your favorite tasty beverage). Maybe a nap. This unbundling process is going to take quite a lot of time."
cd mozilla-central
hg unbundle /tmp/mozilla-central.hg
echo "3. Adding the following lines to the file mozilla-central/.hg/hgrc (you may have to create it) so that Mercurial will automatically know where to pull changes from future updates."
cat >> .hg/hgrc << END
[paths]
default = https://hg.mozilla.org/mozilla-central/
END
# 4. Establish trusted users and groups so that Mercurial knows that the user root and group root are legitimate, by adding the following lines to the file /etc/mercurial/hgrc.d/trust.rc:
echo "4. there is no 4."
# [trusted]
# groups = root
# users = root
#
echo "5. Update the repository to get all the changes since the bundle was created (this step also doubles as a check of the bundle integrity since if its contents are not exactly the same as what's in the official repository then the hg pull will fail):"
hg pull
echo "6. Check out a working copy from your new up to date repository:"
hg update
cat << END
7. You should be all set.
cd mozilla-central # then hack away!
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment