# 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/.
import asyncio import json import os import re import subprocess import sys from datetime import datetime
import pytest import webdriver
from client import Client
try: import pathlib except ImportError: import pathlib2 as pathlib
if"use_interventions"in test_config:
value = test_config["use_interventions"]
prefs[INJECTIONS_PREF] = value
prefs[UA_OVERRIDES_PREF] = value
prefs[PIP_OVERRIDES_PREF] = value
# keep system addon updates off to prevent bug 1882562
prefs[SYSTEM_ADDON_UPDATES_PREF] = False
# remote/cdp/CDP.sys.mjs sets cookieBehavior to 0, # which we definitely do not want, so set it back to 5.
cookieBehavior = 4 if test_config.get("without_tcp") else 5
prefs[CB_PREF] = cookieBehavior
prefs[CB_PBM_PREF] = cookieBehavior
# prevent "allow notifications for?" popups by setting the # default permission for notificaitons to PERM_DENY_ACTION.
prefs[NOTIFICATIONS_PERMISSIONS_PREF] = 2
fx_options = {"prefs": prefs}
if self.browser_binary:
fx_options["binary"] = self.browser_binary if self.headless:
fx_options["args"] = ["--headless"]
if self.device_serial:
fx_options["androidDeviceSerial"] = self.device_serial
fx_options["androidPackage"] = self.package_name
if self.addon:
prefs["xpinstall.signatures.required"] = False
prefs["extensions.experiments.enabled"] = True
def install_addon(session, addon_file_path):
context = session.send_session_command("GET", "moz/context")
session.send_session_command("POST", "moz/context", {"context": "chrome"})
session.execute_async_script( """
async function installAsBuiltinExtension(xpi) {
// The built-in location requires a resource: URL that maps to a
// jar: or file: URL. This would typically be something bundled
// into omni.ja but we use a temp file.
let base = Services.io.newURI(`jar:file:${xpi.path}!/`);
let resProto = Services.io
.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
resProto.setSubstitution("ext-test", base); return AddonManager.installBuiltinAddon("resource://ext-test/");
}
@pytest.fixture(autouse=True) def check_visible_scrollbars(session):
plat = session.capabilities["platformName"] if plat == "android": return"Android does not have visible scrollbars" elif plat == "mac":
cmd = ["defaults", "read", "-g", "AppleShowScrollBars"]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait() if"Always"in str(p.stdout.readline()): returnNone return"scrollbars are not set to always be visible in MacOS system preferences" returnNone
@pytest.fixture(autouse=True) def need_visible_scrollbars(bug_number, check_visible_scrollbars, request, session): if request.node.get_closest_marker("need_visible_scrollbars"): if (
request.node.get_closest_marker("need_visible_scrollbars") and check_visible_scrollbars
):
pytest.skip(f"Bug #{bug_number} skipped: {check_visible_scrollbars}")
@pytest.fixture(autouse=True) def only_platforms(bug_number, platform, request, session): if request.node.get_closest_marker("only_platforms"):
plats = request.node.get_closest_marker("only_platforms").args for only in plats: if only == platform: return
pytest.skip(
f"Bug #{bug_number} skipped on platform ({platform}, test only for {' or '.join(plats)})"
)
@pytest.fixture(autouse=True) def skip_platforms(bug_number, platform, request, session): if request.node.get_closest_marker("skip_platforms"):
plats = request.node.get_closest_marker("skip_platforms").args for skipped in plats: if skipped == platform:
pytest.skip(
f"Bug #{bug_number} skipped on platform ({platform}, test skipped for {' and '.join(plats)})"
)
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.