Index: Source/modules/websockets/DOMWebSocketTest.cpp |
diff --git a/Source/modules/websockets/DOMWebSocketTest.cpp b/Source/modules/websockets/DOMWebSocketTest.cpp |
index e72c303ad2bcc813650f245d2c2974fef14e4fdb..4974926726f11cdf2d31867c6b4561e542677bad 100644 |
--- a/Source/modules/websockets/DOMWebSocketTest.cpp |
+++ b/Source/modules/websockets/DOMWebSocketTest.cpp |
@@ -10,6 +10,7 @@ |
#include "core/dom/DOMTypedArray.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExceptionCode.h" |
+#include "core/dom/SecurityContext.h" |
#include "core/fileapi/Blob.h" |
#include "core/frame/ConsoleTypes.h" |
#include "core/testing/DummyPageHolder.h" |
@@ -187,6 +188,51 @@ TEST_F(DOMWebSocketTest, invalidSubprotocols) |
EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState()); |
} |
+TEST_F(DOMWebSocketTest, insecureContentUpgrade) |
+{ |
+ { |
+ InSequence s; |
+ EXPECT_CALL(channel(), connect(KURL(KURL(), "wss://example.com/endpoint"), String())).WillOnce(Return(true)); |
+ } |
+ |
+ m_pageHolder->document().setInsecureContentPolicy(SecurityContext::InsecureContentUpgrade); |
+ m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_exceptionState); |
+ |
+ EXPECT_FALSE(m_exceptionState.hadException()); |
+ EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
+ EXPECT_EQ(KURL(KURL(), "wss://example.com/endpoint"), m_websocket->url()); |
+} |
+ |
+TEST_F(DOMWebSocketTest, insecureContentDoNotUpgrade) |
+{ |
+ { |
+ InSequence s; |
+ EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/endpoint"), String())).WillOnce(Return(true)); |
+ } |
+ |
+ m_pageHolder->document().setInsecureContentPolicy(SecurityContext::InsecureContentDoNotUpgrade); |
+ m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_exceptionState); |
+ |
+ EXPECT_FALSE(m_exceptionState.hadException()); |
+ EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
+ EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"), m_websocket->url()); |
+} |
+ |
+TEST_F(DOMWebSocketTest, insecureContentMonitor) |
+{ |
+ { |
+ InSequence s; |
+ EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/endpoint"), String())).WillOnce(Return(true)); |
+ } |
+ |
+ m_pageHolder->document().setInsecureContentPolicy(SecurityContext::InsecureContentMonitor); |
+ m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_exceptionState); |
+ |
+ EXPECT_FALSE(m_exceptionState.hadException()); |
+ EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
+ EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"), m_websocket->url()); |
+} |
+ |
TEST_F(DOMWebSocketTest, channelConnectSuccess) |
{ |
Vector<String> subprotocols; |