def test_reverse_lookup():
    """Test that the chrome reverse lookup function works properly."""

    c = ChromeManifest("""
    content ns1 /dir1/
    content ns2 /dir2/foo/
    content nsbad1 /dir3
    content ns3 jar:foo.jar!/subdir1/
    content ns3 jar:zap.jar!/altdir1/
    content ns4 jar:bar.jar!/subdir2
    """, "chrome.manifest")

    eq_(c.reverse_lookup(MockPackStack(), "random.js"), None)
    eq_(c.reverse_lookup(MockPackStack(), "/dir1/x.js"),
        "chrome://ns1/x.js")
    eq_(c.reverse_lookup(MockPackStack(), "/dir2/x.js"), None)
    eq_(c.reverse_lookup(MockPackStack(), "/dir2/foo/x.js"),
        "chrome://ns2/x.js")
    eq_(c.reverse_lookup(MockPackStack(), "/dir3/x.js"),
        "chrome://nsbad1/x.js")
    eq_(c.reverse_lookup(MockPackStack(["foo.jar"]), "/x.js"),
        "chrome://ns3/subdir1/x.js")
    eq_(c.reverse_lookup(MockPackStack(["foo.jar"]), "/zap/x.js"),
        "chrome://ns3/subdir1/zap/x.js")
    eq_(c.reverse_lookup(MockPackStack(["bar.jar"]), "/x.js"),
        "chrome://ns4/subdir2/x.js")
    eq_(c.reverse_lookup(MockPackStack(["zap.jar"]), "/x.js"),
        "chrome://ns3/altdir1/x.js")
def test_reverse_lookup():
    """Test that the chrome reverse lookup function works properly."""

    c = ChromeManifest(
        """
    content ns1 /dir1/
    content ns2 /dir2/foo/
    content nsbad1 /dir3
    content ns3 jar:foo.jar!/subdir1/
    content ns3 jar:zap.jar!/altdir1/
    content ns4 jar:bar.jar!/subdir2
    """, 'chrome.manifest')

    assert c.reverse_lookup(MockPackStack(), 'random.js') is None
    assert c.reverse_lookup(MockPackStack(),
                            '/dir1/x.js') == 'chrome://ns1/x.js'
    assert c.reverse_lookup(MockPackStack(), '/dir2/x.js') is None
    assert c.reverse_lookup(MockPackStack(),
                            '/dir2/foo/x.js') == 'chrome://ns2/x.js'
    assert c.reverse_lookup(MockPackStack(),
                            '/dir3/x.js') == 'chrome://nsbad1/x.js'
    assert c.reverse_lookup(MockPackStack(['foo.jar']),
                            '/x.js') == 'chrome://ns3/subdir1/x.js'
    assert c.reverse_lookup(MockPackStack(['foo.jar']),
                            '/zap/x.js') == 'chrome://ns3/subdir1/zap/x.js'
    assert c.reverse_lookup(MockPackStack(['bar.jar']),
                            '/x.js') == 'chrome://ns4/subdir2/x.js'
    assert c.reverse_lookup(MockPackStack(['zap.jar']),
                            '/x.js') == 'chrome://ns3/altdir1/x.js'
def test_reverse_lookup():
    """Test that the chrome reverse lookup function works properly."""

    c = ChromeManifest("""
    content ns1 /dir1/
    content ns2 /dir2/foo/
    content nsbad1 /dir3
    content ns3 jar:foo.jar!/subdir1/
    content ns3 jar:zap.jar!/altdir1/
    content ns4 jar:bar.jar!/subdir2
    """, 'chrome.manifest')

    assert c.reverse_lookup(MockPackStack(), 'random.js') is None
    assert c.reverse_lookup(MockPackStack(),
                            '/dir1/x.js') == 'chrome://ns1/x.js'
    assert c.reverse_lookup(MockPackStack(), '/dir2/x.js') is None
    assert c.reverse_lookup(MockPackStack(),
                            '/dir2/foo/x.js') == 'chrome://ns2/x.js'
    assert c.reverse_lookup(MockPackStack(),
                            '/dir3/x.js') == 'chrome://nsbad1/x.js'
    assert c.reverse_lookup(MockPackStack(['foo.jar']),
                            '/x.js') == 'chrome://ns3/subdir1/x.js'
    assert c.reverse_lookup(MockPackStack(['foo.jar']),
                            '/zap/x.js') == 'chrome://ns3/subdir1/zap/x.js'
    assert c.reverse_lookup(MockPackStack(['bar.jar']),
                            '/x.js') == 'chrome://ns4/subdir2/x.js'
    assert c.reverse_lookup(MockPackStack(['zap.jar']),
                            '/x.js') == 'chrome://ns3/altdir1/x.js'
Example #4
0
def test_reverse_lookup():
    """Test that the chrome reverse lookup function works properly."""

    c = ChromeManifest(
        """
    content ns1 /dir1/
    content ns2 /dir2/foo/
    content nsbad1 /dir3
    content ns3 jar:foo.jar!/subdir1/
    content ns3 jar:zap.jar!/altdir1/
    content ns4 jar:bar.jar!/subdir2
    """, "chrome.manifest")

    eq_(c.reverse_lookup(MockPackStack(), "random.js"), None)
    eq_(c.reverse_lookup(MockPackStack(), "/dir1/x.js"), "chrome://ns1/x.js")
    eq_(c.reverse_lookup(MockPackStack(), "/dir2/x.js"), None)
    eq_(c.reverse_lookup(MockPackStack(), "/dir2/foo/x.js"),
        "chrome://ns2/x.js")
    eq_(c.reverse_lookup(MockPackStack(), "/dir3/x.js"),
        "chrome://nsbad1/x.js")
    eq_(c.reverse_lookup(MockPackStack(["foo.jar"]), "/x.js"),
        "chrome://ns3/subdir1/x.js")
    eq_(c.reverse_lookup(MockPackStack(["foo.jar"]), "/zap/x.js"),
        "chrome://ns3/subdir1/zap/x.js")
    eq_(c.reverse_lookup(MockPackStack(["bar.jar"]), "/x.js"),
        "chrome://ns4/subdir2/x.js")
    eq_(c.reverse_lookup(MockPackStack(["zap.jar"]), "/x.js"),
        "chrome://ns3/altdir1/x.js")