def tearDown(self): self.logger.info("tearing down!") MarionetteTestCase.tearDown(self) self.logger.info("tearing down webservers!") self._webservers.stop() self.logger.info("processing data in %s!" % self._resultsDir) perf_blob = process_perf_data.create_perf_data(self._resultsDir) self.logger.info("PERFHERDER_DATA: %s" % json.dumps(perf_blob)) perf_file = os.path.join(self._resultsDir, "perfherder_data.json") with open(perf_file, 'w') as fp: json.dump(perf_blob, fp, indent=2) self.logger.info("Perfherder data written to %s" % perf_file) if self._dmd: self.cleanup_dmd() # copy it to moz upload dir if set if 'MOZ_UPLOAD_DIR' in os.environ: for file in os.listdir(self._resultsDir): file = os.path.join(self._resultsDir, file) if os.path.isfile(file): shutil.copy2(file, os.environ["MOZ_UPLOAD_DIR"]) self.logger.info("done tearing down!")
def setUp(self): MarionetteTestCase.setUp(self) self.logger = mozlog.structured.structuredlog.get_default_logger() self.marionette.set_context('chrome') self._resultsDir = self.testvars["resultsDir"] self._binary = self.testvars['bin'] self._run_local = self.testvars.get('run_local', False) # Cleanup our files from previous runs. for patt in ('memory-report-*.json.gz', 'perfherder_data.json', 'dmd-*.json.gz'): for f in glob.glob(os.path.join(self._resultsDir, patt)): os.unlink(f) # Optional testvars. self._pages_to_load = self.testvars.get("entities", 0) self._iterations = self.testvars.get("iterations", ITERATIONS) self._perTabPause = self.testvars.get("perTabPause", PER_TAB_PAUSE) self._settleWaitTime = self.testvars.get("settleWaitTime", SETTLE_WAIT_TIME) self._maxTabs = self.testvars.get("maxTabs", MAX_TABS) self._dmd = self.testvars.get("dmd", False) self.logger.info("areweslimyet run by %d pages, %d iterations," " %d perTabPause, %d settleWaitTime" % (self._pages_to_load, self._iterations, self._perTabPause, self._settleWaitTime)) self.reset_state()
def setUp(self): MarionetteTestCase.setUp(self) self.TEST_URL = "https://www.mediawiki.org/wiki/MediaWiki" self.ATTRIBUTES = { "navigationStart": 0, "unloadEventStart": 0, "unloadEventEnd": 0, "redirectStart": 0, "redirectEnd": 0, "fetchStart": 0, "domainLookupStart": 0, "domainLookupEnd": 0, "connectStart": 0, "connectEnd": 0, "secureConnectionStart": 0, "requestStart": 0, "responseStart": 0, "responseEnd": 0, "domLoading": 0, "domInteractive": 0, "domContentLoadedEventStart": 0, "domContentLoadedEventEnd": 0, "domComplete": 0, "loadEventStart": 0, "loadEventEnd": 0, }
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.URL = 'https://pinning-test.badssl.com/'
def setUp(self): MarionetteTestCase.setUp(self) if self.marionette.session_capabilities["platformName"] == "darwin": self.mod_key = Keys.META else: self.mod_key = Keys.CONTROL self.action = Actions(self.marionette)
def tearDown(self): MarionetteTestCase.tearDown(self) try: self.logger.info("processing data in %s!" % self._resultsDir) perf_blob = process_perf_data.create_perf_data( self._resultsDir, self.perf_suites(), self.perf_checkpoints(), self.perf_extra_opts()) self.logger.info("PERFHERDER_DATA: %s" % json.dumps(perf_blob)) perf_file = os.path.join(self._resultsDir, "perfherder_data.json") with open(perf_file, 'w') as fp: json.dump(perf_blob, fp, indent=2) self.logger.info("Perfherder data written to %s" % perf_file) except Exception: raise finally: # Make sure we cleanup and upload any existing files even if there # were errors processing the perf data. if self._dmd: self.cleanup_dmd() # copy it to moz upload dir if set if 'MOZ_UPLOAD_DIR' in os.environ: for file in os.listdir(self._resultsDir): file = os.path.join(self._resultsDir, file) if os.path.isfile(file): shutil.copy2(file, os.environ["MOZ_UPLOAD_DIR"])
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.URL = "file://%s/testfile.pdf" % ts.t['options']['test_data_dir']
def tearDown(self): self.logger.info("finished loading pages") self.marionette.set_context('chrome') time.sleep(10) ping = self.marionette.execute_script(GET_PING_SCRIPT) self.logger.info("retrieved telemetry ping\n") histograms = {} scalars = {} for name, process in HISTOGRAMS: histogramSet = self.findHistograms(ping, process, name) for name, histogram in histogramSet.items(): self.expandHistogram(histogram) histograms[name] = histogram for name, process in SCALARS: scalars[name] = self.findScalar(ping, process, name) try: os.mkdir('run') except: pass with open('run/ping.json', 'w') as out: json.dump(ping, out, sort_keys=True, indent=2) with open('run/histograms.json', 'w') as out: json.dump(histograms, out, sort_keys=True, indent=2) with open('run/scalars.json', 'w') as out: json.dump(scalars, out, sort_keys=True, indent=2) with open('run/histograms.txt', 'w') as out: for name, histogram in sorted(histograms.items()): rendered = self.renderHistogram(name, histogram) print >> out, rendered MarionetteTestCase.tearDown(self)
def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # Some helpers to deal with removing a load of files import errno, stat def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 func(path) else: raise if self.desktop_backup_path: shutil.rmtree(self.desktop_backup_path, ignore_errors=False, onerror=handleRemoveReadonly) if self.reset_profile_path: # Remove ourselves from profiles.ini self.runCode(""" let name = arguments[0]; let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=(self.profileNameToRemove,)) # And delete all the files. shutil.rmtree(self.reset_profile_path, ignore_errors=False, onerror=handleRemoveReadonly)
def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # Some helpers to deal with removing a load of files import errno, stat def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777 func(path) else: raise if self.desktop_backup_path: shutil.rmtree(self.desktop_backup_path, ignore_errors=False, onerror=handleRemoveReadonly) if self.reset_profile_path: # Remove ourselves from profiles.ini profileLeafName = os.path.basename(os.path.normpath(self.reset_profile_path)) self.runCode(""" let [salt, name] = arguments[0].split("."); let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=[profileLeafName]) # And delete all the files. shutil.rmtree(self.reset_profile_path, ignore_errors=False, onerror=handleRemoveReadonly)
def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # A helper to deal with removing a load of files import mozfile for cleanup in self.cleanups: if cleanup.desktop_backup_path: mozfile.remove(cleanup.desktop_backup_path) if cleanup.reset_profile_path: # Remove ourselves from profiles.ini self.runCode(""" let name = arguments[0]; let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=(cleanup.profile_name_to_remove, )) # Remove the local profile dir if it's not the same as the profile dir: different_path = cleanup.reset_profile_local_path != cleanup.reset_profile_path if cleanup.reset_profile_local_path and different_path: mozfile.remove(cleanup.reset_profile_local_path) # And delete all the files. mozfile.remove(cleanup.reset_profile_path)
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.set_context("chrome") self.win = self.marionette.current_window_handle self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');") self.marionette.switch_to_window('foo') self.assertNotEqual(self.win, self.marionette.current_window_handle)
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.svg_dir = "file://%s/svg/" % ts.t['options']['test_data_dir']
def tearDown(self): # Force yet another restart with a clean profile to disconnect from the # profile and environment changes we've made, to leave a more or less # blank slate for the next person. self.marionette.restart(clean=True, in_app=False) self.setUpScriptData() # Super MarionetteTestCase.tearDown(self) # Some helpers to deal with removing a load of files import errno import stat def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 func(path) else: raise for cleanup in self.cleanups: if cleanup.desktop_backup_path: shutil.rmtree(cleanup.desktop_backup_path, ignore_errors=False, onerror=handleRemoveReadonly) if cleanup.reset_profile_path: # Remove ourselves from profiles.ini self.runCode(""" let name = arguments[0]; let profile = global.profSvc.getProfileByName(name); profile.remove(false) global.profSvc.flush(); """, script_args=(cleanup.profile_name_to_remove, )) # Remove the local profile dir if it's not the same as the profile dir: different_path = cleanup.reset_profile_local_path != cleanup.reset_profile_path if cleanup.reset_profile_local_path and different_path: shutil.rmtree(cleanup.reset_profile_local_path, ignore_errors=False, onerror=handleRemoveReadonly) # TODO (Bug 1626581) - Move this to mozfile.remove. os = self.marionette.session_capabilities["platformName"] # Prepend the "\\?\" prefix on Windows to avoid file name too long issue. if os == "windows" and not cleanup.reset_profile_path.startswith( '\\\\?\\'): profile_path = r"\\?\%s" % cleanup.reset_profile_path else: profile_path = cleanup.reset_profile_path # And delete all the files. shutil.rmtree(profile_path, ignore_errors=False, onerror=handleRemoveReadonly)
def tearDown(self): # Ensure to restart a session if none exist for clean-up if self.marionette.session is None: self.marionette.start_session() self.marionette.clear_pref("startup.homepage_welcome_url") MarionetteTestCase.tearDown(self)
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.enforce_gecko_prefs( {"marionette.test.bool": True, "marionette.test.string": "testing", "marionette.test.int": 3 }) self.marionette.set_context("chrome")
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.HTTP_URL = "http://httpbin.org/" self.HTTPS_URL = "https://httpbin.org/"
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.http_url = "%s/noscript/" % ts.t['options']['test_data_url'] self.https_url = "%s/noscript/" % ts.t['options']['test_data_url_https']
def tearDown(self): # Ensure to restart a session if none exist for clean-up if not self.marionette.session: self.marionette.start_session() self.marionette.clear_pref("browser.startup.page") MarionetteTestCase.tearDown(self)
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.enforce_gecko_prefs({"dom.webcomponents.enabled": True}) self.marionette.navigate(self.marionette.absolute_url("test_shadow_dom.html")) self.host = self.marionette.find_element(By.ID, "host") self.marionette.switch_to_shadow_root(self.host) self.button = self.marionette.find_element(By.ID, "button")
def setUp(self): MarionetteTestCase.setUp(self) self.linter = Linter( ResourceUriFileReader(self.marionette), JSHintEngine(self.marionette, self._read_local_file(self.JSHINT_PATH), self._read_local_file(self.JSHINTRC_PATH)), self._get_extended_error_message)
def setUp(self): MarionetteTestCase.setUp(self) self.root_window = self.marionette.current_window_handle self.marionette.set_context("chrome") self.marionette.execute_script( "window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen')") self.marionette.switch_to_window("foo") self.assertNotEqual(self.root_window, self.marionette.current_window_handle)
def setUp(self): MarionetteTestCase.setUp(self) self.setUpScriptData() self.reset_profile_path = None self.desktop_backup_path = None self.createProfileData()
def setUp(self): MarionetteTestCase.setUp(self) test_url = self.marionette.absolute_url('test.html') self.marionette.navigate(test_url) self.COOKIE_A = {"name": "foo", "value": "bar", "path": "/", "secure": False}
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.enforce_gecko_prefs({ "marionette.test.bool": True, "marionette.test.string": "testing", "marionette.test.int": 3 }) self.marionette.set_context("chrome")
def setUp(self): MarionetteTestCase.setUp(self) self.pid = self.marionette.process_id self.session_id = self.marionette.session_id self.assertNotEqual(self.marionette.get_pref("browser.startup.page"), 3) self.marionette.set_pref("browser.startup.page", 3)
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.URLs = [ 'chrome://torlauncher/content/network-settings-wizard.xul', ]
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.enforce_gecko_prefs( {"dom.webcomponents.enabled": True}) self.marionette.navigate( self.marionette.absolute_url("test_shadow_dom.html")) self.host = self.marionette.find_element(By.ID, "host") self.marionette.switch_to_shadow_root(self.host) self.button = self.marionette.find_element(By.ID, "button")
def setUp(self): MarionetteTestCase.setUp(self) self.logger = mozlog.structured.structuredlog.get_default_logger() with open(PAGE_SET) as page_set: self.pages = json.load(page_set) self.marionette.set_context('chrome') self.marionette.timeout.page_load = 20 self.marionette.execute_script(CLEAR_PING_SCRIPT) self.logger.info("cleared telemetry ping")
def setUp(self): MarionetteTestCase.setUp(self) self.pid = self.marionette.process_id self.session_id = self.marionette.session_id # Use a preference to check that the restart was successful. If its # value has not been forced, a restart will cause a reset of it. self.assertNotEqual( self.marionette.get_pref("startup.homepage_welcome_url"), "about:") self.marionette.set_pref("startup.homepage_welcome_url", "about:")
def setUp(self): MarionetteTestCase.setUp(self) self.pid = self.marionette.process_id self.session_id = self.marionette.session_id # Use a preference to check that the restart was successful. If its # value has not been forced, a restart will cause a reset of it. self.assertNotEqual(self.marionette.get_pref("startup.homepage_welcome_url"), "about:") self.marionette.set_pref("startup.homepage_welcome_url", "about:")
def setUp(self): MarionetteTestCase.setUp(self) # shortcuts to improve readability of these tests self.chrome = self.marionette.CONTEXT_CHROME self.content = self.marionette.CONTEXT_CONTENT test_url = self.marionette.absolute_url("empty.html") self.marionette.navigate(test_url) self.marionette.set_context(self.content) self.assertEquals(self.get_context(), self.content)
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts self.test_page_url = ts.t['test']['fpcentral_url'] if 'timeout' in ts.t['test']: self.timeout = ts.t['test']['timeout'] else: self.timeout = 50000
def setUp(self): MarionetteTestCase.setUp(self) self.logger = mozlog.structured.structuredlog.get_default_logger() self.logger.info("setting up!") self.marionette.set_context('chrome') self._webroot_dir = self.testvars["webRootDir"] self._resultsDir = self.testvars["resultsDir"] # Be conservative in what we delete automatically. for f in glob.glob( os.path.join(self._resultsDir, 'memory-report-*.json.gz')): os.unlink(f) for f in glob.glob( os.path.join(self._resultsDir, 'perfherder_data.json')): os.unlink(f) for f in glob.glob(os.path.join(self._resultsDir, 'dmd-*.json.gz')): os.unlink(f) self._urls = [] urls = None default_tp5n_manifest = os.path.join(self._webroot_dir, 'page_load_test', 'tp5n', 'tp5n.manifest') tp5n_manifest = self.testvars.get("pageManifest", default_tp5n_manifest) with open(tp5n_manifest) as fp: urls = fp.readlines() urls = map(lambda x: x.replace('localhost', 'localhost:{}'), urls) # Optional testvars. self._pages_to_load = self.testvars.get("entities", len(urls)) self._iterations = self.testvars.get("iterations", ITERATIONS) self._perTabPause = self.testvars.get("perTabPause", PER_TAB_PAUSE) self._settleWaitTime = self.testvars.get("settleWaitTime", SETTLE_WAIT_TIME) self._maxTabs = self.testvars.get("maxTabs", MAX_TABS) self._dmd = self.testvars.get("dmd", False) self._webservers = webservers.WebServers("localhost", 8001, self._webroot_dir, self._pages_to_load) self._webservers.start() for url, server in zip(urls, self._webservers.servers): self._urls.append(url.strip().format(server.port)) self.logger.info( "areweslimyet run by %d pages, %d iterations, %d perTabPause, %d settleWaitTime" % (self._pages_to_load, self._iterations, self._perTabPause, self._settleWaitTime)) self.reset_state() self.logger.info("done setting up!")
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.set_context('chrome') self.logger = mozlog.structured.structuredlog.get_default_logger() self.urls = self.testvars["urls"] self.pages_to_load = self.testvars.get("entities", len(self.urls)) self.perTabPause = self.testvars.get("perTabPause", PER_TAB_PAUSE) self.settleWaitTime = self.testvars.get("settleWaitTime", SETTLE_WAIT_TIME) self.maxTabs = self.testvars.get("maxTabs", MAX_TABS) self.stats = self.testvars.get("stats")
def setUp(self): MarionetteTestCase.setUp(self) self.max = self.marionette.execute_script(""" return { width: window.screen.availWidth, height: window.screen.availHeight, }""", sandbox=None) # ensure window is not fullscreen actual = self.marionette.set_window_rect( width=self.max["width"] - 100, height=self.max["height"] - 100) self.assertNotEqual(actual["width"], self.max["width"]) self.assertNotEqual(actual["height"], self.max["height"]) self.original_size = actual
def setUp(self): MarionetteTestCase.setUp(self) ts = testsuite.TestSuite() self.ts = ts if ts.t['test']['remote']: test_data_url = ts.t['options']['test_data_url'] else: test_data_url = "file://%s" % ts.t['options']['test_data_dir'] self.test_page_url = '%s/%s.html' % (test_data_url, ts.t['test']['name']) if ts.t['test']['timeout']: self.timeout = ts.t['test']['timeout'] else: self.timeout = 50000
def setUp(self): MarionetteTestCase.setUp(self) self.logger = mozlog.structured.structuredlog.get_default_logger() self.logger.info("setting up!") self.marionette.set_context('chrome') self._webroot_dir = self.testvars["webRootDir"] self._resultsDir = self.testvars["resultsDir"] # Be conservative in what we delete automatically. for f in glob.glob(os.path.join(self._resultsDir, 'memory-report-*.json.gz')): os.unlink(f) for f in glob.glob(os.path.join(self._resultsDir, 'perfherder_data.json')): os.unlink(f) for f in glob.glob(os.path.join(self._resultsDir, 'dmd-*.json.gz')): os.unlink(f) self._urls = [] urls = None default_tp5n_manifest = os.path.join(self._webroot_dir, 'page_load_test', 'tp5n', 'tp5n.manifest') tp5n_manifest = self.testvars.get("pageManifest", default_tp5n_manifest) with open(tp5n_manifest) as fp: urls = fp.readlines() urls = map(lambda x:x.replace('localhost', 'localhost:{}'), urls) # Optional testvars. self._pages_to_load = self.testvars.get("entities", len(urls)) self._iterations = self.testvars.get("iterations", ITERATIONS) self._perTabPause = self.testvars.get("perTabPause", PER_TAB_PAUSE) self._settleWaitTime = self.testvars.get("settleWaitTime", SETTLE_WAIT_TIME) self._maxTabs = self.testvars.get("maxTabs", MAX_TABS) self._dmd = self.testvars.get("dmd", False) self._webservers = webservers.WebServers("localhost", 8001, self._webroot_dir, self._pages_to_load) self._webservers.start() for url, server in zip(urls, self._webservers.servers): self._urls.append(url.strip().format(server.port)) self.logger.info("areweslimyet run by %d pages, %d iterations, %d perTabPause, %d settleWaitTime" % (self._pages_to_load, self._iterations, self._perTabPause, self._settleWaitTime)) self.reset_state() self.logger.info("done setting up!")
def setUp(self): MarionetteTestCase.setUp(self) self.TEST_URL = "https://www.mediawiki.org/wiki/MediaWiki" self.RESOURCE_URL = "https://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png"
def tearDown(self): try: self.marionette.delete_session() except: pass MarionetteTestCase.tearDown(self)
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.delete_session() self.capabilities = self.marionette.start_session( {"requiredCapabilities": self.insecure_tls})
def setUp(self): MarionetteTestCase.setUp(self) # clears log cache self.marionette.get_logs()
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.timeout.implicit = 0
def setUp(self): MarionetteTestCase.setUp(self) self.original_size = self.marionette.window_size
def tearDown(self): self.assertEqual(self.get_context(), self.marionette.CONTEXT_CHROME) MarionetteTestCase.tearDown(self)
def setUp(self): MarionetteTestCase.setUp(self) self.marionette.set_context(self.marionette.CONTEXT_CHROME)
def tearDown(self): self.marionette.delete_all_cookies() MarionetteTestCase.tearDown(self)
def tearDown(self): self.assertNotEqual(self.win, self.marionette.current_window_handle) self.marionette.execute_script("window.close();") self.marionette.switch_to_window(self.win) MarionetteTestCase.tearDown(self)