summaryrefslogtreecommitdiffstats
path: root/testing/firefox-ui/tests/functional/security/test_ssl_status_after_restart.py
blob: 3684433f6f53ee7b68e08a30122eea0365232cd4 (plain)
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from marionette_driver import By, Wait
from marionette_harness import MarionetteTestCase, WindowManagerMixin


class TestSSLStatusAfterRestart(WindowManagerMixin, MarionetteTestCase):
    def setUp(self):
        super(TestSSLStatusAfterRestart, self).setUp()
        self.marionette.set_context("chrome")

        self.test_url = "https://www.itisatrap.org/"

        # Set browser to restore previous session
        self.marionette.set_pref("browser.startup.page", 3)
        # Disable rcwn to make cache behavior deterministic
        self.marionette.set_pref("network.http.rcwn.enable", False)

    def tearDown(self):
        self.marionette.clear_pref("browser.startup.page")
        self.marionette.clear_pref("network.http.rcwn.enable")

        super(TestSSLStatusAfterRestart, self).tearDown()

    def test_ssl_status_after_restart(self):
        with self.marionette.using_context("content"):
            self.marionette.navigate(self.test_url)
        self.verify_certificate_status(self.test_url)

        self.marionette.restart(in_app=True)

        self.verify_certificate_status(self.test_url)

    def verify_certificate_status(self, url):
        with self.marionette.using_context("content"):
            Wait(self.marionette).until(
                lambda _: self.marionette.get_url() == url,
                message="Expected URL loaded",
            )

        identity_box = self.marionette.find_element(By.ID, "identity-box")
        self.assertEqual(identity_box.get_attribute("pageproxystate"), "valid")

        class_list = self.marionette.execute_script(
            """
          const names = [];
          for (const name of arguments[0].classList) {
            names.push(name);
          }
          return names;
        """,
            script_args=[identity_box],
        )
        self.assertIn("verifiedDomain", class_list)