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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp

Issue 2566503002: Adds HTTP check to PresentationRequest creation. (Closed)
Patch Set: Adds unittest Created 3 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/modules/presentation/PresentationRequest.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 "modules/presentation/PresentationRequest.h" 5 #include "modules/presentation/PresentationRequest.h"
6 6
7 #include "bindings/core/v8/V8BindingForTesting.h" 7 #include "bindings/core/v8/V8BindingForTesting.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 11 matching lines...) Expand all
22 WTF::Vector<KURL> requestUrls = request->urls(); 22 WTF::Vector<KURL> requestUrls = request->urls();
23 EXPECT_EQ(static_cast<size_t>(1), requestUrls.size()); 23 EXPECT_EQ(static_cast<size_t>(1), requestUrls.size());
24 EXPECT_TRUE(requestUrls[0].isValid()); 24 EXPECT_TRUE(requestUrls[0].isValid());
25 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); 25 EXPECT_EQ("https://example.com/", requestUrls[0].getString());
26 } 26 }
27 27
28 TEST(PresentationRequestTest, TestMultipleUrlConstructor) { 28 TEST(PresentationRequestTest, TestMultipleUrlConstructor) {
29 V8TestingScope scope; 29 V8TestingScope scope;
30 WTF::Vector<String> urls; 30 WTF::Vector<String> urls;
31 urls.append("https://example.com"); 31 urls.append("https://example.com");
32 urls.append("cast://deadbeef?param=foo"); 32 urls.append("http://deadbeef?param=foo");
33 33
34 PresentationRequest* request = PresentationRequest::create( 34 PresentationRequest* request = PresentationRequest::create(
35 scope.getExecutionContext(), urls, scope.getExceptionState()); 35 scope.getExecutionContext(), urls, scope.getExceptionState());
36 ASSERT_FALSE(scope.getExceptionState().hadException()); 36 ASSERT_FALSE(scope.getExceptionState().hadException());
37 37
38 WTF::Vector<KURL> requestUrls = request->urls(); 38 WTF::Vector<KURL> requestUrls = request->urls();
39 EXPECT_EQ(static_cast<size_t>(2), requestUrls.size()); 39 EXPECT_EQ(static_cast<size_t>(2), requestUrls.size());
40 EXPECT_TRUE(requestUrls[0].isValid()); 40 EXPECT_TRUE(requestUrls[0].isValid());
41 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); 41 EXPECT_EQ("https://example.com/", requestUrls[0].getString());
42 EXPECT_TRUE(requestUrls[1].isValid()); 42 EXPECT_TRUE(requestUrls[1].isValid());
43 EXPECT_EQ("cast://deadbeef?param=foo", requestUrls[1].getString()); 43 EXPECT_EQ("http://deadbeef/?param=foo", requestUrls[1].getString());
44 }
45
46 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidURLFamily) {
47 V8TestingScope scope;
48 WTF::Vector<String> urls;
49 urls.append("https://example.com");
50 urls.append("cast://deadbeef?param=foo");
zhaobin 2017/01/18 18:58:22 Some layout tests uses url with "cast://". They ma
mark a. foltz 2017/01/18 20:26:01 Yeah, now that we have tests for cast:// we should
51
52 PresentationRequest::create(scope.getExecutionContext(), urls,
53 scope.getExceptionState());
54 ASSERT_TRUE(scope.getExceptionState().hadException());
55
56 EXPECT_EQ(SyntaxError, scope.getExceptionState().code());
44 } 57 }
45 58
46 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) { 59 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) {
47 V8TestingScope scope; 60 V8TestingScope scope;
48 WTF::Vector<String> urls; 61 WTF::Vector<String> urls;
49 urls.append("https://example.com"); 62 urls.append("https://example.com");
50 urls.append(""); 63 urls.append("");
51 64
52 PresentationRequest::create(scope.getExecutionContext(), urls, 65 PresentationRequest::create(scope.getExecutionContext(), urls,
53 scope.getExceptionState()); 66 scope.getExceptionState());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 WTF::Vector<String> urls; 99 WTF::Vector<String> urls;
87 100
88 PresentationRequest::create(scope.getExecutionContext(), urls, 101 PresentationRequest::create(scope.getExecutionContext(), urls,
89 scope.getExceptionState()); 102 scope.getExceptionState());
90 EXPECT_TRUE(scope.getExceptionState().hadException()); 103 EXPECT_TRUE(scope.getExceptionState().hadException());
91 EXPECT_EQ(NotSupportedError, scope.getExceptionState().code()); 104 EXPECT_EQ(NotSupportedError, scope.getExceptionState().code());
92 } 105 }
93 106
94 } // anonymous namespace 107 } // anonymous namespace
95 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698