Ejemplo n.º 1
0
    def add_manifest(self, entry):
        # Store manifest entries in a single manifest per directory, named
        # after their parent directory, except for root manifests, all named
        # chrome.manifest.
        if entry.base:
            name = mozpath.basename(entry.base)
        else:
            name = 'chrome'
        path = mozpath.normpath(mozpath.join(entry.base, '%s.manifest' % name))
        if not self.copier.contains(path):
            # Add a reference to the manifest file in the parent manifest, if
            # the manifest file is not a root manifest.
            if entry.base:
                parent = mozpath.dirname(entry.base)
                relbase = mozpath.basename(entry.base)
                relpath = mozpath.join(relbase,
                                            mozpath.basename(path))
                self.add_manifest(Manifest(parent, relpath))
            self.copier.add(path, ManifestFile(entry.base))

        if isinstance(entry, ManifestChrome):
            data = self._chrome_db.setdefault(entry.name, {})
            entries = data.setdefault(entry.type, [])
            for e in entries:
                # Ideally, we'd actually check whether entry.flags are more
                # specific than e.flags, but in practice the following test
                # is enough for now.
                if not entry.flags or e.flags and entry.flags == e.flags:
                    errors.fatal('"%s" overrides "%s"' % (entry, e))
            entries.append(entry)

        self.copier[path].add(entry)
Ejemplo n.º 2
0
 def add_manifest(self, entry):
     # Store manifest entries in a single manifest per directory, named
     # after their parent directory, except for root manifests, all named
     # chrome.manifest.
     if entry.base:
         name = mozpath.basename(entry.base)
     else:
         name = 'chrome'
     path = mozpath.normpath(mozpath.join(entry.base, '%s.manifest' % name))
     if not self.copier.contains(path):
         # Add a reference to the manifest file in the parent manifest, if
         # the manifest file is not a root manifest.
         if entry.base:
             parent = mozpath.dirname(entry.base)
             relbase = mozpath.basename(entry.base)
             relpath = mozpath.join(relbase, mozpath.basename(path))
             self.add_manifest(Manifest(parent, relpath))
         self.copier.add(path, ManifestFile(entry.base))
     self.copier[path].add(entry)
Ejemplo n.º 3
0
 def add_manifest(self, entry):
     # Store manifest entries in a single manifest per directory, named
     # after their parent directory, except for root manifests, all named
     # chrome.manifest.
     base = self._get_base(entry.base)
     if entry.base == base:
         name = 'chrome'
     else:
         name = mozpack.path.basename(entry.base)
     path = mozpack.path.normpath(
         mozpack.path.join(entry.base, '%s.manifest' % name))
     if not self.copier.contains(path):
         assert mozpack.path.basedir(entry.base, [base]) == base
         # Add a reference to the manifest file in the parent manifest, if
         # the manifest file is not a root manifest.
         if len(entry.base) > len(base):
             parent = mozpack.path.dirname(entry.base)
             relbase = mozpack.path.basename(entry.base)
             relpath = mozpack.path.join(relbase,
                                         mozpack.path.basename(path))
             FlatFormatter.add_manifest(self, Manifest(parent, relpath))
         self.copier.add(path, ManifestFile(entry.base))
     self.copier[path].add(entry)
