示例#1
0
    def test_manifest_file(self):
        f = ManifestFile('chrome')
        f.add(ManifestContent('chrome', 'global', 'toolkit/content/global/'))
        f.add(ManifestResource('chrome', 'gre-resources', 'toolkit/res/'))
        f.add(
            ManifestLocale('chrome', 'browser', 'en-US',
                           'en-US/locale/browser/'))

        f.copy(self.tmppath('chrome.manifest'))
        self.assertEqual(
            open(self.tmppath('chrome.manifest')).readlines(), [
                'content global toolkit/content/global/\n',
                'resource gre-resources toolkit/res/\n',
                'locale browser en-US en-US/locale/browser/\n',
            ])

        self.assertRaises(
            ValueError, f.remove,
            ManifestContent('', 'global', 'toolkit/content/global/'))
        self.assertRaises(
            ValueError, f.remove,
            ManifestOverride('chrome', 'chrome://global/locale/netError.dtd',
                             'chrome://browser/locale/netError.dtd'))

        f.remove(ManifestContent('chrome', 'global',
                                 'toolkit/content/global/'))
        self.assertRaises(
            ValueError, f.remove,
            ManifestContent('chrome', 'global', 'toolkit/content/global/'))

        f.copy(self.tmppath('chrome.manifest'))
        content = open(self.tmppath('chrome.manifest')).read()
        self.assertEqual(content[:42], f.open().read(42))
        self.assertEqual(content, f.open().read())
示例#2
0
    def test_manifest_file(self):
        f = ManifestFile("chrome")
        f.add(ManifestContent("chrome", "global", "toolkit/content/global/"))
        f.add(ManifestResource("chrome", "gre-resources", "toolkit/res/"))
        f.add(ManifestResource("chrome/pdfjs", "pdfjs", "./"))
        f.add(ManifestContent("chrome/pdfjs", "pdfjs", "pdfjs"))
        f.add(
            ManifestLocale("chrome", "browser", "en-US",
                           "en-US/locale/browser/"))

        f.copy(self.tmppath("chrome.manifest"))
        self.assertEqual(
            open(self.tmppath("chrome.manifest")).readlines(),
            [
                "content global toolkit/content/global/\n",
                "resource gre-resources toolkit/res/\n",
                "resource pdfjs pdfjs/\n",
                "content pdfjs pdfjs/pdfjs\n",
                "locale browser en-US en-US/locale/browser/\n",
            ],
        )

        self.assertRaises(
            ValueError,
            f.remove,
            ManifestContent("", "global", "toolkit/content/global/"),
        )
        self.assertRaises(
            ValueError,
            f.remove,
            ManifestOverride(
                "chrome",
                "chrome://global/locale/netError.dtd",
                "chrome://browser/locale/netError.dtd",
            ),
        )

        f.remove(ManifestContent("chrome", "global",
                                 "toolkit/content/global/"))
        self.assertRaises(
            ValueError,
            f.remove,
            ManifestContent("chrome", "global", "toolkit/content/global/"),
        )

        f.copy(self.tmppath("chrome.manifest"))
        content = open(self.tmppath("chrome.manifest"), "rb").read()
        self.assertEqual(content[:42], f.open().read(42))
        self.assertEqual(content, f.open().read())
示例#3
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/')])
示例#4
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/")],
         )