test_ssl_status_after_restart.py (2005B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 from marionette_driver import By, Wait 6 from marionette_harness import MarionetteTestCase, WindowManagerMixin 7 8 9 class TestSSLStatusAfterRestart(WindowManagerMixin, MarionetteTestCase): 10 def setUp(self): 11 super().setUp() 12 self.marionette.set_context("chrome") 13 14 self.test_url = "https://www.itisatrap.org/" 15 16 # Set browser to restore previous session 17 self.marionette.set_pref("browser.startup.page", 3) 18 # Disable rcwn to make cache behavior deterministic 19 self.marionette.set_pref("network.http.rcwn.enable", False) 20 21 def tearDown(self): 22 self.marionette.clear_pref("browser.startup.page") 23 self.marionette.clear_pref("network.http.rcwn.enable") 24 25 super().tearDown() 26 27 def test_ssl_status_after_restart(self): 28 with self.marionette.using_context("content"): 29 self.marionette.navigate(self.test_url) 30 self.verify_certificate_status(self.test_url) 31 32 self.marionette.restart(in_app=True) 33 34 self.verify_certificate_status(self.test_url) 35 36 def verify_certificate_status(self, url): 37 with self.marionette.using_context("content"): 38 Wait(self.marionette).until( 39 lambda _: self.marionette.get_url() == url, 40 message="Expected URL loaded", 41 ) 42 43 identity_box = self.marionette.find_element(By.ID, "identity-box") 44 self.assertEqual(identity_box.get_attribute("pageproxystate"), "valid") 45 46 class_list = self.marionette.execute_script( 47 """ 48 const names = []; 49 for (const name of arguments[0].classList) { 50 names.push(name); 51 } 52 return names; 53 """, 54 script_args=[identity_box], 55 ) 56 self.assertIn("verifiedDomain", class_list)