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

Side by Side Diff: third_party/WebKit/Source/core/page/EventSourceTest.cpp

Issue 1601553004: [EventSource] retry field including non-digit chars should be ignored (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@event-source
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/page/EventSource.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/page/EventSource.h" 5 #include "core/page/EventSource.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/ScriptValue.h" 9 #include "bindings/core/v8/ScriptValue.h"
10 #include "bindings/core/v8/SerializedScriptValue.h" 10 #include "bindings/core/v8/SerializedScriptValue.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 enqueue("retry:123\n"); 266 enqueue("retry:123\n");
267 EXPECT_NE(EventSource::defaultReconnectDelay, source()->reconnectDelayForTes t()); 267 EXPECT_NE(EventSource::defaultReconnectDelay, source()->reconnectDelayForTes t());
268 EXPECT_EQ(123u, source()->reconnectDelayForTest()); 268 EXPECT_EQ(123u, source()->reconnectDelayForTest());
269 269
270 enqueue("retry:a0\n"); 270 enqueue("retry:a0\n");
271 EXPECT_EQ(123u, source()->reconnectDelayForTest()); 271 EXPECT_EQ(123u, source()->reconnectDelayForTest());
272 enqueue("retry:xi\n"); 272 enqueue("retry:xi\n");
273 EXPECT_EQ(123u, source()->reconnectDelayForTest()); 273 EXPECT_EQ(123u, source()->reconnectDelayForTest());
274 274
275 enqueue("retry:2a\n"); 275 enqueue("retry:2a\n");
276 // TODO(yhirano): Should be ignored. 276 EXPECT_EQ(123u, source()->reconnectDelayForTest());
277 // EXPECT_EQ(123u, source()->reconnectDelayForTest());
278 EXPECT_EQ(2u, source()->reconnectDelayForTest());
279 277
280 enqueue("retry:09a\n"); 278 enqueue("retry:09a\n");
281 // TODO(yhirano): Should be ignored. 279 EXPECT_EQ(123u, source()->reconnectDelayForTest());
282 // EXPECT_EQ(123u, source()->reconnectDelayForTest());
283 EXPECT_EQ(9u, source()->reconnectDelayForTest());
284 280
285 enqueue("retry:1\b\n"); 281 enqueue("retry:1\b\n");
286 // TODO(yhirano): Should be ignored. 282 EXPECT_EQ(123u, source()->reconnectDelayForTest());
287 // EXPECT_EQ(123u, source()->reconnectDelayForTest());
288 EXPECT_EQ(1u, source()->reconnectDelayForTest());
289 283
290 enqueue("retry: 1234\n"); 284 enqueue("retry: 1234\n");
291 // TODO(yhirano): Should be ignored. 285 EXPECT_EQ(123u, source()->reconnectDelayForTest());
292 // EXPECT_EQ(123u, source()->reconnectDelayForTest());
293 EXPECT_EQ(1234u, source()->reconnectDelayForTest());
294 286
295 enqueue("retry:456 \n"); 287 enqueue("retry:456 \n");
296 // TODO(yhirano): Should be ignored. 288 EXPECT_EQ(123u, source()->reconnectDelayForTest());
297 // EXPECT_EQ(123u, source()->reconnectDelayForTest());
298 EXPECT_EQ(456u, source()->reconnectDelayForTest());
299 289
300 EXPECT_EQ(0u, listener->events().size()); 290 EXPECT_EQ(0u, listener->events().size());
301 } 291 }
302 292
303 TEST_F(EventSourceTest, UnrecognizedFieldShouldBeIgnored) 293 TEST_F(EventSourceTest, UnrecognizedFieldShouldBeIgnored)
304 { 294 {
305 RefPtrWillBeRawPtr<FakeEventListener> listener = FakeEventListener::create() ; 295 RefPtrWillBeRawPtr<FakeEventListener> listener = FakeEventListener::create() ;
306 296
307 source()->addEventListener("message", listener); 297 source()->addEventListener("message", listener);
308 enqueue("data:hello\nhoge:fuga\npiyo\n\n"); 298 enqueue("data:hello\nhoge:fuga\npiyo\n\n");
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 ASSERT_EQ("message", messageListener->events()[0]->type()); 418 ASSERT_EQ("message", messageListener->events()[0]->type());
429 RefPtrWillBeRawPtr<MessageEvent> messageEvent = static_cast<MessageEvent*>(m essageListener->events()[0].get()); 419 RefPtrWillBeRawPtr<MessageEvent> messageEvent = static_cast<MessageEvent*>(m essageListener->events()[0].get());
430 ASSERT_EQ(MessageEvent::DataTypeSerializedScriptValue, messageEvent->dataTyp e()); 420 ASSERT_EQ(MessageEvent::DataTypeSerializedScriptValue, messageEvent->dataTyp e());
431 EXPECT_EQ("bye", dataAsString(scriptState(), messageEvent.get())); 421 EXPECT_EQ("bye", dataAsString(scriptState(), messageEvent.get()));
432 EXPECT_EQ("8", messageEvent->lastEventId()); 422 EXPECT_EQ("8", messageEvent->lastEventId());
433 } 423 }
434 424
435 } // namespace 425 } // namespace
436 426
437 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/EventSource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698