Ejemplo n.º 4
0
def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
    app = LocaleManifestFinder(app_finder)
    l10n = LocaleManifestFinder(l10n_finder)

    # The code further below assumes there's only one locale replaced with
    # another one.
    if len(app.locales) > 1:
        errors.fatal("Multiple app locales aren't supported: " +
                     ",".join(app.locales))
    if len(l10n.locales) > 1:
        errors.fatal("Multiple l10n locales aren't supported: " +
                     ",".join(l10n.locales))
    locale = app.locales[0]
    l10n_locale = l10n.locales[0]

    # For each base directory, store what path a locale chrome package name
    # corresponds to.
    # e.g., for the following entry under app/chrome:
    #     locale foo en-US path/to/files
    # keep track that the locale path for foo in app is
    # app/chrome/path/to/files.
    # As there may be multiple locale entries with the same base, but with
    # different flags, that tracking takes the flags into account when there
    # are some. Example:
    #     locale foo en-US path/to/files/win os=Win
    #     locale foo en-US path/to/files/mac os=Darwin
    def key(entry):
        if entry.flags:
            return '%s %s' % (entry.name, entry.flags)
        return entry.name

    l10n_paths = {}
    for e in l10n.entries:
        if isinstance(e, ManifestChrome):
            base = mozpath.basedir(e.path, app.bases)
            l10n_paths.setdefault(base, {})
            l10n_paths[base][key(e)] = e.path

    # For chrome and non chrome files or directories, store what langpack path
    # corresponds to a package path.
    paths = {}
    for e in app.entries:
        if isinstance(e, ManifestEntryWithRelPath):
            base = mozpath.basedir(e.path, app.bases)
            if base not in l10n_paths:
                errors.fatal("Locale doesn't contain %s/" % base)
                # Allow errors to accumulate
                continue
            if key(e) not in l10n_paths[base]:
                errors.fatal("Locale doesn't have a manifest entry for '%s'" %
                             e.name)
                # Allow errors to accumulate
                continue
            paths[e.path] = l10n_paths[base][key(e)]

    for pattern in non_chrome:
        for base in app.bases:
            path = mozpath.join(base, pattern)
            left = set(p for p, f in app_finder.find(path))
            right = set(p for p, f in l10n_finder.find(path))
            for p in right:
                paths[p] = p
            for p in left - right:
                paths[p] = None

    # Create a new package, with non localized bits coming from the original
    # package, and localized bits coming from the langpack.
    packager = SimplePackager(formatter)
    for p, f in app_finder:
        if is_manifest(p):
            # Remove localized manifest entries.
            for e in [e for e in f if e.localized]:
                f.remove(e)
        # If the path is one that needs a locale replacement, use the
        # corresponding file from the langpack.
        path = None
        if p in paths:
            path = paths[p]
            if not path:
                continue
        else:
            base = mozpath.basedir(p, paths.keys())
            if base:
                subpath = mozpath.relpath(p, base)
                path = mozpath.normpath(mozpath.join(paths[base], subpath))

        if path:
            files = [f for p, f in l10n_finder.find(path)]
            if not len(files):
                if base not in non_chrome:
                    finderBase = ""
                    if hasattr(l10n_finder, 'base'):
                        finderBase = l10n_finder.base
                    errors.error("Missing file: %s" %
                                 os.path.join(finderBase, path))
            else:
                packager.add(path, files[0])
        else:
            packager.add(p, f)

    # Add localized manifest entries from the langpack.
    l10n_manifests = []
    for base in set(e.base for e in l10n.entries):
        m = ManifestFile(base, [e for e in l10n.entries if e.base == base])
        path = mozpath.join(base, 'chrome.%s.manifest' % l10n_locale)
        l10n_manifests.append((path, m))
    bases = packager.get_bases()
    for path, m in l10n_manifests:
        base = mozpath.basedir(path, bases)
        packager.add(path, m)
        # Add a "manifest $path" entry in the top manifest under that base.
        m = ManifestFile(base)
        m.add(Manifest(base, mozpath.relpath(path, base)))
        packager.add(mozpath.join(base, 'chrome.manifest'), m)

    packager.close()

    # Add any remaining non chrome files.
    for pattern in non_chrome:
        for base in bases:
            for p, f in l10n_finder.find(mozpath.join(base, pattern)):
                if not formatter.contains(p):
                    formatter.add(p, f)

    # Resources in `localization` directories are packaged from the source and then
    # if localized versions are present in the l10n dir, we package them as well
    # keeping the source dir resources as a runtime fallback.
    for p, f in l10n_finder.find('**/localization'):
        if not formatter.contains(p):
            formatter.add(p, f)

    # Transplant jar preloading information.
    for path, log in six.iteritems(app_finder.jarlogs):
        assert isinstance(copier[path], Jarrer)
        copier[path].preload([l.replace(locale, l10n_locale) for l in log])
