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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp

Issue 2552343009: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed)
Patch Set: resolve code review comments from mlamouri Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..30cd70c44081ca556f8f403e7c7ae04c5f28b9ec
--- /dev/null
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequestTest.cpp
@@ -0,0 +1,72 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/presentation/PresentationRequest.h"
+
+#include "bindings/core/v8/V8BindingForTesting.h"
+#include "core/dom/ExceptionCode.h"
+#include "platform/weborigin/KURL.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+namespace {
+
+TEST(PresentationRequestTest, TestSingleUrlConstructor) {
+ V8TestingScope scope;
+ PresentationRequest* request = PresentationRequest::create(
+ scope.getExecutionContext(), "https://example.com",
+ scope.getExceptionState());
+ ASSERT_FALSE(scope.getExceptionState().hadException());
+ 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.
+ 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.
+ EXPECT_TRUE(requestUrls[0].isValid());
+ 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.
+}
+
+TEST(PresentationRequestTest, TestMultipleUrlConstructor) {
+ V8TestingScope scope;
+ WTF::Vector<String> urls;
+ urls.append("https://example.com");
+ urls.append("cast://deadbeef?param=foo");
+
+ PresentationRequest* request = PresentationRequest::create(
+ scope.getExecutionContext(), urls, scope.getExceptionState());
+ ASSERT_FALSE(scope.getExceptionState().hadException());
+ 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.
+ EXPECT_EQ(static_cast<size_t>(2), requestUrls.size());
+ EXPECT_TRUE(requestUrls[0].isValid());
+ EXPECT_EQ("https://example.com/", requestUrls[0].getString());
+ EXPECT_TRUE(requestUrls[1].isValid());
+ EXPECT_EQ("cast://deadbeef?param=foo", requestUrls[1].getString());
+}
+
+TEST(PresentationRequestTest, TestMultipleUrlConstructorInvalidUrl) {
+ V8TestingScope scope;
+ WTF::Vector<String> urls;
+ urls.append("https://example.com");
+ urls.append("");
+
+ PresentationRequest::create(scope.getExecutionContext(), urls,
+ scope.getExceptionState());
+ EXPECT_TRUE(scope.getExceptionState().hadException());
+ EXPECT_EQ(SyntaxError, scope.getExceptionState().code());
+}
+
+TEST(PresentationRequestTest, TestMultipleUrlConstructorMixedContent) {
+ V8TestingScope scope;
+ scope.getExecutionContext()->securityContext().setSecurityOrigin(
+ SecurityOrigin::createFromString("https://example.test"));
+
+ WTF::Vector<String> urls;
+ urls.append("http://example.com");
+ urls.append("https://example1.com");
+
+ PresentationRequest::create(scope.getExecutionContext(), urls,
+ scope.getExceptionState());
+ EXPECT_TRUE(scope.getExceptionState().hadException());
+ EXPECT_EQ(SecurityError, scope.getExceptionState().code());
+}
+
+} // anonymous namespace
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698