1 // Copyright 2014 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.
6 #include "core/loader/MixedContentChecker.h"
8 #include "platform/weborigin/KURL.h"
9 #include "platform/weborigin/SecurityOrigin.h"
10 #include "wtf/RefPtr.h"
12 #include <base/macros.h>
13 #include <gtest/gtest.h>
17 TEST(MixedContentCheckerTest, IsMixedContent)
24 {"http://example.com/foo", "http://example.com/foo", false},
25 {"http://example.com/foo", "https://example.com/foo", false},
26 {"https://example.com/foo", "https://example.com/foo", false},
27 {"https://example.com/foo", "wss://example.com/foo", false},
28 {"https://example.com/foo", "http://example.com/foo", true},
29 {"https://example.com/foo", "http://google.com/foo", true},
30 {"https://example.com/foo", "ws://example.com/foo", true},
31 {"https://example.com/foo", "ws://google.com/foo", true},
34 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
35 const char* origin = cases[i].origin;
36 const char* target = cases[i].target;
37 bool expectation = cases[i].expectation;
39 KURL originUrl(KURL(), origin);
40 RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl));
41 KURL targetUrl(KURL(), target);
42 EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigin.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Expectation: " << expectation;
46 } // namespace WebCore