Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing test #4

Merged
merged 4 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install:
- choco install firefox
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\Program Files (x86)\Mozilla Firefox;
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\Program Files\Mozilla Firefox;
- rustc -Vv
- cargo -V

Expand Down
2 changes: 1 addition & 1 deletion ff/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn spawn_firefox(firefox_bin: &Path, profile: &Path, marionette: bool) -> IoResu
}

#[cfg(windows)]
fn spawn_firefox(firefox_bin: &Path, profile: &Path) -> IoResult<Child> {
fn spawn_firefox(firefox_bin: &Path, profile: &Path, marionette: bool) -> IoResult<Child> {
let mut cmd = Command::new(firefox_bin);
if marionette {
cmd.arg("-marionette");
Expand Down
7 changes: 4 additions & 3 deletions ff/tests/userprefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ use std::time::Duration;

#[test]
fn user_js_file() {
let browser = ff::Browser::start(65333,
let browser = ff::Browser::start(Some(65333),
None,
None,
Some("tests/data/test-user.js"),
None,
None).unwrap();

ff::check_connection(browser.runner.port()).unwrap();
let port = browser.runner.port().unwrap();
ff::check_connection(port).unwrap();

thread::sleep(Duration::new(5, 0));
let mut conn = MarionetteConnection::connect(browser.runner.port()).unwrap();
let mut conn = MarionetteConnection::connect(port).unwrap();
let res = conn.get_pref("ff.testpref.canary").unwrap();
assert_eq!(res, JsonValue::String("the canary is dead".to_string()));
conn.quit().unwrap();
Expand Down
12 changes: 12 additions & 0 deletions marionette/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ impl MarionetteConnection {

conn.compatibility = compat;
conn.timeouts = resp.capabilities.timeouts;

// Try to make sure the browser is live before returning
for retry in 0..4 {
match conn.get_title() {
Ok(_) => break,
Err(err) => {
debug!("#{} Failed to connect to firefox({}): {}", retry, port, err);
std::thread::sleep(std::time::Duration::new(retry*2, 0));
}
}
}

Ok(conn)
} else {
Err(MarionetteError::UnsupportedProtocolVersion)
Expand Down
Loading