File: path.py

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (134 lines) | stat: -rw-r--r-- 4,399 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import pytest
from support.addons import (
    get_ids_for_installed_addons,
    is_addon_private_browsing_allowed,
    is_addon_temporary_installed,
)
from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import get_extension_path

from . import ADDON_ID, install_addon, uninstall_addon


def test_install_invalid_addon(session):
    response = install_addon(session, "path", get_extension_path("firefox/invalid.xpi"))
    assert_error(response, "unknown error")


def test_install_nonexistent_addon(session):
    response = install_addon(session, "path", get_extension_path("does-not-exist.xpi"))
    assert_error(response, "unknown error")


@pytest.mark.allow_system_access
@pytest.mark.parametrize("value", [True, False], ids=["required", "not required"])
def test_install_unsigned_addon_with_signature(session, use_pref, value):
    # Even though "xpinstall.signatures.required" preference is enabled in Firefox by default,
    # it's disabled for wpt tests, so test both values here.
    use_pref("xpinstall.signatures.required", value)

    response = install_addon(
        session, "path", get_extension_path("firefox/unsigned.xpi"), False
    )

    if value is True:
        assert_error(response, "unknown error")
    else:
        addon_id = assert_success(response)

        installed_addon_ids = get_ids_for_installed_addons(session)

        try:
            assert addon_id in installed_addon_ids
            assert addon_id == ADDON_ID
            assert is_addon_temporary_installed(session, addon_id) is False
        finally:
            # Clean up the addon.
            uninstall_addon(session, addon_id)


@pytest.mark.allow_system_access
def test_temporary_install_unsigned_addon(session):
    response = install_addon(
        session, "path", get_extension_path("firefox/unsigned.xpi"), True
    )
    addon_id = assert_success(response)

    installed_addon_ids = get_ids_for_installed_addons(session)

    try:
        assert addon_id in installed_addon_ids
        assert addon_id == ADDON_ID
        assert is_addon_temporary_installed(session, addon_id) is True
    finally:
        # Clean up the addon.
        uninstall_addon(session, addon_id)


@pytest.mark.allow_system_access
@pytest.mark.parametrize("temporary", [True, False])
def test_install_signed_addon(session, temporary):
    response = install_addon(
        session, "path", get_extension_path("firefox/signed.xpi"), temporary
    )
    addon_id = assert_success(response)

    installed_addon_ids = get_ids_for_installed_addons(session)

    try:
        assert addon_id in installed_addon_ids
        assert addon_id == ADDON_ID
        assert is_addon_temporary_installed(session, addon_id) is temporary
    finally:
        # Clean up the addon.
        uninstall_addon(session, addon_id)


@pytest.mark.allow_system_access
def test_install_mixed_separator_windows(session):
    os = session.capabilities["platformName"]

    # Only makes sense to test on Windows.
    if os == "windows":
        # Ensure the base path has only \
        addon_path = get_extension_path("firefox").replace("/", "\\")
        addon_path += "/signed.xpi"

        response = install_addon(session, "path", addon_path, False)
        addon_id = assert_success(response)

        installed_addon_ids = get_ids_for_installed_addons(session)

        try:
            assert addon_id in installed_addon_ids
            assert addon_id == ADDON_ID
            assert is_addon_temporary_installed(session, addon_id) is False
        finally:
            # Clean up the addon.
            uninstall_addon(session, addon_id)


@pytest.mark.allow_system_access
@pytest.mark.parametrize("allow_private_browsing", [True, False])
def test_install_addon_with_private_browsing(session, allow_private_browsing):
    response = install_addon(
        session,
        "path",
        get_extension_path("firefox/signed.xpi"),
        False,
        allow_private_browsing,
    )
    addon_id = assert_success(response)

    installed_addon_ids = get_ids_for_installed_addons(session)

    try:
        assert addon_id in installed_addon_ids
        assert addon_id == ADDON_ID
        assert (
            is_addon_private_browsing_allowed(session, addon_id)
            is allow_private_browsing
        )
    finally:
        # Clean up the addon.
        uninstall_addon(session, addon_id)