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

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

Issue 1775933002: CORS-RFC1918: Pipe creator address space through SharedWorker creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile Created 4 years, 9 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/shared_worker/shared_worker_instance.h" 9 #include "content/browser/shared_worker/shared_worker_instance.h"
10 #include "content/browser/shared_worker/worker_storage_partition.h" 10 #include "content/browser/shared_worker/worker_storage_partition.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 scoped_ptr<TestBrowserContext> browser_context_; 42 scoped_ptr<TestBrowserContext> browser_context_;
43 scoped_ptr<WorkerStoragePartition> partition_; 43 scoped_ptr<WorkerStoragePartition> partition_;
44 const WorkerStoragePartitionId partition_id_; 44 const WorkerStoragePartitionId partition_id_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest); 46 DISALLOW_COPY_AND_ASSIGN(SharedWorkerInstanceTest);
47 }; 47 };
48 48
49 TEST_F(SharedWorkerInstanceTest, MatchesTest) { 49 TEST_F(SharedWorkerInstanceTest, MatchesTest) {
50 SharedWorkerInstance instance1( 50 SharedWorkerInstance instance1(
51 GURL("http://example.com/w.js"), base::string16(), base::string16(), 51 GURL("http://example.com/w.js"), base::string16(), base::string16(),
52 blink::WebContentSecurityPolicyTypeReport, 52 blink::WebContentSecurityPolicyTypeReport, blink::WebAddressSpacePublic,
53 browser_context_->GetResourceContext(), partition_id_, 53 browser_context_->GetResourceContext(), partition_id_,
54 blink::WebSharedWorkerCreationContextTypeNonsecure); 54 blink::WebSharedWorkerCreationContextTypeNonsecure);
55 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", "")); 55 EXPECT_TRUE(Matches(instance1, "http://example.com/w.js", ""));
56 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "")); 56 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", ""));
57 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "")); 57 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", ""));
58 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "")); 58 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", ""));
59 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name")); 59 EXPECT_FALSE(Matches(instance1, "http://example.com/w.js", "name"));
60 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name")); 60 EXPECT_FALSE(Matches(instance1, "http://example.com/w2.js", "name"));
61 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name")); 61 EXPECT_FALSE(Matches(instance1, "http://example.net/w.js", "name"));
62 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name")); 62 EXPECT_FALSE(Matches(instance1, "http://example.net/w2.js", "name"));
63 63
64 SharedWorkerInstance instance2( 64 SharedWorkerInstance instance2(
65 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"), 65 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"),
66 base::string16(), blink::WebContentSecurityPolicyTypeReport, 66 base::string16(), blink::WebContentSecurityPolicyTypeReport,
67 browser_context_->GetResourceContext(), partition_id_, 67 blink::WebAddressSpacePublic, browser_context_->GetResourceContext(),
68 blink::WebSharedWorkerCreationContextTypeNonsecure); 68 partition_id_, blink::WebSharedWorkerCreationContextTypeNonsecure);
69 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "")); 69 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", ""));
70 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "")); 70 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", ""));
71 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "")); 71 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", ""));
72 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "")); 72 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", ""));
73 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name")); 73 EXPECT_TRUE(Matches(instance2, "http://example.com/w.js", "name"));
74 EXPECT_TRUE(Matches(instance2, "http://example.com/w2.js", "name")); 74 EXPECT_TRUE(Matches(instance2, "http://example.com/w2.js", "name"));
75 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name")); 75 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name"));
76 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name")); 76 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name"));
77 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2")); 77 EXPECT_FALSE(Matches(instance2, "http://example.com/w.js", "name2"));
78 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2")); 78 EXPECT_FALSE(Matches(instance2, "http://example.com/w2.js", "name2"));
79 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2")); 79 EXPECT_FALSE(Matches(instance2, "http://example.net/w.js", "name2"));
80 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2")); 80 EXPECT_FALSE(Matches(instance2, "http://example.net/w2.js", "name2"));
81 } 81 }
82 82
83 TEST_F(SharedWorkerInstanceTest, AddressSpace) {
84 for (int i = 0; i < 3; i++) {
kinuko 2016/03/08 15:53:56 Maybe i = 0; i <= static_cast<int>(WebAddressSpa
85 SharedWorkerInstance instance(
86 GURL("http://example.com/w.js"), base::ASCIIToUTF16("name"),
87 base::string16(), blink::WebContentSecurityPolicyTypeReport,
88 static_cast<blink::WebAddressSpace>(i),
89 browser_context_->GetResourceContext(), partition_id_,
90 blink::WebSharedWorkerCreationContextTypeNonsecure);
91 EXPECT_EQ(static_cast<blink::WebAddressSpace>(i),
92 instance.creation_address_space());
93 }
94 }
95
83 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/shared_worker/shared_worker_instance.cc ('k') | content/browser/shared_worker/shared_worker_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698