Ejemplo n.º 5
0
    def test_l10n_repack(self):
        foo = GeneratedFile('foo')
        foobar = GeneratedFile('foobar')
        qux = GeneratedFile('qux')
        bar = GeneratedFile('bar')
        baz = GeneratedFile('baz')
        dict_aa = GeneratedFile('dict_aa')
        dict_bb = GeneratedFile('dict_bb')
        dict_cc = GeneratedFile('dict_cc')
        barbaz = GeneratedFile('barbaz')
        lst = GeneratedFile('foo\nbar')
        app_finder = MockFinder({
            'bar/foo':
            foo,
            'chrome/foo/foobar':
            foobar,
            'chrome/qux/qux.properties':
            qux,
            'chrome/qux/baz/baz.properties':
            baz,
            'chrome/chrome.manifest':
            ManifestFile('chrome', [
                ManifestContent('chrome', 'foo', 'foo/'),
                ManifestLocale('chrome', 'qux', 'en-US', 'qux/'),
            ]),
            'chrome.manifest':
            ManifestFile('', [Manifest('', 'chrome/chrome.manifest')]),
            'dict/aa':
            dict_aa,
            'app/chrome/bar/barbaz.dtd':
            barbaz,
            'app/chrome/chrome.manifest':
            ManifestFile(
                'app/chrome',
                [ManifestLocale('app/chrome', 'bar', 'en-US', 'bar/')]),
            'app/chrome.manifest':
            ManifestFile('app', [Manifest('app', 'chrome/chrome.manifest')]),
            'app/dict/bb':
            dict_bb,
            'app/dict/cc':
            dict_cc,
            'app/chrome/bar/search/foo.xml':
            foo,
            'app/chrome/bar/search/bar.xml':
            bar,
            'app/chrome/bar/search/lst.txt':
            lst,
        })
        app_finder.jarlogs = {}
        app_finder.base = 'app'
        foo_l10n = GeneratedFile('foo_l10n')
        qux_l10n = GeneratedFile('qux_l10n')
        baz_l10n = GeneratedFile('baz_l10n')
        barbaz_l10n = GeneratedFile('barbaz_l10n')
        lst_l10n = GeneratedFile('foo\nqux')
        l10n_finder = MockFinder({
            'chrome/qux-l10n/qux.properties':
            qux_l10n,
            'chrome/qux-l10n/baz/baz.properties':
            baz_l10n,
            'chrome/chrome.manifest':
            ManifestFile('chrome', [
                ManifestLocale('chrome', 'qux', 'x-test', 'qux-l10n/'),
            ]),
            'chrome.manifest':
            ManifestFile('', [Manifest('', 'chrome/chrome.manifest')]),
            'dict/bb':
            dict_bb,
            'dict/cc':
            dict_cc,
            'app/chrome/bar-l10n/barbaz.dtd':
            barbaz_l10n,
            'app/chrome/chrome.manifest':
            ManifestFile(
                'app/chrome',
                [ManifestLocale('app/chrome', 'bar', 'x-test', 'bar-l10n/')]),
            'app/chrome.manifest':
            ManifestFile('app', [Manifest('app', 'chrome/chrome.manifest')]),
            'app/dict/aa':
            dict_aa,
            'app/chrome/bar-l10n/search/foo.xml':
            foo_l10n,
            'app/chrome/bar-l10n/search/qux.xml':
            qux_l10n,
            'app/chrome/bar-l10n/search/lst.txt':
            lst_l10n,
        })
        l10n_finder.base = 'l10n'
        copier = FileRegistry()
        formatter = FlatFormatter(copier)

        l10n._repack(app_finder, l10n_finder, copier, formatter,
                     ['dict', 'chrome/**/search/*.xml'])
        self.maxDiff = None

        repacked = {
            'bar/foo':
            foo,
            'chrome/foo/foobar':
            foobar,
            'chrome/qux-l10n/qux.properties':
            qux_l10n,
            'chrome/qux-l10n/baz/baz.properties':
            baz_l10n,
            'chrome/chrome.manifest':
            ManifestFile('chrome', [
                ManifestContent('chrome', 'foo', 'foo/'),
                ManifestLocale('chrome', 'qux', 'x-test', 'qux-l10n/'),
            ]),
            'chrome.manifest':
            ManifestFile('', [Manifest('', 'chrome/chrome.manifest')]),
            'dict/bb':
            dict_bb,
            'dict/cc':
            dict_cc,
            'app/chrome/bar-l10n/barbaz.dtd':
            barbaz_l10n,
            'app/chrome/chrome.manifest':
            ManifestFile(
                'app/chrome',
                [ManifestLocale('app/chrome', 'bar', 'x-test', 'bar-l10n/')]),
            'app/chrome.manifest':
            ManifestFile('app', [Manifest('app', 'chrome/chrome.manifest')]),
            'app/dict/aa':
            dict_aa,
            'app/chrome/bar-l10n/search/foo.xml':
            foo_l10n,
            'app/chrome/bar-l10n/search/qux.xml':
            qux_l10n,
            'app/chrome/bar-l10n/search/lst.txt':
            lst_l10n,
        }

        self.assertEqual(
            dict((p, f.open().read()) for p, f in copier),
            dict((p, f.open().read()) for p, f in repacked.iteritems()))
