Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/presentation/PresentationRequest.h" | |
| 6 | |
| 7 #include "bindings/core/v8/V8BindingForTesting.h" | |
| 8 #include "core/dom/ExceptionCode.h" | |
| 9 #include "platform/weborigin/KURL.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 namespace { | |
| 14 | |
| 15 TEST(PresentationRequestTest, TestSingleUrlConstructor) { | |
| 16 V8TestingScope scope; | |
| 17 PresentationRequest* request = PresentationRequest::create( | |
| 18 scope.getExecutionContext(), "https://example.com", | |
| 19 scope.getExceptionState()); | |
| 20 ASSERT_FALSE(scope.getExceptionState().hadException()); | |
| 21 | |
| 22 WTF::Vector<KURL> requestUrls = request->urls(); | |
| 23 EXPECT_EQ(static_cast<size_t>(1), requestUrls.size()); | |
| 24 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 25 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); | |
| 26 } | |
| 27 | |
| 28 TEST(PresentationRequestTest, TestMultipleUrlConstructor) { | |
| 29 V8TestingScope scope; | |
| 30 WTF::Vector<String> urls; | |
| 31 urls.append("https://example.com"); | |
| 32 urls.append("cast://deadbeef?param=foo"); | |
| 33 | |
| 34 PresentationRequest* request = PresentationRequest::create( | |
| 35 scope.getExecutionContext(), urls, scope.getExceptionState()); | |
| 36 ASSERT_FALSE(scope.getExceptionState().hadException()); | |
| 37 | |
| 38 WTF::Vector<KURL> requestUrls = request->urls(); | |
| 39 EXPECT_EQ(static_cast<size_t>(2), requestUrls.size()); | |
| 40 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 41 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); | |
| 42 EXPECT_TRUE(requestUrls[1].isValid()); | |
| 43 EXPECT_EQ("cast://deadbeef?param=foo", requestUrls[1].getString()); | |
| 44 } | |
| 45 | |
| 46 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) { | |
| 47 V8TestingScope scope; | |
| 48 WTF::Vector<String> urls; | |
| 49 urls.append("https://example.com"); | |
| 50 urls.append(""); | |
| 51 | |
| 52 PresentationRequest::create(scope.getExecutionContext(), urls, | |
| 53 scope.getExceptionState()); | |
| 54 EXPECT_TRUE(scope.getExceptionState().hadException()); | |
| 55 EXPECT_EQ(SyntaxError, scope.getExceptionState().code()); | |
| 56 } | |
| 57 | |
| 58 TEST(PresentationRequestTest, TestMultipleUrlConstructorMixedContent) { | |
|
mark a. foltz
2016/12/14 06:47:10
Can you add a test case for mixed content with the
zhaobin
2016/12/15 00:49:21
Done.
| |
| 59 V8TestingScope scope; | |
| 60 scope.getExecutionContext()->securityContext().setSecurityOrigin( | |
| 61 SecurityOrigin::createFromString("https://example.test")); | |
| 62 | |
| 63 WTF::Vector<String> urls; | |
| 64 urls.append("http://example.com"); | |
| 65 urls.append("https://example1.com"); | |
| 66 | |
| 67 PresentationRequest::create(scope.getExecutionContext(), urls, | |
| 68 scope.getExceptionState()); | |
| 69 EXPECT_TRUE(scope.getExceptionState().hadException()); | |
| 70 EXPECT_EQ(SecurityError, scope.getExceptionState().code()); | |
| 71 } | |
| 72 | |
| 73 } // anonymous namespace | |
| 74 } // namespace blink | |
| OLD | NEW |