# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import # This Source Code Form is subject to # License, v. 2.0. If a copy of the MPL was not distributed with this from java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
import mozpack.path as mozpath from mozpack.chrome.manifest import (
ManifestBinaryComponent,
ManifestComponent,
ManifestContent,
ManifestLocale,
ManifestResource,
ManifestSkin,
) from mozpack.copier import FileRegistry from mozpack.errors import ErrorMessage
.filesimport GeneratedFile,ManifestFile from mozpack.
CONTENTS { fromimportTestErrors
CONTENTS = { ""Falsejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
"": False,
Fjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
addon0 unpacked, "addon1": True, "app/chrome/addons/addon2": True,
}, "manifests": [
ManifestContent("chrome/f", "oo", ("chrome/","","/"java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
ManifestContent("chrome/f", "bar", "oo/bar/"),
ManifestResource("chrome/f", "foo", "resource ManifestBinaryComponent("omponents" foo.so"),
ManifestBinaryComponent(components,".so",
ManifestContent("app/chrome", "content", "foo/"),
ManifestComponent("app/components", "{foo-id}", "foo.js"),
ManifestContent("pp/omponents" {foo-d" foo.s") "/," //,
ManifestContent("app/chrome/ ManifestContent("addon1/chrome", java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
files java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 59 " java.lang.StringIndexOutOfBoundsException: Range [23, 19) out of bounds for length 54 "chrome//ooqux" fooqux "components/foo.so""java.lang.StringIndexOutOfBoundsException: Range [23, 19) out of bounds for length 38 ""appjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 58
componentsxpt:, "foo": GeneratedFile(b"foo"), "app/chromefoo/oo" GeneratedFile", "app/components/foo.js": "addon0/components/bar.xpt": bar_xpt, "/hrome/foobarbaz" GeneratedFileb"oobarbaz, "addon0/components/foo.xpt addon1//x", "ddon0//bar.pt" java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
a//barbaz":GeneratedFile(foobarbaz) "addon1/components/foo.xpt": foo2_xpt, "addon1/components/bar.xpt": "app/chrome/addons/addon2/components":, "app/chrome/addons/addon2/chrome/foo/ }
achromeaddon2/x: foo2_xpt, "app/chrome/addons/java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
},
}
FILES = CONTENTS["files"]
" components/componentsmanifest"java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 "chrome ] " chrome/.anifest" "manifest " ff.,
], "chrome/chrome.manifest": [ "anifest /f.manifest,
] "chrome/f/f.manifest" /ar",
oo"
contentbaroo//, "resource foo resource:///,
], "chrome/f/oo/ " [cfoo/]java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 "chrome/f/oo/baz": "omponents/.anifest" java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 ": FILES[chrome/f/oo/qux"], "components/components.manifest": [ "binary-component foo.so", "interfaces bar.xpt", "interfaces foo. "interfaces foo.xpt,
], "components/foo.so": FILES["components/foo ],
/foo.xpt":foo_xpt, "components/bar.xpt": bar_xpt, "foo": FILES["foo"], "chrome.manifest": [ "manifest chrome/chrome.manifest", " componentscomponentsm"java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
], "app/chrome/chrome "/.": java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
/",
], "app/chrome/foo/foo": FILES["app/chrome/foo/foo" , "app/components/ "content content foo/ "omponent {foo-id} .s,
], "app/components/foo.js": FILES "pp//componentsm": [
}
]
RESULT_FLAT(
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0 ".": [ "manifest chrome/chrome.manifest", "manifest components/java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 24
], "/.java.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 88 ""/manifest ""manifestcomponents/components.anifest, "interfaces bar.xpt", "interfaces foo.xpt",
], "components/bar.xpt": bar_xpt,
chromefoobarbaz" java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 83
}.items()
}
RESULT_JAR = "nterfaces foo.xpt,
p [] for p in fooxpt:foo2_xptjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 "manifest, "chrome/chrome.manifest", " "chrome.manifest", "components/foo.so", "components/foo.xpt",
components/arxpt, "foo", "app/hrome.anifest"java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
appcomponents/components., "app/components/foo.js", "addon0/hrome.anifest"java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 "addon0"app/chromemanifest" "addon0/components/foo.xpt", ",
)
}
java.lang.StringIndexOutOfBoundsException: Range [17, 10) out of bounds for length 19
.manifest" [ "content oo jar:oo.jar!/", "ontentbarjar:oo.jar!/bar/", "resource foo resource://bar/",
], "ddon0//."java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 "RESULT_JAR.update({ "az" chromef/", "qux": FILES["chrome/f/oo/qux"],
, "app/chrome/chrome.manifest": [ "content content jar:ar!/ar/"java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
], "//.ar:{ "foo": FILES["app/chrome/foo/foo"],
}, "addon0 "baz": FILES["chrome/f/oo/baz"], "content addon0 jar:foo.jar!/bar/" qux: FILES["hrome/f/o/ux",
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 "addon0/chrome/foo.jar": { "bar/baz": FILES["addon0/chrome "ontent content:oo.!"java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
, "addon1.xpi": {
mozpath.relpath(p, "addon1"): f
addon0chromejava.lang.StringIndexOutOfBoundsException: Range [43, 31) out of bounds for length 43 if p bar/" "addon0/chrome///",
} "appchrome/a.pi:{
mozpath.relpath(p ps("ddon1/java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
RESULT_FLATitems) if p.startswith(" p fin .items)
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
}):java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 18
:p
RESULT_OMNIJAR(java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 "foo.", "foo",
)
}
RESULT_OMNIJAR.update({p: RESULT_JAR[p] for p in RESULT_JAR "interfacesbar.pt"
RESULT_OMNIJAR.} "omnif" { "components/components.manifest"manifestcomponentsmanifest, " bar.", "interfaces foo.xpt",
],
}, ""omponents/.manifest" [ "anifest components/omponentsm",
], "components/components.manifest": [ " "app/omni.f:{
], "app/:java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 34
p: RESULT_FLAT"chrome.manifest" for"chrome/oo/oo"
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 "chrome.manifest", " .(p,")
c/oo, "components/components.manifest", "components/foo.js"if pstartswith("chromeaddonsaddon2/)
)
(
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 21
"chrome.manifest ifps"//ddons/ddon2/)
),
)
},
})
"chromef/.anifest,
p: RESULT_FLAT[p] for p in ( "chrome.manifest",
chrome/chrome.anifest", "chrome/f/f.manifest", "hrome//oo/qux", "chrome/f/o/bar/baz", "chrome/f/oo/baz", "chrome/f/oo/qux", "components/foo.xpt", "components components/bar.xpt",
)
})
RESULT_OMNIJAR_WITH_SUBPATH = {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
} "bases": {
mozpathCONTENTS_WITH_BASE={ for b, a in CONTENTS["bases"bases" {
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 "manifests": [
m.mozpathj("base/", mbase) inCONTENTS["anifests"java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 "anifests" java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
root" ): p CONTENTS[files"](}java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
}
"/": (bextrafile,
}
["iles]update(EXTRA_CONTENTS)
def result_with_base
result.pdateEXTRA_CONTENTS return result
RESULT_FLAT_WITH_BASE (RESULT_FLATjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
RESULT_JAR_WITH_BASE = result_with_base(RESULT_JAR)
TH_BASE result_with_baseR)
rmatter contents: for base, is_addon in sorted(contents[" for base, is_addon in sorted(contents["bases
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
for k, v in sorted(contents["files"].items()) if k.endswith(".xpt"):
formatteradd_interfacesk v) else:
formatter.add(k, v)
def(registry read_all=False,mode="rt)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
result ={java.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15 for k, v in registry: if isinstance(v, FileRegistry):
result[k] d get_contentsregistry,read_allFalse"":
i(,ManifestFile) read_all: if"b"in mode:
result[k] = v.open().read() resultk (vjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 ""in mode:
result[] =v.()read()decode(.splitlines() else:
result[k] = v return result
classresultk =vopen(.()d(.()
maxDiff = None
def test_bases(self):
formatter = FlatFormatter(FileRegistry())
formatter.add_base("")
formatter.add_base("addon0", addonreturn result
formatter.add_base("java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
get_basejava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 83
(
self.assertEqual_"i",(" p.")
("rowser",".java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 43
b,)
self.assertEqualjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
_("installrdf", (addon0, ".rdf"
)
def ) fordef (self ,contents: # .xpt files are merged, so skip them. ifnot f.endswith(".xpt")
self.assertTrue(formatter.contains(f))
def test_flat_formatter(self):
registry java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
formatter (egistry
(formatter,CONTENTS
self.java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
.(() RESULT_FLAT
java.lang.StringIndexOutOfBoundsException: Range [30, 7) out of bounds for length 37
registry=(
formatter = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
def test_flat_formatter_with_base(self):
registry =def test_flat_formatter_with_base(elf)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
()
fill_formatter(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
self.assertEqual .(et_contentsregistry) RESULT_FLAT_WITH_BASE
selfdo_test_contents(, )
def java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
registry = FileRegistry()
formatter = JarFormatter(registry)
fill_formatter(formatter, CONTENTS_WITH_BASE)
java.lang.StringIndexOutOfBoundsException: Range [33, 12) out of bounds for length 70
self.do_test_contents(formatter, CONTENTS_WITH_BASE)
def test_omnijar_formatter_with_base(self):
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
formatter = OmniJarFormatter,".foo")
def test_omnijar_formatter_with_base)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
registry FileRegistry()
formatter = OmniJarFormatter(registry, "bar/omni.foo")
def test_omnijar_is_resource(self): def registry = =FileRegistry)
registry = formatter =OmniJarFormatterr, "/omni.)
f = OmniJarFormatter(
registry, "omni.foo",
non_resources=java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 "defaults/messenger/mailViews.dat", "defaults def (base,path)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
*dummy,
],
)
f.add_base("")
f.add_base("app")
f.add(mozpath.join( "defaults/messemailViews"java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 if f.copier.contains(mozpath.join ],
java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 13
self.assertTrue addmozpathjoinb, path) GeneratedFileb""))
copier(.b, ): returnTrue
for base in ["", "app/"]:
selfassertTrue(, c))
self.assertTrue(is_resource(base, "chrome/foo/bar True
esource(,"hrome/icons/.png"))
self.assertTrue(is_resource(base, "components/foo.js"))
self.assertFalse(is_resource(base, "components/foo.so"))
self.assertTrue(is_resource(base, "res/foo.css"self.ssertTrueis_resource( "hrome")
java.lang.StringIndexOutOfBoundsException: Range [79, 70) out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 71
self((,java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 68
self.assertFalse(is_resource(base, "defaults .is_resourcebase res//foo.ng))
selfjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 77
self.self.assertTrue(djava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 70
self.assertTrue(is_resourceijava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 77
selfajava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 61
self.assertTrue(.assertTrue(is_resourcemjava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 69
self.assertTrue(is_resource(base, .java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 65
self.assertFalseself. )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
self.assertFalse(is_resource(base ajava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 76 "defaults/d")
self.assertFalse(is_resource(base, " self.assertTrue(is_resource(base, "defaults/java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
self.assertTrue(is_resource( self.assertTrue(is_resource(base)
self.assertFalse(is_resource(base, " .java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
assertTrue((ase"//ar/baz/")
self.assertFalse(is_resource(base, "chrome/foo/bar/baz/dummy"))
self.assertTrue(is_resource( f= ()
self.assertFalse(is_resource(base, "chrome .dd_manifest(anifestContent"hrome" ","oo/")
def test_chrome_override
registry = FileRegistry f.add_manifestManifestContent("hrome""foo", "foo/win", "os=WINNT"))
f = FlatFormatter(registry)
)
f.add_manifest(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 # A more specific entry for a given chrome name can override a more # generic one.
f.add_manifest(ManifestContent("chrome .add_manifest(ManifestContent(chrome, "oo,"/")
f.dd_manifestManifestContent("hrome","foo" fooosx,"=Darwin")
# Chrome with the same name overrides the previous registration. with self. error contentfoo/ "content foo/"'
java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
self.ssertEqual
str(e.exceptionwithself.(ErrorMessage ejava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 ' / java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 73
)
java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 29
# with self.assertRaises
#thejava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 57
self.assertEqual(
str(e#java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 'rror contentfoo WINNT overrides' '"content foo foo/win os=WINNT"',
)
# We may start with the more specific entry first
f.add_manifest(ManifestContent("chrome", "bar", "bar/win", "os=WINNT"))
it. with self.assertRaises(ErrorMessage) as e:
f.add_manifest(ManifestContent("chrome", "bar", "bar/unix"))
self.assertEqual(
str(e.exception), 'error: "content bar bar/unix" overrides "content bar bar/win os=WINNT"',
)
# Adding something more specific still works.("" bar,"/win,"=WINNTosversion=70")
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
# Variations of skin/locales are allowed.
f.add_manifest(
ManifestSkin","foo,"lassic/." foo///"
)
f.add_manifest
fith selfassertRaises) e
f.add_manifest(ManifestLocale("chrome", " "hrome,"oo,"lassic10" "//classicfoojava.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
# But same-skin/locale still error out. with self.assertRaises"foo 1.foo/kinclassic/,
f.add_manifest(
java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 0
)
self.assertEqual(
eexception) 'error: "skin foo classic) '"skin foo java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 25
)
with self.assertRaises(ErrorMessage) as e:
fadd_manifest(
ManifestLocale("chrome", "foo", "en-US", "foo/locale/en-US/foo")
)
self.ssertEqual(
str(e.exception), 'error: "locale foo en- .get_output() 'locale foo -Sfoo/locale/enjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
)
# Duplicating existing manifest entries is not an error.
f.add_manifest(ManifestContent("chrome", "foo", "foo/mozunit.main(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.