зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1755312
) for causing wd failures on marionette_port.py. CLOSED TREE
Backed out changeset 6c795bd3f3d4 (bug1755312
) Backed out changeset 4bb6093b4db3 (bug1755312
)
This commit is contained in:
Родитель
a392bace4a
Коммит
a3123f6bf6
|
@ -121,7 +121,11 @@ pub struct WebElement {
|
|||
pub struct Timeouts {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub implicit: Option<u64>,
|
||||
#[serde(default, rename = "pageLoad", skip_serializing_if = "Option::is_none")]
|
||||
#[serde(
|
||||
default,
|
||||
rename = "pageLoad",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub page_load: Option<u64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[allow(clippy::option_option)]
|
||||
|
|
|
@ -42,20 +42,6 @@ impl Browser {
|
|||
Browser::Existing(x) => Ok(Some(*x)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn update_marionette_port(&mut self, port: u16) {
|
||||
match self {
|
||||
Browser::Local(x) => x.update_marionette_port(port),
|
||||
Browser::Remote(x) => x.update_marionette_port(port),
|
||||
Browser::Existing(x) => {
|
||||
if port != *x {
|
||||
error!(
|
||||
"Cannot re-assign Marionette port when connected to an existing browser"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -175,11 +161,13 @@ impl LocalBrowser {
|
|||
if self.marionette_port != 0 {
|
||||
return Ok(Some(self.marionette_port));
|
||||
}
|
||||
|
||||
if let Some(profile_path) = self.profile_path.as_ref() {
|
||||
return Ok(read_marionette_port(profile_path));
|
||||
let port = read_marionette_port(profile_path);
|
||||
if let Some(port) = port {
|
||||
self.marionette_port = port;
|
||||
}
|
||||
return Ok(port);
|
||||
}
|
||||
|
||||
// This should be impossible, but it isn't enforced
|
||||
Err(WebDriverError::new(
|
||||
ErrorStatus::SessionNotCreated,
|
||||
|
@ -187,10 +175,6 @@ impl LocalBrowser {
|
|||
))
|
||||
}
|
||||
|
||||
fn update_marionette_port(&mut self, port: u16) {
|
||||
self.marionette_port = port;
|
||||
}
|
||||
|
||||
pub(crate) fn check_status(&mut self) -> Option<String> {
|
||||
match self.process.try_wait() {
|
||||
Ok(Some(status)) => Some(
|
||||
|
@ -292,10 +276,6 @@ impl RemoteBrowser {
|
|||
fn marionette_port(&mut self) -> WebDriverResult<Option<u16>> {
|
||||
Ok(Some(self.marionette_port))
|
||||
}
|
||||
|
||||
fn update_marionette_port(&mut self, port: u16) {
|
||||
self.marionette_port = port;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_prefs(
|
||||
|
@ -554,7 +534,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_local_read_marionette_port() {
|
||||
fn test_local_marionette_port() {
|
||||
fn create_port_file(profile_path: &Path, data: &[u8]) {
|
||||
let port_path = profile_path.join("MarionetteActivePort");
|
||||
let mut file = File::create(&port_path).unwrap();
|
||||
|
|
|
@ -105,7 +105,7 @@ impl fmt::Display for FatalError {
|
|||
let s = match *self {
|
||||
Parsing(ref err) => err.to_string(),
|
||||
Usage(ref s) => format!("error: {}", s),
|
||||
Server(ref err) => format!("error: {}", err),
|
||||
Server(ref err) => format!("error: {}", err.to_string()),
|
||||
};
|
||||
write!(f, "{}", s)
|
||||
}
|
||||
|
|
|
@ -1177,7 +1177,6 @@ impl MarionetteConnection {
|
|||
match MarionetteConnection::try_connect(host, port) {
|
||||
Ok(stream) => {
|
||||
debug!("Connection to Marionette established on {}:{}.", host, port);
|
||||
browser.update_marionette_port(port);
|
||||
return Ok(stream);
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
@ -543,7 +543,7 @@ impl Device {
|
|||
}
|
||||
|
||||
if SYNC_REGEX.is_match(shell_command) {
|
||||
let arg: &str = &shell_command.replace('\'', "'\"'\"'")[..];
|
||||
let arg: &str = &shell_command.replace("'", "'\"'\"'")[..];
|
||||
return self.execute_host_command(&format!("shell:su -c '{}'", arg), true, false);
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ impl Device {
|
|||
}
|
||||
|
||||
if SYNC_REGEX.is_match(shell_command) {
|
||||
let arg: &str = &shell_command.replace('\'', "'\"'\"'")[..];
|
||||
let arg: &str = &shell_command.replace("'", "'\"'\"'")[..];
|
||||
return self.execute_host_command(
|
||||
&format!("shell:run-as {} {}", run_as_package, arg),
|
||||
true,
|
||||
|
|
|
@ -842,7 +842,7 @@ where
|
|||
fn escape_quote(data: &str) -> Cow<str> {
|
||||
// Not very efficient…
|
||||
if data.contains('"') || data.contains('\\') {
|
||||
Cow::Owned(data.replace('\\', r#"\\"#).replace('"', r#"\""#))
|
||||
Cow::Owned(data.replace(r#"\"#, r#"\\"#).replace(r#"""#, r#"\""#))
|
||||
} else {
|
||||
Cow::Borrowed(data)
|
||||
}
|
||||
|
|
|
@ -352,10 +352,12 @@ pub mod platform {
|
|||
info_plist.push("Info.plist");
|
||||
if let Ok(plist) = Value::from_file(&info_plist) {
|
||||
if let Some(dict) = plist.as_dictionary() {
|
||||
if let Some(Value::String(s)) = dict.get("CFBundleExecutable") {
|
||||
path.push("Contents");
|
||||
path.push("MacOS");
|
||||
path.push(s);
|
||||
if let Some(binary_file) = dict.get("CFBundleExecutable") {
|
||||
if let Value::String(s) = binary_file {
|
||||
path.push("Contents");
|
||||
path.push("MacOS");
|
||||
path.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +393,7 @@ pub mod platform {
|
|||
.iter()
|
||||
{
|
||||
let path = match (home.as_ref(), prefix_home) {
|
||||
(Some(home_dir), true) => home_dir.join(trial_path),
|
||||
(Some(ref home_dir), true) => home_dir.join(trial_path),
|
||||
(None, true) => continue,
|
||||
(_, false) => PathBuf::from(trial_path),
|
||||
};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
from http.client import HTTPConnection
|
||||
|
||||
import webdriver
|
||||
from http.client import HTTPConnection
|
||||
|
||||
|
||||
def request(server_host, server_port, path="/status", host=None, origin=None):
|
||||
|
@ -58,21 +57,14 @@ def get_host(port_type, hostname, server_port):
|
|||
class Geckodriver:
|
||||
def __init__(self, configuration, hostname, extra_args):
|
||||
self.config = configuration["webdriver"]
|
||||
self.requested_capabilities = configuration["capabilities"]
|
||||
self.hostname = hostname
|
||||
self.extra_args = extra_args
|
||||
|
||||
self.capabilities = None
|
||||
self.command = None
|
||||
self.port = get_free_port()
|
||||
self.proc = None
|
||||
|
||||
capabilities = {"alwaysMatch": self.requested_capabilities}
|
||||
self.session = webdriver.Session(
|
||||
self.hostname, self.port, capabilities=capabilities
|
||||
)
|
||||
self.port = None
|
||||
|
||||
def __enter__(self):
|
||||
self.port = get_free_port()
|
||||
self.command = (
|
||||
[self.config["binary"], "--port", str(self.port)]
|
||||
+ self.config["args"]
|
||||
|
@ -98,13 +90,5 @@ class Geckodriver:
|
|||
return self
|
||||
|
||||
def __exit__(self, *args, **kwargs):
|
||||
self.delete_session()
|
||||
|
||||
self.proc.terminate()
|
||||
print(self.proc.stdout.read())
|
||||
|
||||
def new_session(self):
|
||||
self.session.start()
|
||||
|
||||
def delete_session(self):
|
||||
self.session.end()
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
from copy import deepcopy
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from mozprofile import Profile
|
||||
|
||||
from . import Geckodriver
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def custom_profile(configuration):
|
||||
# Clone the known profile for automation preferences
|
||||
firefox_options = configuration["capabilities"]["moz:firefoxOptions"]
|
||||
_, profile_folder = firefox_options["args"]
|
||||
profile = Profile.clone(profile_folder)
|
||||
|
||||
yield profile
|
||||
|
||||
profile.cleanup()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("port", ["0", "2828"], ids=["system allocated", "fixed"])
|
||||
def test_marionette_port(configuration, custom_profile, port):
|
||||
config = deepcopy(configuration)
|
||||
|
||||
# Prepare a Marionette active port file that contains a port which will
|
||||
# never be used when requesting a system allocated port.
|
||||
active_port_file = os.path.join(custom_profile.profile, "MarionetteActivePort")
|
||||
with open(active_port_file, "wb") as f:
|
||||
f.write(b"53")
|
||||
|
||||
config["capabilities"]["moz:firefoxOptions"]["args"] = [
|
||||
"--profile",
|
||||
custom_profile.profile,
|
||||
]
|
||||
|
||||
extra_args = ["--marionette-port", port]
|
||||
with Geckodriver(config, "localhost", extra_args=extra_args) as geckodriver:
|
||||
geckodriver.new_session()
|
|
@ -212,7 +212,7 @@ impl<'de> Deserialize<'de> for PointerOrigin {
|
|||
} else {
|
||||
Err(de::Error::custom(format!(
|
||||
"unknown value `{}`, expected `pointer`, `viewport`, or `element-6066-11e4-a52e-4f735466cecf`",
|
||||
value
|
||||
value.to_string()
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ fn build_route<U: 'static + WebDriverExtensionRoute + Send + Sync>(
|
|||
host,
|
||||
allow_hosts
|
||||
.iter()
|
||||
.map(|x| format!("{}:{}", x, server_address.port()))
|
||||
.map(|x| format!("{}:{}", x.to_string(), server_address.port()))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче