Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 685523: Provide mobile support through "cfx --force-mobile".
Browse files Browse the repository at this point in the history
  • Loading branch information
ochameau authored and warner committed Sep 20, 2011
1 parent 9924ae2 commit 33df04a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
11 changes: 9 additions & 2 deletions python-lib/cuddlefish/__init__.py
Expand Up @@ -165,6 +165,11 @@
action="store_true",
default=False,
cmds=['xpi'])),
(("", "--force-mobile",), dict(dest="enable_mobile",
help="Force compatibility with Firefox Mobile",
action="store_true",
default=False,
cmds=['run', 'test', 'xpi', 'testall'])),
]
),

Expand Down Expand Up @@ -690,7 +695,8 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
target_cfg=target_cfg,
bundle_id=bundle_id,
update_url=options.update_url,
bootstrap=True)
bootstrap=True,
enable_mobile=options.enable_mobile)

if command == "xpi" and options.update_link:
rdf_name = UPDATE_RDF_FILENAME % target_cfg.name
Expand Down Expand Up @@ -744,7 +750,8 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
addons=options.addons,
args=options.cmdargs,
norun=options.no_run,
used_files=used_files)
used_files=used_files,
enable_mobile=options.enable_mobile)
except Exception, e:
if str(e).startswith(MOZRUNNER_BIN_NOT_FOUND):
print >>sys.stderr, MOZRUNNER_BIN_NOT_FOUND_HELP.strip()
Expand Down
10 changes: 9 additions & 1 deletion python-lib/cuddlefish/prefs.py
Expand Up @@ -4,7 +4,15 @@
# sets this preference)
'browser.dom.window.dump.enabled': True,
# warn about possibly incorrect code
'javascript.options.strict': True
'javascript.options.strict': True,
'javascript.options.showInConsole': True,
'extensions.logging.enabled': True
}

DEFAULT_FENNEC_PREFS = {
'extensions.logging.enabled': True,
'javascript.options.showInConsole': True,
'browser.console.showInPanel': True
}

# When launching a temporary new Firefox profile, use these preferences.
Expand Down
22 changes: 21 additions & 1 deletion python-lib/cuddlefish/rdf.py
Expand Up @@ -109,7 +109,7 @@ def remove(self, property):
return True;

def gen_manifest(template_root_dir, target_cfg, bundle_id,
update_url=None, bootstrap=True):
update_url=None, bootstrap=True, enable_mobile=False):
install_rdf = os.path.join(template_root_dir, "install.rdf")
manifest = RDFManifest(install_rdf)

Expand All @@ -129,6 +129,26 @@ def gen_manifest(template_root_dir, target_cfg, bundle_id,
else:
manifest.remove("em:updateURL")

if enable_mobile:
dom = manifest.dom
target_app = dom.createElement("em:targetApplication")
dom.documentElement.getElementsByTagName("Description")[0].appendChild(target_app)

ta_desc = dom.createElement("Description")
target_app.appendChild(ta_desc)

elem = dom.createElement("em:id")
elem.appendChild(dom.createTextNode("{a23983c0-fd0e-11dc-95ff-0800200c9a66}"))
ta_desc.appendChild(elem)

elem = dom.createElement("em:minVersion")
elem.appendChild(dom.createTextNode("4.0b7"))
ta_desc.appendChild(elem)

elem = dom.createElement("em:maxVersion")
elem.appendChild(dom.createTextNode("9.0a1"))
ta_desc.appendChild(elem)

if target_cfg.get("homepage"):
manifest.set("em:homepageURL", target_cfg.get("homepage"))
else:
Expand Down
15 changes: 13 additions & 2 deletions python-lib/cuddlefish/runner.py
Expand Up @@ -13,6 +13,7 @@
from cuddlefish.prefs import DEFAULT_COMMON_PREFS
from cuddlefish.prefs import DEFAULT_FIREFOX_PREFS
from cuddlefish.prefs import DEFAULT_THUNDERBIRD_PREFS
from cuddlefish.prefs import DEFAULT_FENNEC_PREFS

def follow_file(filename):
"""
Expand Down Expand Up @@ -215,7 +216,7 @@ def find_binary(self):
def run_app(harness_root_dir, manifest_rdf, harness_options,
app_type, binary=None, profiledir=None, verbose=False,
timeout=None, logfile=None, addons=None, args=None, norun=None,
used_files=None):
used_files=None, enable_mobile=False):
if binary:
binary = os.path.expanduser(binary)

Expand All @@ -242,6 +243,7 @@ def run_app(harness_root_dir, manifest_rdf, harness_options,
runner_class = mozrunner.ThunderbirdRunner
elif app_type == "fennec":
profile_class = FennecProfile
preferences.update(DEFAULT_FENNEC_PREFS)
runner_class = FennecRunner
else:
raise ValueError("Unknown app: %s" % app_type)
Expand Down Expand Up @@ -330,7 +332,7 @@ def maybe_remove_logfile():
# Note: this regex doesn't handle all valid versions in the Toolkit Version
# Format <https://developer.mozilla.org/en/Toolkit_version_format>, just the
# common subset that we expect Mozilla apps to use.
mo = re.search(r"Mozilla (Firefox|Iceweasel) ((\d+)\.\S*)",
mo = re.search(r"Mozilla (Firefox|Iceweasel|Fennec) ((\d+)\.\S*)",
version_output)
if not mo:
# cfx may be used with Thunderbird, SeaMonkey or an exotic Firefox
Expand All @@ -339,6 +341,15 @@ def maybe_remove_logfile():
WARNING: cannot determine Firefox version; please ensure you are running
a Mozilla application equivalent to Firefox 4.0 or greater.
"""
elif mo.group(1) == "Fennec":
# For now, only allow running on Mobile with --force-mobile argument
if not enable_mobile:
print """
WARNING: Firefox Mobile support is still experimental.
If you would like to run an addon on this platform, use --force-mobile flag:
cfx --force-mobile"""
return
else:
version = mo.group(3)
if int(version) < 4:
Expand Down

0 comments on commit 33df04a

Please sign in to comment.