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

Side by Side Diff: Source/web/tests/WebDocumentTest.cpp

Issue 1174283002: Fix unit test style in Source/web/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/ViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6
7 #include "public/web/WebDocument.h" 6 #include "public/web/WebDocument.h"
8 7
9 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
10 #include "core/HTMLNames.h" 9 #include "core/HTMLNames.h"
11 #include "core/dom/NodeComputedStyle.h" 10 #include "core/dom/NodeComputedStyle.h"
12 #include "core/dom/StyleEngine.h" 11 #include "core/dom/StyleEngine.h"
13 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
14 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
15 #include "core/html/HTMLLinkElement.h" 14 #include "core/html/HTMLLinkElement.h"
16 #include "core/style/ComputedStyle.h" 15 #include "core/style/ComputedStyle.h"
17 #include "core/page/Page.h" 16 #include "core/page/Page.h"
18 #include "platform/RuntimeEnabledFeatures.h" 17 #include "platform/RuntimeEnabledFeatures.h"
19 #include "platform/graphics/Color.h" 18 #include "platform/graphics/Color.h"
20 #include "platform/testing/URLTestHelpers.h" 19 #include "platform/testing/URLTestHelpers.h"
21 #include "platform/weborigin/SecurityOrigin.h" 20 #include "platform/weborigin/SecurityOrigin.h"
22 #include "web/tests/FrameTestHelpers.h" 21 #include "web/tests/FrameTestHelpers.h"
23 #include <gtest/gtest.h> 22 #include <gtest/gtest.h>
24 23
25 namespace { 24 namespace blink {
26 25
27 using blink::FrameTestHelpers::WebViewHelper; 26 using blink::FrameTestHelpers::WebViewHelper;
28 using blink::URLTestHelpers::toKURL; 27 using blink::URLTestHelpers::toKURL;
29 using namespace blink;
30 28
31 const char* kDefaultOrigin = "https://example.test/"; 29 const char* kDefaultOrigin = "https://example.test/";
32 const char* kManifestDummyFilePath = "manifest-dummy.html"; 30 const char* kManifestDummyFilePath = "manifest-dummy.html";
33 31
34 class WebDocumentTest : public ::testing::Test { 32 class WebDocumentTest : public ::testing::Test {
35 protected: 33 protected:
36 static void SetUpTestCase(); 34 static void SetUpTestCase();
37 35
38 void loadURL(const std::string& url); 36 void loadURL(const std::string& url);
39 Document* topDocument() const; 37 Document* topDocument() const;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Crossorigin set to 'anonymous' shouldn't trigger using credentials. 129 // Crossorigin set to 'anonymous' shouldn't trigger using credentials.
132 linkManifest->setAttribute(HTMLNames::crossoriginAttr, "anonymous"); 130 linkManifest->setAttribute(HTMLNames::crossoriginAttr, "anonymous");
133 ASSERT_FALSE(webDoc.manifestUseCredentials()); 131 ASSERT_FALSE(webDoc.manifestUseCredentials());
134 132
135 // Crossorigin set to 'use-credentials' should trigger using credentials. 133 // Crossorigin set to 'use-credentials' should trigger using credentials.
136 linkManifest->setAttribute(HTMLNames::crossoriginAttr, "use-credentials"); 134 linkManifest->setAttribute(HTMLNames::crossoriginAttr, "use-credentials");
137 ASSERT_TRUE(webDoc.manifestUseCredentials()); 135 ASSERT_TRUE(webDoc.manifestUseCredentials());
138 } 136 }
139 137
140 namespace { 138 namespace {
141 const char* baseURLOriginA = "http://example.test:0/";
142 const char* baseURLOriginSubA = "http://subdomain.example.test:0/";
143 const char* baseURLOriginB = "http://not-example.test:0/";
144 const char* emptyFile = "first_party/empty.html";
145 const char* nestedData = "first_party/nested-data.html";
146 const char* nestedOriginA = "first_party/nested-originA.html";
147 const char* nestedOriginSubA = "first_party/nested-originSubA.html";
148 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA. html";
149 const char* nestedOriginAInOriginB = "first_party/nested-originA-in-originB. html";
150 const char* nestedOriginB = "first_party/nested-originB.html";
151 const char* nestedOriginBInOriginA = "first_party/nested-originB-in-originA. html";
152 const char* nestedOriginBInOriginB = "first_party/nested-originB-in-originB. html";
153 const char* nestedSrcDoc = "first_party/nested-srcdoc.html";
154 139
155 static KURL toOriginA(const char* file) 140 const char* baseURLOriginA = "http://example.test:0/";
156 { 141 const char* baseURLOriginSubA = "http://subdomain.example.test:0/";
157 return toKURL(std::string(baseURLOriginA) + file); 142 const char* baseURLOriginB = "http://not-example.test:0/";
158 } 143 const char* emptyFile = "first_party/empty.html";
144 const char* nestedData = "first_party/nested-data.html";
145 const char* nestedOriginA = "first_party/nested-originA.html";
146 const char* nestedOriginSubA = "first_party/nested-originSubA.html";
147 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA.html ";
148 const char* nestedOriginAInOriginB = "first_party/nested-originA-in-originB.html ";
149 const char* nestedOriginB = "first_party/nested-originB.html";
150 const char* nestedOriginBInOriginA = "first_party/nested-originB-in-originA.html ";
151 const char* nestedOriginBInOriginB = "first_party/nested-originB-in-originB.html ";
152 const char* nestedSrcDoc = "first_party/nested-srcdoc.html";
159 153
160 static KURL toOriginSubA(const char* file) 154 static KURL toOriginA(const char* file)
kochi 2015/06/11 07:34:50 nit: don't need 'static' in anonymous namespace.
tkent 2015/06/11 07:38:35 Done.
161 { 155 {
162 return toKURL(std::string(baseURLOriginSubA) + file); 156 return toKURL(std::string(baseURLOriginA) + file);
163 } 157 }
164 158
165 static KURL toOriginB(const char* file) 159 static KURL toOriginSubA(const char* file)
kochi 2015/06/11 07:34:50 nit: ditto
tkent 2015/06/11 07:38:35 Done.
166 { 160 {
167 return toKURL(std::string(baseURLOriginB) + file); 161 return toKURL(std::string(baseURLOriginSubA) + file);
168 }
169 } 162 }
170 163
164 static KURL toOriginB(const char* file)
kochi 2015/06/11 07:34:50 nit: ditto
tkent 2015/06/11 07:38:35 Done.
165 {
166 return toKURL(std::string(baseURLOriginB) + file);
167 }
168
169 } // anonymous namespace
170
171 class WebDocumentFirstPartyTest : public WebDocumentTest { 171 class WebDocumentFirstPartyTest : public WebDocumentTest {
172 public: 172 public:
173 static void SetUpTestCase(); 173 static void SetUpTestCase();
174 174
175 protected: 175 protected:
176 void load(const char*); 176 void load(const char*);
177 Document* nestedDocument() const; 177 Document* nestedDocument() const;
178 Document* nestedNestedDocument() const; 178 Document* nestedNestedDocument() const;
179 }; 179 };
180 180
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 289 }
290 290
291 TEST_F(WebDocumentFirstPartyTest, NestedData) 291 TEST_F(WebDocumentFirstPartyTest, NestedData)
292 { 292 {
293 load(nestedData); 293 load(nestedData);
294 294
295 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); 295 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies());
296 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies()); 296 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies());
297 } 297 }
298 298
299 } 299 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/ViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698