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

Unified Diff: third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp

Issue 2000253006: Implement URL and Origin typemaps/struct traits for blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try to fix gyp rules Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp
diff --git a/third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp b/third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7f1bd73ce7c9913afe2c03ee52ff0ae0d48238f6
--- /dev/null
+++ b/third_party/WebKit/Source/platform/mojo/KURLSecurityOriginTest.cpp
@@ -0,0 +1,93 @@
+// 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 "base/macros.h"
+#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/mojo/url_test.mojom-blink.h"
+#include "url/url_constants.h"
+
+namespace blink {
+namespace {
+
+class UrlTestImpl : public url::mojom::blink::UrlTest {
+public:
+ explicit UrlTestImpl(url::mojom::blink::UrlTestRequest request)
+ : m_binding(this, std::move(request))
+ {
+ }
+
+ // UrlTest:
+ void BounceUrl(const KURL& in, const BounceUrlCallback& callback) override
+ {
+ callback.Run(in);
+ }
+
+ void BounceOrigin(const RefPtr<SecurityOrigin>& in,
+ const BounceOriginCallback& callback) override
+ {
+ callback.Run(in);
+ }
+
+private:
+ mojo::Binding<UrlTest> m_binding;
+};
+
+} // namespace
+
+// Mojo version of chrome IPC test in url/ipc/url_param_traits_unittest.cc.
+TEST(KURLSecurityOriginStructTraitsTest, Basic)
+{
+ base::MessageLoop messageLoop;
+
+ url::mojom::blink::UrlTestPtr proxy;
+ UrlTestImpl impl(GetProxy(&proxy));
+
+ const char* serializeCases[] = {
+ "http://www.google.com/",
+ "http://user:pass@host.com:888/foo;bar?baz#nop",
+ };
+
+ for (const char* testCase : serializeCases) {
+ KURL input(KURL(), testCase);
+ KURL output;
+ EXPECT_TRUE(proxy->BounceUrl(input, &output));
+
+ // We want to test each component individually to make sure its range was
+ // correctly serialized and deserialized, not just the spec.
+ EXPECT_EQ(input.getString(), output.getString());
+ EXPECT_EQ(input.isValid(), output.isValid());
+ EXPECT_EQ(input.protocol(), output.protocol());
+ EXPECT_EQ(input.user(), output.user());
+ EXPECT_EQ(input.pass(), output.pass());
+ EXPECT_EQ(input.host(), output.host());
+ EXPECT_EQ(input.port(), output.port());
+ EXPECT_EQ(input.path(), output.path());
+ EXPECT_EQ(input.query(), output.query());
+ EXPECT_EQ(input.fragmentIdentifier(), output.fragmentIdentifier());
+ }
+
+ // Test an excessively long GURL.
+ {
+ const std::string url = std::string("http://example.org/").append(url::kMaxURLChars + 1, 'a');
+ KURL input(KURL(), url.c_str());
+ KURL output;
+ EXPECT_TRUE(proxy->BounceUrl(input, &output));
+ EXPECT_TRUE(output.isEmpty());
+ }
+
+ // Test basic Origin serialization.
+ RefPtr<SecurityOrigin> nonUnique = SecurityOrigin::create("http", "www.google.com", 80);
+ RefPtr<SecurityOrigin> output;
+ EXPECT_TRUE(proxy->BounceOrigin(nonUnique, &output));
+ EXPECT_TRUE(nonUnique->isSameSchemeHostPort(output.get()));
+ EXPECT_FALSE(nonUnique->isUnique());
+
+ RefPtr<SecurityOrigin> unique = SecurityOrigin::createUnique();
+ EXPECT_TRUE(proxy->BounceOrigin(unique, &output));
+ EXPECT_TRUE(output->isUnique());
+}
+
+} // namespace url
« no previous file with comments | « third_party/WebKit/Source/platform/mojo/KURL.typemap ('k') | third_party/WebKit/Source/platform/mojo/KURLStructTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698