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

Side by Side Diff: content/browser/shared_worker/shared_worker_instance_unittest.cc

Issue 2881073003: Support DataSaver for SharedWorker (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
OLDNEW
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
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, false);
60 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", "")); 60 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", ""));
61 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "")); 61 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", ""));
62 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "")); 62 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", ""));
63 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "")); 63 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", ""));
64 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name")); 64 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name"));
65 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name")); 65 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name"));
66 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name")); 66 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name"));
67 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name")); 67 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name"));
68 68
69 SharedWorkerInstance instance2( 69 SharedWorkerInstance instance2(
70 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), 70 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"),
71 base::string16(), blink::kWebContentSecurityPolicyTypeReport, 71 base::string16(), blink::kWebContentSecurityPolicyTypeReport,
72 blink::kWebAddressSpacePublic, browser_context_->GetResourceContext(), 72 blink::kWebAddressSpacePublic, browser_context_->GetResourceContext(),
73 partition_id_, blink::kWebSharedWorkerCreationContextTypeNonsecure); 73 partition_id_, blink::kWebSharedWorkerCreationContextTypeNonsecure,
74 false);
74 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "")); 75 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", ""));
75 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "")); 76 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", ""));
76 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "")); 77 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", ""));
77 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "")); 78 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", ""));
78 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name")); 79 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name"));
79 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name")); 80 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name"));
80 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name")); 81 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name"));
81 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name")); 82 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name"));
82 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2")); 83 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2"));
83 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2")); 84 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2"));
84 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2")); 85 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2"));
85 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2")); 86 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2"));
86 } 87 }
87 88
88 TEST_F(SharedWorkerInstanceTest, AddressSpace) { 89 TEST_F(SharedWorkerInstanceTest, AddressSpace) {
89 for (int i = 0; i < static_cast<int>(blink::kWebAddressSpaceLast); i++) { 90 for (int i = 0; i < static_cast<int>(blink::kWebAddressSpaceLast); i++) {
90 SharedWorkerInstance instance( 91 SharedWorkerInstance instance(
91 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), 92 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"),
92 base::string16(), blink::kWebContentSecurityPolicyTypeReport, 93 base::string16(), blink::kWebContentSecurityPolicyTypeReport,
93 static_cast<blink::WebAddressSpace>(i), 94 static_cast<blink::WebAddressSpace>(i),
94 browser_context_->GetResourceContext(), partition_id_, 95 browser_context_->GetResourceContext(), partition_id_,
95 blink::kWebSharedWorkerCreationContextTypeNonsecure); 96 blink::kWebSharedWorkerCreationContextTypeNonsecure, false);
96 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i), 97 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i),
97 instance.creation_address_space()); 98 instance.creation_address_space());
98 } 99 }
99 } 100 }
100 101
101 } // namespace content 102 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698