Backed out changeset f4152054eb1b (bug 1410366) for Marionette mass failures, at least on Android 4.3 API16+ debug. r=backout on a CLOSED TREE

--HG--
extra : amend_source : 85858d56ec95c0802a1346f8a5bcf2a66bfca118
This commit is contained in:
Sebastian Hengst 2017-10-23 20:34:12 +02:00
parent 85b2276598
commit 354425a911
2 changed files with 24 additions and 43 deletions

View File

@ -5,7 +5,6 @@
import time
from marionette_driver import errors
from marionette_driver.marionette import Marionette
from marionette_harness import MarionetteTestCase, run_if_manage_instance, skip_if_mobile
@ -31,26 +30,6 @@ class TestMarionette(MarionetteTestCase):
self.assertFalse(self.marionette.wait_for_port(timeout=5))
self.assertLess(time.time() - start_time, 5)
def test_disable_enable_new_connections(self):
# Do not re-create socket if it already exists
self.marionette._send_message("acceptConnections", {"value": True})
try:
# Disabling new connections does not affect existing ones...
self.marionette._send_message("acceptConnections", {"value": False})
self.assertEqual(1, self.marionette.execute_script("return 1"))
# but only new connection attempts
marionette = Marionette(host=self.marionette.host, port=self.marionette.port)
self.assertFalse(marionette.wait_for_port(timeout=1.0),
"Unexpected connection with acceptConnections=false")
self.marionette._send_message("acceptConnections", {"value": True})
marionette.wait_for_port(timeout=1.0)
finally:
self.marionette._send_message("acceptConnections", {"value": True})
class TestContext(MarionetteTestCase):

View File

@ -309,6 +309,7 @@ server.TCPListener = class {
this.conns = new Set();
this.nextConnID = 0;
this.alive = false;
this._acceptConnections = false;
this.alteredPrefs = new Set();
}
@ -326,22 +327,13 @@ server.TCPListener = class {
}
set acceptConnections(value) {
if (value) {
if (!this.socket) {
const flags = KeepWhenOffline | LoopbackOnly;
const backlog = 1;
this.socket = new ServerSocket(this.port, flags, backlog);
this.port = this.socket.port;
this.socket.asyncListen(this);
logger.debug("New connections are accepted");
}
} else if (this.socket) {
this.socket.close();
this.socket = null;
logger.debug("New connections will no longer be accepted");
if (!value) {
logger.info("New connections will no longer be accepted");
} else {
logger.info("New connections are accepted again");
}
this._acceptConnections = value;
}
/**
@ -369,13 +361,16 @@ server.TCPListener = class {
}
}
// Start socket server and listening for connection attempts
this.acceptConnections = true;
const flags = KeepWhenOffline | LoopbackOnly;
const backlog = 1;
this.socket = new ServerSocket(this.port, flags, backlog);
this.socket.asyncListen(this);
this.port = this.socket.port;
Preferences.set(PREF_PORT, this.port);
env.set(ENV_ENABLED, "1");
this.alive = true;
this._acceptConnections = true;
env.set(ENV_ENABLED, "1");
}
stop() {
@ -383,6 +378,11 @@ server.TCPListener = class {
return;
}
this._acceptConnections = false;
this.socket.close();
this.socket = null;
for (let k of this.alteredPrefs) {
logger.debug(`Resetting recommended pref ${k}`);
Preferences.reset(k);
@ -391,13 +391,15 @@ server.TCPListener = class {
Services.obs.notifyObservers(this, NOTIFY_RUNNING);
// Shutdown server socket, and no longer listen for new connections
this.acceptConnections = false;
this.alive = false;
}
onSocketAccepted(serverSocket, clientSocket) {
if (!this._acceptConnections) {
logger.warn("New connections are currently not accepted");
return;
}
let input = clientSocket.openInputStream(0, 0, 0);
let output = clientSocket.openOutputStream(0, 0, 0);
let transport = new DebuggerTransport(input, output);