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

Side by Side Diff: Source/modules/websockets/DOMWebSocketTest.cpp

Issue 980213002: Rename InsecureContentPolicy to InsecureRequestsPolicy. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/websockets/DOMWebSocket.h" 6 #include "modules/websockets/DOMWebSocket.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "core/dom/DOMTypedArray.h" 10 #include "core/dom/DOMTypedArray.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 subprotocols.append("@subprotocol-|'\"x\x01\x02\x03x"); 182 subprotocols.append("@subprotocol-|'\"x\x01\x02\x03x");
183 183
184 m_websocket->connect("ws://example.com/", subprotocols, m_exceptionState); 184 m_websocket->connect("ws://example.com/", subprotocols, m_exceptionState);
185 185
186 EXPECT_TRUE(m_exceptionState.hadException()); 186 EXPECT_TRUE(m_exceptionState.hadException());
187 EXPECT_EQ(SyntaxError, m_exceptionState.code()); 187 EXPECT_EQ(SyntaxError, m_exceptionState.code());
188 EXPECT_EQ("The subprotocol '@subprotocol-|'\"x\\u0001\\u0002\\u0003x' is inv alid.", m_exceptionState.message()); 188 EXPECT_EQ("The subprotocol '@subprotocol-|'\"x\\u0001\\u0002\\u0003x' is inv alid.", m_exceptionState.message());
189 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState()); 189 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState());
190 } 190 }
191 191
192 TEST_F(DOMWebSocketTest, insecureContentUpgrade) 192 TEST_F(DOMWebSocketTest, insecureRequestsUpgrade)
193 { 193 {
194 { 194 {
195 InSequence s; 195 InSequence s;
196 EXPECT_CALL(channel(), connect(KURL(KURL(), "wss://example.com/endpoint" ), String())).WillOnce(Return(true)); 196 EXPECT_CALL(channel(), connect(KURL(KURL(), "wss://example.com/endpoint" ), String())).WillOnce(Return(true));
197 } 197 }
198 198
199 m_pageHolder->document().setInsecureContentPolicy(SecurityContext::InsecureC ontentUpgrade); 199 m_pageHolder->document().setInsecureRequestsPolicy(SecurityContext::Insecure RequestsUpgrade);
200 m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_except ionState); 200 m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_except ionState);
201 201
202 EXPECT_FALSE(m_exceptionState.hadException()); 202 EXPECT_FALSE(m_exceptionState.hadException());
203 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 203 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
204 EXPECT_EQ(KURL(KURL(), "wss://example.com/endpoint"), m_websocket->url()); 204 EXPECT_EQ(KURL(KURL(), "wss://example.com/endpoint"), m_websocket->url());
205 } 205 }
206 206
207 TEST_F(DOMWebSocketTest, insecureContentDoNotUpgrade) 207 TEST_F(DOMWebSocketTest, insecureRequestsDoNotUpgrade)
208 { 208 {
209 { 209 {
210 InSequence s; 210 InSequence s;
211 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/endpoint") , String())).WillOnce(Return(true)); 211 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/endpoint") , String())).WillOnce(Return(true));
212 } 212 }
213 213
214 m_pageHolder->document().setInsecureContentPolicy(SecurityContext::InsecureC ontentDoNotUpgrade); 214 m_pageHolder->document().setInsecureRequestsPolicy(SecurityContext::Insecure RequestsDoNotUpgrade);
215 m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_except ionState); 215 m_websocket->connect("ws://example.com/endpoint", Vector<String>(), m_except ionState);
216 216
217 EXPECT_FALSE(m_exceptionState.hadException()); 217 EXPECT_FALSE(m_exceptionState.hadException());
218 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 218 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
219 EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"), m_websocket->url()); 219 EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"), m_websocket->url());
220 } 220 }
221 221
222 TEST_F(DOMWebSocketTest, channelConnectSuccess) 222 TEST_F(DOMWebSocketTest, channelConnectSuccess)
223 { 223 {
224 Vector<String> subprotocols; 224 Vector<String> subprotocols;
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); 729 EXPECT_EQ(InvalidAccessError, m_exceptionState.code());
730 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message()); 730 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message());
731 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 731 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
732 } 732 }
733 733
734 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); 734 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535));
735 735
736 } // namespace 736 } // namespace
737 737
738 } // namespace blink 738 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698