Ejemplo n.º 6
0
def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
    app = LocaleManifestFinder(app_finder)
    l10n = LocaleManifestFinder(l10n_finder)

    # The code further below assumes there's only one locale replaced with
    # another one.
    if len(app.locales) > 1 or len(l10n.locales) > 1:
        errors.fatal("Multiple locales aren't supported")
    locale = app.locales[0]
    l10n_locale = l10n.locales[0]

    # For each base directory, store what path a locale chrome package name
    # corresponds to.
    # e.g., for the following entry under app/chrome:
    #     locale foo en-US path/to/files
    # keep track that the locale path for foo in app is
    # app/chrome/path/to/files.
    l10n_paths = {}
    for e in l10n.entries:
        if isinstance(e, ManifestChrome):
            base = mozpack.path.basedir(e.path, app.bases)
            l10n_paths.setdefault(base, {})
            l10n_paths[base][e.name] = e.path

    # For chrome and non chrome files or directories, store what langpack path
    # corresponds to a package path.
    paths = dict((e.path,
                  l10n_paths[mozpack.path.basedir(e.path, app.bases)][e.name])
                 for e in app.entries
                 if isinstance(e, ManifestEntryWithRelPath))

    for pattern in non_chrome:
        for base in app.bases:
            path = mozpack.path.join(base, pattern)
            left = set(p for p, f in app_finder.find(path))
            right = set(p for p, f in l10n_finder.find(path))
            for p in right:
                paths[p] = p
            for p in left - right:
                paths[p] = None

    # Create a new package, with non localized bits coming from the original
    # package, and localized bits coming from the langpack.
    packager = SimplePackager(formatter)
    for p, f in app_finder:
        if is_manifest(p):
            # Remove localized manifest entries.
            for e in [e for e in f if e.localized]:
                f.remove(e)
        # If the path is one that needs a locale replacement, use the
        # corresponding file from the langpack.
        path = None
        if p in paths:
            path = paths[p]
            if not path:
                continue
        else:
            base = mozpack.path.basedir(p, paths.keys())
            if base:
                subpath = mozpack.path.relpath(p, base)
                path = mozpack.path.normpath(mozpack.path.join(paths[base],
                                                               subpath))
        if path:
            files = [f for p, f in l10n_finder.find(path)]
            if not len(files):
                if base not in non_chrome:
                    errors.error("Missing file: %s" %
                                 os.path.join(l10n_finder.base, path))
            else:
                packager.add(path, files[0])
        else:
            packager.add(p, f)

    # Add localized manifest entries from the langpack.
    l10n_manifests = []
    for base in set(e.base for e in l10n.entries):
        m = ManifestFile(base, [e for e in l10n.entries if e.base == base])
        path = mozpack.path.join(base, 'chrome.%s.manifest' % l10n_locale)
        l10n_manifests.append((path, m))
    bases = packager.get_bases()
    for path, m in l10n_manifests:
        base = mozpack.path.basedir(path, bases)
        packager.add(path, m)
        # Add a "manifest $path" entry in the top manifest under that base.
        m = ManifestFile(base)
        m.add(Manifest(base, mozpack.path.relpath(path, base)))
        packager.add(mozpack.path.join(base, 'chrome.manifest'), m)

    packager.close()

    # Add any remaining non chrome files.
    for pattern in non_chrome:
        for base in bases:
            for p, f in l10n_finder.find(mozpack.path.join(base, pattern)):
                if not formatter.contains(p):
                    formatter.add(p, f)

    # Transplant jar preloading information.
    for path, log in app_finder.jarlogs.iteritems():
        assert isinstance(copier[path], Jarrer)
        copier[path].preload([l.replace(locale, l10n_locale) for l in log])
