test_service_workers_disabled.py (1164B)
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 import os 6 import sys 7 8 # Add this directory to the import path. 9 sys.path.append(os.path.dirname(__file__)) 10 11 from service_worker_utils import MarionetteServiceWorkerTestCase 12 13 14 class ServiceWorkersDisabledTestCase(MarionetteServiceWorkerTestCase): 15 def setUp(self): 16 super().setUp() 17 self.install_service_worker("serviceworker/install_serviceworker.html") 18 19 def tearDown(self): 20 self.marionette.restart(in_app=False, clean=True) 21 super().tearDown() 22 23 def test_service_workers_disabled_at_startup(self): 24 # self.marionette.set_pref sets preferences after startup. Using it 25 # here causes intermittent failures. 26 self.marionette.instance.profile.set_preferences({ 27 "dom.serviceWorkers.enabled": False, 28 }) 29 30 self.marionette.restart() 31 32 self.assertFalse( 33 self.is_service_worker_registered, 34 "Service worker registration should have been purged", 35 )