Bug 785319 - Don't throw when setting WebSocket.binaryType to an invalid value; f=Ms2ger r=smaug

--HG--
extra : rebase_source : 2153ba6ecd98583e09c83208949e5f78042c0e37
This commit is contained in:
Abhishek Potnis 2012-08-25 16:57:59 +05:30
parent f3d96e2210
commit 0df3829f77
2 changed files with 11 additions and 29 deletions

View File

@ -1206,8 +1206,6 @@ nsWebSocket::SetBinaryType(const nsAString& aBinaryType)
mBinaryType = WS_BINARY_TYPE_ARRAYBUFFER;
} else if (aBinaryType.EqualsLiteral("blob")) {
mBinaryType = WS_BINARY_TYPE_BLOB;
} else {
return NS_ERROR_INVALID_ARG;
}
return NS_OK;

View File

@ -1245,9 +1245,9 @@ function test42()
// test some utf-8 non-characters. They should be allowed in the
// websockets context. Test via round trip echo.
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-42");
var data = ["U+FFFE ",
"U+FFFF ￿",
"U+10FFFF 􏿿"];
var data = ["U+FFFE \ufffe",
"U+FFFF \uffff",
"U+10FFFF \udbff\udfff"];
var index = 0;
ws.onopen = function()
@ -1282,30 +1282,14 @@ function test43()
// Test binaryType setting
ws.binaryType = "arraybuffer";
ws.binaryType = "blob";
try {
ws.binaryType = ""; // illegal
ok(false, "allowed ws.binaryType to be set to empty string");
} catch(e) {
ok(true, "prevented ws.binaryType to be set to empty string: " + e);
}
try {
ws.binaryType = "ArrayBuffer"; // illegal
ok(false, "allowed ws.binaryType to be set to 'ArrayBuffer'");
} catch(e) {
ok(true, "prevented ws.binaryType to be set to 'ArrayBuffer' " + e);
}
try {
ws.binaryType = "Blob"; // illegal
ok(false, "allowed ws.binaryType to be set to 'Blob'");
} catch(e) {
ok(true, "prevented ws.binaryType to be set to 'Blob' " + e);
}
try {
ws.binaryType = "mcfoofluu"; // illegal
ok(false, "allowed ws.binaryType to be set to 'mcfoofluu'");
} catch(e) {
ok(true, "prevented ws.binaryType to be set to 'mcfoofluu'");
}
ws.binaryType = ""; // illegal
is(ws.binaryType, "blob");
ws.binaryType = "ArrayBuffer"; // illegal
is(ws.binaryType, "blob");
ws.binaryType = "Blob"; // illegal
is(ws.binaryType, "blob");
ws.binaryType = "mcfoofluu"; // illegal
is(ws.binaryType, "blob");
ws.close();
};