Ejemplo n.º 7
0
 def test_parse_manifest(self):
     manifest = [
         'content global content/global/',
         'content global content/global/ application=foo application=bar' +
         ' platform',
         'locale global en-US content/en-US/',
         'locale global en-US content/en-US/ application=foo',
         'skin global classic/1.0 content/skin/classic/',
         'skin global classic/1.0 content/skin/classic/ application=foo' +
         ' os=WINNT',
         '',
         'manifest pdfjs/chrome.manifest',
         'resource gre-resources toolkit/res/',
         'override chrome://global/locale/netError.dtd' +
         ' chrome://browser/locale/netError.dtd',
         '# Comment',
         'component {b2bba4df-057d-41ea-b6b1-94a10a8ede68} foo.js',
         'contract @mozilla.org/foo;1' +
         ' {b2bba4df-057d-41ea-b6b1-94a10a8ede68}',
         'interfaces foo.xpt',
         'binary-component bar.so',
         'category command-line-handler m-browser' +
         ' @mozilla.org/browser/clh;1' +
         ' application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}',
         'style chrome://global/content/viewSource.xul' +
         ' chrome://browser/skin/',
         'overlay chrome://global/content/viewSource.xul' +
         ' chrome://browser/content/viewSourceOverlay.xul',
     ]
     other_manifest = ['content global content/global/']
     expected_result = [
         ManifestContent('', 'global', 'content/global/'),
         ManifestContent('', 'global', 'content/global/', 'application=foo',
                         'application=bar', 'platform'),
         ManifestLocale('', 'global', 'en-US', 'content/en-US/'),
         ManifestLocale('', 'global', 'en-US', 'content/en-US/',
                        'application=foo'),
         ManifestSkin('', 'global', 'classic/1.0', 'content/skin/classic/'),
         ManifestSkin('', 'global', 'classic/1.0', 'content/skin/classic/',
                      'application=foo', 'os=WINNT'),
         Manifest('', 'pdfjs/chrome.manifest'),
         ManifestResource('', 'gre-resources', 'toolkit/res/'),
         ManifestOverride('', 'chrome://global/locale/netError.dtd',
                          'chrome://browser/locale/netError.dtd'),
         ManifestComponent('', '{b2bba4df-057d-41ea-b6b1-94a10a8ede68}',
                           'foo.js'),
         ManifestContract('', '@mozilla.org/foo;1',
                          '{b2bba4df-057d-41ea-b6b1-94a10a8ede68}'),
         ManifestInterfaces('', 'foo.xpt'),
         ManifestBinaryComponent('', 'bar.so'),
         ManifestCategory(
             '', 'command-line-handler', 'm-browser',
             '@mozilla.org/browser/clh;1',
             'application=' + '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'),
         ManifestStyle('', 'chrome://global/content/viewSource.xul',
                       'chrome://browser/skin/'),
         ManifestOverlay('', 'chrome://global/content/viewSource.xul',
                         'chrome://browser/content/viewSourceOverlay.xul'),
     ]
     with mozunit.MockedOpen({
             'manifest': '\n'.join(manifest),
             'other/manifest': '\n'.join(other_manifest)
     }):
         # Ensure we have tests for all types of manifests.
         self.assertEqual(set(type(e) for e in expected_result),
                          set(MANIFESTS_TYPES.values()))
         self.assertEqual(list(parse_manifest(os.curdir, 'manifest')),
                          expected_result)
         self.assertEqual(
             list(parse_manifest(os.curdir, 'other/manifest')),
             [ManifestContent('other', 'global', 'content/global/')])
