def test_valid_chrome_manifest(): 'Chrome manifests must only contain certain elements' err = ErrorBundle() err.save_resource('chrome.manifest', chrome_manifest('locale foo bar')) langpack.test_langpack_manifest(err, MockXPI()) assert not err.failed() err.save_resource('chrome.manifest', chrome_manifest('foo bar asdf')) langpack.test_langpack_manifest(err, MockXPI()) assert err.failed()
def test_xpcnativewrappers(): 'Tests that xpcnativewrappers is not in the chrome.manifest' err = ErrorBundle() assert content.test_xpcnativewrappers(err, None) is None err.save_resource('chrome.manifest', chrome_manifest('foo bar')) content.test_xpcnativewrappers(err, None) assert not err.failed() err.save_resource('chrome.manifest', chrome_manifest('xpcnativewrappers on')) content.test_xpcnativewrappers(err, None) assert err.failed()
def test_marking_overlays_subdir(): """ Mark an overlay in a subdirectory, then test that it marks the scripts within the overlay. Make sure it properly figures out relative URLs. """ err = ErrorBundle() err.supported_versions = {} c = chrome_manifest(""" content ns1 foo/ overlay chrome://foo chrome://ns1/content/subdir/main.xul """) err.save_resource('chrome.manifest', c) err.save_resource('chrome.manifest_nopush', c) xpi = MockXPI( {'foo/subdir/main.xul': 'tests/resources/content/script_list.xul'}) content.test_packed_packages(err, xpi) assert not err.failed() marked_scripts = err.get_resource('marked_scripts') print marked_scripts assert marked_scripts eq_( marked_scripts, set([ 'chrome://ns1/subdir/foo.js', 'chrome://ns1/bar.js', 'chrome://asdf/foo.js' ]))
def test_marking_overlays_root_package(): """ Tests that '/' resolves correctly as a chrome content package. """ err = ErrorBundle() err.supported_versions = {} manifest = chrome_manifest(""" content ns1 / overlay chrome://foo chrome://ns1/content/main.xul """) err.save_resource('chrome.manifest', manifest) err.save_resource('chrome.manifest_nopush', manifest) xpi = MockXPI({'main.xul': 'tests/resources/content/script_list.xul'}) content.test_packed_packages(err, xpi) assert not err.failed() marked_scripts = err.get_resource('marked_scripts') eq_( marked_scripts, set([ 'chrome://ns1/foo.js', 'chrome://ns1/bar.js', 'chrome://asdf/foo.js' ]))
def test_marking_overlays_no_overlay(): """ Test that unmarked overlays don't mark scripts as being potentially pollutable. """ err = ErrorBundle() err.supported_versions = {} c = chrome_manifest(""" content ns1 foo/ #overlay chrome://foo chrome://ns1/main.xul """) err.save_resource('chrome.manifest', c) err.save_resource('chrome.manifest_nopush', c) xpi = MockXPI({'foo/main.xul': 'tests/resources/content/script_list.xul'}) content.test_packed_packages(err, xpi) assert not err.failed() marked_scripts = err.get_resource('marked_scripts') print marked_scripts assert not marked_scripts