Permalink
Browse files

Make sub-sub-manifest paths relative when necessary (bug 720720)

  • Loading branch information...
1 parent 3d25b7c commit b3ef9d1a2c6b2309bcea2c16b3d8d0dbd56a9ea4 @mattbasta committed Sep 12, 2012
@@ -0,0 +1 @@
+manifest foo.manifest
@@ -0,0 +1 @@
+manifest dir/level2.manifest
View
@@ -159,6 +159,32 @@ def test_proper_linked_manifest():
eq_(zaps[0]["context"].data, ["zap baz", ""])
+def test_proper_linked_manifest_relative():
+ """
+ Test that linked manifests are imported relatively when using relative
+ paths.
+ """
+
+ err = ErrorBundle()
+ package = MockXPI({
+ "chrome.manifest": "tests/resources/submain/linkman/subdir.manifest",
+ "dir/level2.manifest":
+ "tests/resources/submain/linkman/foosub.manifest",
+ "dir/foo.manifest": "tests/resources/submain/linkman/base2.manifest"})
+
+ submain.populate_chrome_manifest(err, package)
+ chrome = err.get_resource("chrome.manifest")
+ assert chrome
+
+ assert not err.failed() or err.notices
+
+ # From the linked manifest:
+ zaps = list(chrome.get_triples(subject="zap"))
+ assert zaps
+ eq_(zaps[0]["filename"], "dir/foo.manifest")
+ eq_(zaps[0]["context"].data, ["zap baz", ""])
+
+
def test_missing_manifest_link():
"""Test that missing linked manifests are properly flagged."""
@@ -192,6 +218,8 @@ def test_linked_manifest_recursion():
chrome = err.get_resource("chrome.manifest")
assert chrome
+ print err.print_summary(verbose=True)
+
assert err.failed()
assert not err.notices
View
@@ -210,14 +210,13 @@ def _load_install_rdf(err, package, expectation):
# Compare the results of the low-level type detection to
# that of the expectation and the assumption.
if not expectation in (PACKAGE_ANY, results):
- err.warning(("main",
- "test_package",
- "extension_type_mismatch"),
- "Extension Type Mismatch",
- ["We detected that the add-on's type does not match the "
- "expected type.",
- 'Type "%s" expected, found "%s")' %
- (types[expectation], types[results])])
+ err.warning(
+ err_id=("main", "test_package", "extension_type_mismatch"),
+ warning="Extension Type Mismatch",
+ description=["We detected that the add-on's type does not match "
+ "the expected type.",
+ 'Type "%s" expected, found "%s"' %
+ (types[expectation], types[results])])
def populate_chrome_manifest(err, xpi_package):
@@ -263,8 +262,17 @@ def get_linked_manifest(path, from_path, from_chrome, from_triple):
yield triple
if triple["subject"] == "manifest":
+ subpath = triple["predicate"]
+ # If the path is relative, make it relative to the current
+ # file.
+ if not subpath.startswith("/"):
+ subpath = "%s/%s" % (
+ "/".join(path.split("/")[:-1]), subpath)
+
+ subpath = subpath.lstrip("/")
+
for subtriple in get_linked_manifest(
- triple["predicate"], path, manifest, triple):
+ subpath, path, manifest, triple):
yield subtriple
chrome_recursion_buster.discard(path)

0 comments on commit b3ef9d1

Please sign in to comment.