зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1214981 - Disable output stream buffering. r=keeler
This commit is contained in:
Родитель
1897037288
Коммит
5feda64143
|
@ -103,8 +103,6 @@ function storeCertOverride(port, cert) {
|
|||
}
|
||||
|
||||
function startClient(port, expectedResult, options = {}) {
|
||||
let SSL_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SSL_ERROR_BASE;
|
||||
let SSL_ERROR_BAD_CERT_ALERT = SSL_ERROR_BASE + 17;
|
||||
let transport =
|
||||
socketTransportService.createTransport(["ssl"], 1, "127.0.0.1", port, null);
|
||||
if (options.isPrivate) {
|
||||
|
@ -113,8 +111,7 @@ function startClient(port, expectedResult, options = {}) {
|
|||
let input;
|
||||
let output;
|
||||
|
||||
let inputDeferred = Promise.defer();
|
||||
let outputDeferred = Promise.defer();
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let handler = {
|
||||
|
||||
|
@ -125,46 +122,48 @@ function startClient(port, expectedResult, options = {}) {
|
|||
},
|
||||
|
||||
onInputStreamReady: function(input) {
|
||||
let errorCode = Cr.NS_OK;
|
||||
try {
|
||||
let data = NetUtil.readInputStreamToString(input, input.available());
|
||||
equal(data, "HELLO", "Echoed data received");
|
||||
input.close();
|
||||
output.close();
|
||||
deferred.resolve();
|
||||
} catch (e) {
|
||||
errorCode = e.result;
|
||||
}
|
||||
try {
|
||||
equal(errorCode, expectedResult,
|
||||
"Actual and expected connection result should match");
|
||||
inputDeferred.resolve();
|
||||
} catch (e) {
|
||||
inputDeferred.reject(e);
|
||||
deferred.reject(e);
|
||||
}
|
||||
},
|
||||
|
||||
onOutputStreamReady: function(output) {
|
||||
try {
|
||||
output.write("HELLO", 5);
|
||||
try {
|
||||
output.write("HELLO", 5);
|
||||
} catch (e) {
|
||||
if (e.result == Cr.NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
output.asyncWait(handler, 0, 0, Services.tm.currentThread);
|
||||
return;
|
||||
}
|
||||
equal(e.result, expectedResult,
|
||||
"Actual and expected connection result should match");
|
||||
output.close();
|
||||
deferred.resolve();
|
||||
return;
|
||||
}
|
||||
equal(Cr.NS_OK, expectedResult, "Connection should succeed");
|
||||
do_print("Output to server written");
|
||||
outputDeferred.resolve();
|
||||
input = transport.openInputStream(0, 0, 0);
|
||||
input.asyncWait(handler, 0, 0, Services.tm.currentThread);
|
||||
} catch (e) {
|
||||
let errorCode = -1 * (e.result & 0xFFFF);
|
||||
if (errorCode == SSL_ERROR_BAD_CERT_ALERT) {
|
||||
do_print("Server doesn't like client cert");
|
||||
}
|
||||
outputDeferred.reject(e);
|
||||
deferred.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
transport.setEventSink(handler, Services.tm.currentThread);
|
||||
output = transport.openOutputStream(0, 0, 0);
|
||||
output = transport.openOutputStream(Ci.nsITransport.OPEN_UNBUFFERED, 0, 0);
|
||||
output.QueryInterface(Ci.nsIAsyncOutputStream);
|
||||
|
||||
return Promise.all([inputDeferred.promise, outputDeferred.promise]);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
|
|
@ -152,4 +152,3 @@ skip-if = toolkit == 'android' || buildapp == 'b2g'
|
|||
|
||||
[test_weak_crypto.js]
|
||||
firefox-appdir = browser
|
||||
skip-if = toolkit == 'android'
|
||||
|
|
Загрузка…
Ссылка в новой задаче