Ejemplo n.º 8
0
    def test_l10n_repack(self):
        foo = GeneratedFile(b"foo")
        foobar = GeneratedFile(b"foobar")
        qux = GeneratedFile(b"qux")
        bar = GeneratedFile(b"bar")
        baz = GeneratedFile(b"baz")
        dict_aa = GeneratedFile(b"dict_aa")
        dict_bb = GeneratedFile(b"dict_bb")
        dict_cc = GeneratedFile(b"dict_cc")
        barbaz = GeneratedFile(b"barbaz")
        lst = GeneratedFile(b"foo\nbar")
        app_finder = MockFinder({
            "bar/foo":
            foo,
            "chrome/foo/foobar":
            foobar,
            "chrome/qux/qux.properties":
            qux,
            "chrome/qux/baz/baz.properties":
            baz,
            "chrome/chrome.manifest":
            ManifestFile(
                "chrome",
                [
                    ManifestContent("chrome", "foo", "foo/"),
                    ManifestLocale("chrome", "qux", "en-US", "qux/"),
                ],
            ),
            "chrome.manifest":
            ManifestFile("", [Manifest("", "chrome/chrome.manifest")]),
            "dict/aa":
            dict_aa,
            "app/chrome/bar/barbaz.dtd":
            barbaz,
            "app/chrome/chrome.manifest":
            ManifestFile(
                "app/chrome",
                [ManifestLocale("app/chrome", "bar", "en-US", "bar/")]),
            "app/chrome.manifest":
            ManifestFile("app", [Manifest("app", "chrome/chrome.manifest")]),
            "app/dict/bb":
            dict_bb,
            "app/dict/cc":
            dict_cc,
            "app/chrome/bar/search/foo.xml":
            foo,
            "app/chrome/bar/search/bar.xml":
            bar,
            "app/chrome/bar/search/lst.txt":
            lst,
        })
        app_finder.jarlogs = {}
        app_finder.base = "app"
        foo_l10n = GeneratedFile(b"foo_l10n")
        qux_l10n = GeneratedFile(b"qux_l10n")
        baz_l10n = GeneratedFile(b"baz_l10n")
        barbaz_l10n = GeneratedFile(b"barbaz_l10n")
        lst_l10n = GeneratedFile(b"foo\nqux")
        l10n_finder = MockFinder({
            "chrome/qux-l10n/qux.properties":
            qux_l10n,
            "chrome/qux-l10n/baz/baz.properties":
            baz_l10n,
            "chrome/chrome.manifest":
            ManifestFile(
                "chrome",
                [
                    ManifestLocale("chrome", "qux", "x-test", "qux-l10n/"),
                ],
            ),
            "chrome.manifest":
            ManifestFile("", [Manifest("", "chrome/chrome.manifest")]),
            "dict/bb":
            dict_bb,
            "dict/cc":
            dict_cc,
            "app/chrome/bar-l10n/barbaz.dtd":
            barbaz_l10n,
            "app/chrome/chrome.manifest":
            ManifestFile(
                "app/chrome",
                [ManifestLocale("app/chrome", "bar", "x-test", "bar-l10n/")],
            ),
            "app/chrome.manifest":
            ManifestFile("app", [Manifest("app", "chrome/chrome.manifest")]),
            "app/dict/aa":
            dict_aa,
            "app/chrome/bar-l10n/search/foo.xml":
            foo_l10n,
            "app/chrome/bar-l10n/search/qux.xml":
            qux_l10n,
            "app/chrome/bar-l10n/search/lst.txt":
            lst_l10n,
        })
        l10n_finder.base = "l10n"
        copier = FileRegistry()
        formatter = FlatFormatter(copier)

        l10n._repack(
            app_finder,
            l10n_finder,
            copier,
            formatter,
            ["dict", "chrome/**/search/*.xml"],
        )
        self.maxDiff = None

        repacked = {
            "bar/foo":
            foo,
            "chrome/foo/foobar":
            foobar,
            "chrome/qux-l10n/qux.properties":
            qux_l10n,
            "chrome/qux-l10n/baz/baz.properties":
            baz_l10n,
            "chrome/chrome.manifest":
            ManifestFile(
                "chrome",
                [
                    ManifestContent("chrome", "foo", "foo/"),
                    ManifestLocale("chrome", "qux", "x-test", "qux-l10n/"),
                ],
            ),
            "chrome.manifest":
            ManifestFile("", [Manifest("", "chrome/chrome.manifest")]),
            "dict/bb":
            dict_bb,
            "dict/cc":
            dict_cc,
            "app/chrome/bar-l10n/barbaz.dtd":
            barbaz_l10n,
            "app/chrome/chrome.manifest":
            ManifestFile(
                "app/chrome",
                [ManifestLocale("app/chrome", "bar", "x-test", "bar-l10n/")],
            ),
            "app/chrome.manifest":
            ManifestFile("app", [Manifest("app", "chrome/chrome.manifest")]),
            "app/dict/aa":
            dict_aa,
            "app/chrome/bar-l10n/search/foo.xml":
            foo_l10n,
            "app/chrome/bar-l10n/search/qux.xml":
            qux_l10n,
            "app/chrome/bar-l10n/search/lst.txt":
            lst_l10n,
        }

        self.assertEqual(
            dict((p, f.open().read()) for p, f in copier),
            dict((p, f.open().read()) for p, f in six.iteritems(repacked)),
        )
