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 WTF::Vector<KURL> requestUrls = request->urls(); | |
|
mlamouri (slow - plz ping)
2016/12/13 13:50:53
style: can you add a blank line before the `reques
zhaobin
2016/12/14 01:51:54
Done.
| |
| 22 EXPECT_EQ(requestUrls.size(), static_cast<size_t>(1)); | |
|
mlamouri (slow - plz ping)
2016/12/13 13:50:53
should this be (expected, actual)?
zhaobin
2016/12/14 01:51:54
Done.
| |
| 23 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 24 EXPECT_EQ(requestUrls[0].getString(), "https://example.com/"); | |
|
mlamouri (slow - plz ping)
2016/12/13 13:50:53
ditto
zhaobin
2016/12/14 01:51:54
Done.
| |
| 25 } | |
| 26 | |
| 27 TEST(PresentationRequestTest, TestMultipleUrlConstructor) { | |
| 28 V8TestingScope scope; | |
| 29 WTF::Vector<String> urls; | |
| 30 urls.append("https://example.com"); | |
| 31 urls.append("cast://deadbeef?param=foo"); | |
| 32 | |
| 33 PresentationRequest* request = PresentationRequest::create( | |
| 34 scope.getExecutionContext(), urls, scope.getExceptionState()); | |
| 35 ASSERT_FALSE(scope.getExceptionState().hadException()); | |
| 36 WTF::Vector<KURL> requestUrls = request->urls(); | |
|
mlamouri (slow - plz ping)
2016/12/13 13:50:53
style: ditto
zhaobin
2016/12/14 01:51:54
Done.
| |
| 37 EXPECT_EQ(static_cast<size_t>(2), requestUrls.size()); | |
| 38 EXPECT_TRUE(requestUrls[0].isValid()); | |
| 39 EXPECT_EQ("https://example.com/", requestUrls[0].getString()); | |
| 40 EXPECT_TRUE(requestUrls[1].isValid()); | |
| 41 EXPECT_EQ("cast://deadbeef?param=foo", requestUrls[1].getString()); | |
| 42 } | |
| 43 | |
| 44 TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) { | |
| 45 V8TestingScope scope; | |
| 46 WTF::Vector<String> urls; | |
| 47 urls.append("https://example.com"); | |
| 48 urls.append(""); | |
| 49 | |
| 50 PresentationRequest::create(scope.getExecutionContext(), urls, | |
| 51 scope.getExceptionState()); | |
| 52 EXPECT_TRUE(scope.getExceptionState().hadException()); | |
| 53 EXPECT_EQ(SyntaxError, scope.getExceptionState().code()); | |
| 54 } | |
| 55 | |
| 56 TEST(PresentationRequestTest, TestMultipleUrlConstructorMixedContent) { | |
| 57 V8TestingScope scope; | |
| 58 scope.getExecutionContext()->securityContext().setSecurityOrigin( | |
| 59 SecurityOrigin::createFromString("https://example.test")); | |
| 60 | |
| 61 WTF::Vector<String> urls; | |
| 62 urls.append("http://example.com"); | |
| 63 urls.append("https://example1.com"); | |
| 64 | |
| 65 PresentationRequest::create(scope.getExecutionContext(), urls, | |
| 66 scope.getExceptionState()); | |
| 67 EXPECT_TRUE(scope.getExceptionState().hadException()); | |
| 68 EXPECT_EQ(SecurityError, scope.getExceptionState().code()); | |
| 69 } | |
| 70 | |
| 71 } // anonymous namespace | |
| 72 } // namespace blink | |
| OLD | NEW |