This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from hfiguiere/bug1033402
Bug 1033402 - waitForSocket() before connecting to marionette. r=jlal
- Loading branch information
Showing
3 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var net = require('net'); | ||
var debug = require('debug')('marionette:tcp-sync-test-server'); | ||
|
||
const response = '53:{"from":"root","applicationType":"gecko","traits":[]}'; | ||
|
||
var server = net.createServer(function(connection) { //'connection' listener | ||
debug('server connected'); | ||
connection.on('end', function() { | ||
debug('server disconnected'); | ||
}); | ||
connection.on('error', function(e) { | ||
debug('error', e); | ||
}); | ||
connection.write(response); | ||
connection.pipe(connection); | ||
}); | ||
|
||
|
||
function runServer(port) { | ||
server.listen(port, function() { //'listening' listener | ||
debug('server bound'); | ||
}); | ||
} | ||
|
||
|
||
if (require.main === module) { | ||
try { | ||
runServer(1234); | ||
} | ||
catch(e) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
suite('marionette/drivers/tcp-sync', function() { | ||
|
||
var child = null; | ||
|
||
teardown(function() { | ||
if (child) { | ||
child.kill(); | ||
child = null; | ||
} | ||
}); | ||
|
||
test('can wait for marionette socket', function(done) { | ||
|
||
this.timeout(5000); | ||
|
||
var TcpSync = require('../../../lib/marionette/drivers/tcp-sync.js'); | ||
tcpSync = new TcpSync({port: 1234, host: 'localhost'}); | ||
|
||
tcpSync.waitForSocket( {timeout: 3000} , function() { | ||
done(); | ||
}); | ||
|
||
setTimeout(function () { | ||
child = require('child_process') | ||
.fork('./test/marionette/drivers/tcp-sync-test-server.js'); | ||
}, 1000); | ||
|
||
}); | ||
|
||
}); | ||
|