Ejemplo n.º 9
0
 def test_parse_manifest(self):
     manifest = [
         "content global content/global/",
         "content global content/global/ application=foo application=bar"
         + " platform",
         "locale global en-US content/en-US/",
         "locale global en-US content/en-US/ application=foo",
         "skin global classic/1.0 content/skin/classic/",
         "skin global classic/1.0 content/skin/classic/ application=foo"
         + " os=WINNT",
         "",
         "manifest pdfjs/chrome.manifest",
         "resource gre-resources toolkit/res/",
         "override chrome://global/locale/netError.dtd"
         + " chrome://browser/locale/netError.dtd",
         "# Comment",
         "component {b2bba4df-057d-41ea-b6b1-94a10a8ede68} foo.js",
         "contract @mozilla.org/foo;1" + " {b2bba4df-057d-41ea-b6b1-94a10a8ede68}",
         "interfaces foo.xpt",
         "binary-component bar.so",
         "category command-line-handler m-browser"
         + " @mozilla.org/browser/clh;1"
         + " application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
         "style chrome://global/content/viewSource.xul" + " chrome://browser/skin/",
         "overlay chrome://global/content/viewSource.xul"
         + " chrome://browser/content/viewSourceOverlay.xul",
     ]
     other_manifest = ["content global content/global/"]
     expected_result = [
         ManifestContent("", "global", "content/global/"),
         ManifestContent(
             "",
             "global",
             "content/global/",
             "application=foo",
             "application=bar",
             "platform",
         ),
         ManifestLocale("", "global", "en-US", "content/en-US/"),
         ManifestLocale("", "global", "en-US", "content/en-US/", "application=foo"),
         ManifestSkin("", "global", "classic/1.0", "content/skin/classic/"),
         ManifestSkin(
             "",
             "global",
             "classic/1.0",
             "content/skin/classic/",
             "application=foo",
             "os=WINNT",
         ),
         Manifest("", "pdfjs/chrome.manifest"),
         ManifestResource("", "gre-resources", "toolkit/res/"),
         ManifestOverride(
             "",
             "chrome://global/locale/netError.dtd",
             "chrome://browser/locale/netError.dtd",
         ),
         ManifestComponent("", "{b2bba4df-057d-41ea-b6b1-94a10a8ede68}", "foo.js"),
         ManifestContract(
             "", "@mozilla.org/foo;1", "{b2bba4df-057d-41ea-b6b1-94a10a8ede68}"
         ),
         ManifestInterfaces("", "foo.xpt"),
         ManifestBinaryComponent("", "bar.so"),
         ManifestCategory(
             "",
             "command-line-handler",
             "m-browser",
             "@mozilla.org/browser/clh;1",
             "application=" + "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
         ),
         ManifestStyle(
             "", "chrome://global/content/viewSource.xul", "chrome://browser/skin/"
         ),
         ManifestOverlay(
             "",
             "chrome://global/content/viewSource.xul",
             "chrome://browser/content/viewSourceOverlay.xul",
         ),
     ]
     with mozunit.MockedOpen(
         {
             "manifest": "\n".join(manifest),
             "other/manifest": "\n".join(other_manifest),
         }
     ):
         # Ensure we have tests for all types of manifests.
         self.assertEqual(
             set(type(e) for e in expected_result), set(MANIFESTS_TYPES.values())
         )
         self.assertEqual(
             list(parse_manifest(os.curdir, "manifest")), expected_result
         )
         self.assertEqual(
             list(parse_manifest(os.curdir, "other/manifest")),
             [ManifestContent("other", "global", "content/global/")],
         )