| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/shared_worker/shared_worker_instance.h" | 5 #include "content/browser/shared_worker/shared_worker_instance.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); | 51 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 TEST_F(SharedWorkerInstanceTest, MatchesTest) { | 54 TEST_F(SharedWorkerInstanceTest, MatchesTest) { |
| 55 SharedWorkerInstance instance1( | 55 SharedWorkerInstance instance1( |
| 56 GURL("http://example.com/w.js"), base::string16(), base::string16(), | 56 GURL("http://example.com/w.js"), base::string16(), base::string16(), |
| 57 blink::kWebContentSecurityPolicyTypeReport, blink::kWebAddressSpacePublic, | 57 blink::kWebContentSecurityPolicyTypeReport, blink::kWebAddressSpacePublic, |
| 58 browser_context_->GetResourceContext(), partition_id_, | 58 browser_context_->GetResourceContext(), partition_id_, |
| 59 blink::kWebSharedWorkerCreationContextTypeNonsecure); | 59 blink::kWebSharedWorkerCreationContextTypeNonsecure, |
| 60 false /* data_saver_enabled */); |
| 60 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", "")); | 61 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", "")); |
| 61 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "")); | 62 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "")); |
| 62 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "")); | 63 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "")); |
| 63 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "")); | 64 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "")); |
| 64 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name")); | 65 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name")); |
| 65 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name")); | 66 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name")); |
| 66 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name")); | 67 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name")); |
| 67 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name")); | 68 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name")); |
| 68 | 69 |
| 69 SharedWorkerInstance instance2( | 70 SharedWorkerInstance instance2( |
| 70 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), | 71 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), |
| 71 base::string16(), blink::kWebContentSecurityPolicyTypeReport, | 72 base::string16(), blink::kWebContentSecurityPolicyTypeReport, |
| 72 blink::kWebAddressSpacePublic, browser_context_->GetResourceContext(), | 73 blink::kWebAddressSpacePublic, browser_context_->GetResourceContext(), |
| 73 partition_id_, blink::kWebSharedWorkerCreationContextTypeNonsecure); | 74 partition_id_, blink::kWebSharedWorkerCreationContextTypeNonsecure, |
| 75 false /* data_saver_enabled */); |
| 74 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "")); | 76 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "")); |
| 75 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "")); | 77 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "")); |
| 76 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "")); | 78 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "")); |
| 77 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "")); | 79 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "")); |
| 78 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name")); | 80 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name")); |
| 79 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name")); | 81 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name")); |
| 80 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name")); | 82 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name")); |
| 81 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name")); | 83 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name")); |
| 82 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2")); | 84 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2")); |
| 83 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2")); | 85 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2")); |
| 84 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2")); | 86 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2")); |
| 85 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2")); | 87 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2")); |
| 86 } | 88 } |
| 87 | 89 |
| 88 TEST_F(SharedWorkerInstanceTest, AddressSpace) { | 90 TEST_F(SharedWorkerInstanceTest, AddressSpace) { |
| 89 for (int i = 0; i < static_cast<int>(blink::kWebAddressSpaceLast); i++) { | 91 for (int i = 0; i < static_cast<int>(blink::kWebAddressSpaceLast); i++) { |
| 90 SharedWorkerInstance instance( | 92 SharedWorkerInstance instance( |
| 91 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), | 93 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), |
| 92 base::string16(), blink::kWebContentSecurityPolicyTypeReport, | 94 base::string16(), blink::kWebContentSecurityPolicyTypeReport, |
| 93 static_cast<blink::WebAddressSpace>(i), | 95 static_cast<blink::WebAddressSpace>(i), |
| 94 browser_context_->GetResourceContext(), partition_id_, | 96 browser_context_->GetResourceContext(), partition_id_, |
| 95 blink::kWebSharedWorkerCreationContextTypeNonsecure); | 97 blink::kWebSharedWorkerCreationContextTypeNonsecure, |
| 98 false /* data_saver_enabled */); |
| 96 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i), | 99 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i), |
| 97 instance.creation_address_space()); | 100 instance.creation_address_space()); |
| 98 } | 101 } |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace content | 104 } // namespace content |
| OLD | NEW |