Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp b/third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp
index 9c18c91d463d966261add7bc360eb946c3c6d13d..ca54e94f53c849d2b75d9429a1e02d51d3b1f78b 100644
--- a/third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp
+++ b/third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp
@@ -599,7 +599,7 @@ TEST_F(DOMWebSocketTest, sendNonLatin1String)
TEST_F(DOMWebSocketTest, sendArrayBufferWhenConnecting)
{
- RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8);
+ RefPtr<DOMArrayBufferView> view = DOMUint8Array::deprecatedCreateOrCrash(8);
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
@@ -608,7 +608,8 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenConnecting)
EXPECT_FALSE(m_exceptionState.hadException());
- m_websocket->send(view->buffer().get(), m_exceptionState);
+ RefPtr<DOMArrayBuffer> buffer = view->buffer();
+ m_websocket->send(buffer.get(), m_exceptionState);
EXPECT_TRUE(m_exceptionState.hadException());
EXPECT_EQ(InvalidStateError, m_exceptionState.code());
@@ -618,7 +619,7 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenConnecting)
TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosing)
{
- RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8);
+ RefPtr<DOMArrayBufferView> view = DOMUint8Array::deprecatedCreateOrCrash(8);
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
@@ -631,7 +632,8 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosing)
m_websocket->close(m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
- m_websocket->send(view->buffer().get(), m_exceptionState);
+ RefPtr<DOMArrayBuffer> buffer = view->buffer();
+ m_websocket->send(buffer.get(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(DOMWebSocket::CLOSING, m_websocket->readyState());
@@ -640,7 +642,7 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosing)
TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosed)
{
Checkpoint checkpoint;
- RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8);
+ RefPtr<DOMArrayBufferView> view = DOMUint8Array::deprecatedCreateOrCrash(8);
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
@@ -654,7 +656,8 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosed)
m_websocket->didClose(WebSocketChannelClient::ClosingHandshakeIncomplete, 1006, "");
checkpoint.Call(1);
- m_websocket->send(view->buffer().get(), m_exceptionState);
+ RefPtr<DOMArrayBuffer> buffer = view->buffer();
+ m_websocket->send(buffer.get(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState());
@@ -662,18 +665,20 @@ TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosed)
TEST_F(DOMWebSocketTest, sendArrayBufferSuccess)
{
- RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8);
+ RefPtr<DOMArrayBufferView> view = DOMUint8Array::deprecatedCreateOrCrash(8);
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
- EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8));
+ RefPtr<DOMArrayBuffer> buffer = view->buffer();
+ EXPECT_CALL(channel(), send(Ref(*buffer), 0, 8));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect("", "");
- m_websocket->send(view->buffer().get(), m_exceptionState);
+ RefPtr<DOMArrayBuffer> buffer = view->buffer();
+ m_websocket->send(buffer.get(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState());

Powered by Google App Engine
This is Rietveld 408576698