Skip to content

Commit

Permalink
Update Makefile & add navigation debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
daijro committed Oct 10, 2024
1 parent 2101330 commit 595828a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
40 changes: 37 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ debs := python3 python3-dev python3-pip p7zip-full golang-go msitools wget aria2
rpms := python3 python3-devel p7zip golang msitools wget aria2
pacman := python python-pip p7zip go msitools wget aria2

.PHONY: help fetch setup setup-minimal clean set-target distclean build package build-launcher check-arch revert edits run bootstrap mozbootstrap dir package-linux package-macos package-windows vcredist_arch
.PHONY: help fetch setup setup-minimal clean set-target distclean build package build-launcher check-arch revert edits run bootstrap mozbootstrap dir package-linux package-macos package-windows vcredist_arch patch unpatch workspace check-arg

help:
@echo "Available targets:"
Expand All @@ -28,6 +28,12 @@ help:
@echo " package-macos - Package Camoufox for macOS"
@echo " package-windows - Package Camoufox for Windows"
@echo " run - Run Camoufox"
@echo " patch - Apply a patch"
@echo " unpatch - Remove a patch"
@echo " workspace - Sets the workspace to a patch, assuming its applied"

_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(_ARGS):;@:)

fetch:
aria2c -x16 -s16 -k1M -o $(ff_source_tarball) "https://archive.mozilla.org/pub/firefox/releases/$(version)/source/firefox-$(version).source.tar.xz"; \
Expand Down Expand Up @@ -77,7 +83,7 @@ diff:
@cd $(cf_source_dir) && git diff

checkpoint:
cd $(cf_source_dir) && git commit -m "Checkpoint" -a
cd $(cf_source_dir) && git commit -m "Checkpoint" -a -uno

clean:
cd $(cf_source_dir) && git clean -fdx && ./mach clobber
Expand Down Expand Up @@ -153,6 +159,34 @@ run-pw:
--release $(release)

run:
cd $(cf_source_dir) && rm -rf ~/.camoufox && ./mach run
CAMOU_CONFIG='{"debug": true}' \
cd $(cf_source_dir) \
&& rm -rf ~/.camoufox $(cf_source_dir)/obj-x86_64-pc-linux-gnu/tmp/profile-default \
&& ./mach run $(args)

check-arg:
@if [ -z "$(_ARGS)" ]; then \
echo "Error: No file specified. Usage: make <command> ./patches/file.patch"; \
exit 1; \
fi

patch:
@make check-arg $(_ARGS);
cd $(cf_source_dir) && patch -p1 -i ../$(_ARGS)

unpatch:
@make check-arg $(_ARGS);
cd $(cf_source_dir) && patch -p1 -R -i ../$(_ARGS)

workspace:
@make check-arg $(_ARGS);
@if (cd $(cf_source_dir) && patch -p1 -R --dry-run --force -i ../$(_ARGS)) > /dev/null 2>&1; then \
echo "Patch is already applied. Unapplying..."; \
make unpatch $(_ARGS); \
else \
echo "Patch is not applied. Proceeding with application..."; \
fi
make checkpoint || true
make patch $(_ARGS)

vcredist_arch := $(shell echo $(arch) | sed 's/x86_64/x64/' | sed 's/i686/x86/')
26 changes: 26 additions & 0 deletions patches/debug-url-navigation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/browser/base/content/browser-init.js b/browser/base/content/browser-init.js
index cc7fa914c0..760a95487e 100644
--- a/browser/base/content/browser-init.js
+++ b/browser/base/content/browser-init.js
@@ -257,6 +257,21 @@ var gBrowserInit = {
// Update UI if browser is under remote control.
gRemoteControl.updateVisualCue();

+ // Camoufox: print URL changes to console
+ if (ChromeUtils.isCamouDebug()) {
+ gBrowser.addTabsProgressListener({
+ onLocationChange(aBrowser, aWebProgress, aRequest, aLocation, aFlags) {
+ if (aBrowser === gBrowser.selectedBrowser) {
+ ChromeUtils.camouDebug("URL changed to: " + aLocation.spec);
+ }
+ }
+ });
+
+ gURLBar.addEventListener("change", () => {
+ ChromeUtils.camouDebug("URL bar value changed to: " + gURLBar.value);
+ });
+ }
+
// If we are given a tab to swap in, take care of it before first paint to
// avoid an about:blank flash.
let tabToAdopt = this.getTabToAdopt();
3 changes: 2 additions & 1 deletion settings/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
{ "property": "locale:script", "type": "str" },
{ "property": "humanize", "type": "bool" },
{ "property": "humanize:maxTime", "type": "double" },
{ "property": "showcursor", "type": "bool" }
{ "property": "showcursor", "type": "bool" },
{ "property": "debug", "type": "bool" }
]

0 comments on commit 595828a

Please sign in to comment.