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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "public/web/WebDocument.h" | 7 #include "public/web/WebDocument.h" |
8 | 8 |
9 #include "core/CSSPropertyNames.h" | 9 #include "core/CSSPropertyNames.h" |
10 #include "core/dom/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 | 201 |
202 frame->document().setIsTransitionDocument(true); | 202 frame->document().setIsTransitionDocument(true); |
203 ASSERT_TRUE(coreDoc->isTransitionDocument()); | 203 ASSERT_TRUE(coreDoc->isTransitionDocument()); |
204 | 204 |
205 frame->document().setIsTransitionDocument(false); | 205 frame->document().setIsTransitionDocument(false); |
206 ASSERT_FALSE(coreDoc->isTransitionDocument()); | 206 ASSERT_FALSE(coreDoc->isTransitionDocument()); |
207 } | 207 } |
208 | 208 |
209 namespace { | 209 namespace { |
210 const char* baseURLOriginA = "http://example.test:0/"; | 210 const char* baseURLOriginA = "http://example.test:0/"; |
211 const char* baseURLOriginSubA = "http://subdomain.example.test:0/"; | |
Ryan Sleevi
2015/05/15 21:33:42
An invalid origin, FWIW ;)
(:0 = oh noes)
| |
211 const char* baseURLOriginB = "http://not-example.test:0/"; | 212 const char* baseURLOriginB = "http://not-example.test:0/"; |
212 const char* emptyFile = "first_party/empty.html"; | 213 const char* emptyFile = "first_party/empty.html"; |
213 const char* nestedData = "first_party/nested-data.html"; | 214 const char* nestedData = "first_party/nested-data.html"; |
214 const char* nestedOriginA = "first_party/nested-originA.html"; | 215 const char* nestedOriginA = "first_party/nested-originA.html"; |
216 const char* nestedOriginSubA = "first_party/nested-originSubA.html"; | |
215 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA. html"; | 217 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA. html"; |
216 const char* nestedOriginAInOriginB = "first_party/nested-originA-in-originB. html"; | 218 const char* nestedOriginAInOriginB = "first_party/nested-originA-in-originB. html"; |
217 const char* nestedOriginB = "first_party/nested-originB.html"; | 219 const char* nestedOriginB = "first_party/nested-originB.html"; |
218 const char* nestedOriginBInOriginA = "first_party/nested-originB-in-originA. html"; | 220 const char* nestedOriginBInOriginA = "first_party/nested-originB-in-originA. html"; |
219 const char* nestedOriginBInOriginB = "first_party/nested-originB-in-originB. html"; | 221 const char* nestedOriginBInOriginB = "first_party/nested-originB-in-originB. html"; |
220 const char* nestedSrcDoc = "first_party/nested-srcdoc.html"; | 222 const char* nestedSrcDoc = "first_party/nested-srcdoc.html"; |
221 | 223 |
222 static KURL toOriginA(const char* file) | 224 static KURL toOriginA(const char* file) |
223 { | 225 { |
224 return toKURL(std::string(baseURLOriginA) + file); | 226 return toKURL(std::string(baseURLOriginA) + file); |
225 } | 227 } |
226 | 228 |
229 static KURL toOriginSubA(const char* file) | |
230 { | |
231 return toKURL(std::string(baseURLOriginSubA) + file); | |
232 } | |
233 | |
227 static KURL toOriginB(const char* file) | 234 static KURL toOriginB(const char* file) |
228 { | 235 { |
229 return toKURL(std::string(baseURLOriginB) + file); | 236 return toKURL(std::string(baseURLOriginB) + file); |
230 } | 237 } |
231 } | 238 } |
232 | 239 |
233 class WebDocumentFirstPartyTest : public ::testing::Test { | 240 class WebDocumentFirstPartyTest : public ::testing::Test { |
234 public: | 241 public: |
235 static void SetUpTestCase(); | 242 static void SetUpTestCase(); |
236 | 243 |
237 protected: | 244 protected: |
238 void load(const char*); | 245 void load(const char*); |
239 Document* topDocument() const; | 246 Document* topDocument() const; |
240 Document* nestedDocument() const; | 247 Document* nestedDocument() const; |
241 Document* nestedNestedDocument() const; | 248 Document* nestedNestedDocument() const; |
242 | 249 |
243 WebViewHelper m_webViewHelper; | 250 WebViewHelper m_webViewHelper; |
244 }; | 251 }; |
245 | 252 |
246 void WebDocumentFirstPartyTest::SetUpTestCase() | 253 void WebDocumentFirstPartyTest::SetUpTestCase() |
247 { | 254 { |
248 URLTestHelpers::registerMockedURLLoad(toOriginA(emptyFile), WebString::fromU TF8(emptyFile)); | 255 URLTestHelpers::registerMockedURLLoad(toOriginA(emptyFile), WebString::fromU TF8(emptyFile)); |
249 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedData), WebString::from UTF8(nestedData)); | 256 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedData), WebString::from UTF8(nestedData)); |
250 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginA), WebString::f romUTF8(nestedOriginA)); | 257 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginA), WebString::f romUTF8(nestedOriginA)); |
258 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginSubA), WebString ::fromUTF8(nestedOriginSubA)); | |
251 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginAInOriginA), Web String::fromUTF8(nestedOriginAInOriginA)); | 259 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginAInOriginA), Web String::fromUTF8(nestedOriginAInOriginA)); |
252 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginAInOriginB), Web String::fromUTF8(nestedOriginAInOriginB)); | 260 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginAInOriginB), Web String::fromUTF8(nestedOriginAInOriginB)); |
253 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginB), WebString::f romUTF8(nestedOriginB)); | 261 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginB), WebString::f romUTF8(nestedOriginB)); |
254 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginBInOriginA), Web String::fromUTF8(nestedOriginBInOriginA)); | 262 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginBInOriginA), Web String::fromUTF8(nestedOriginBInOriginA)); |
255 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginBInOriginB), Web String::fromUTF8(nestedOriginBInOriginB)); | 263 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedOriginBInOriginB), Web String::fromUTF8(nestedOriginBInOriginB)); |
256 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedSrcDoc), WebString::fr omUTF8(nestedSrcDoc)); | 264 URLTestHelpers::registerMockedURLLoad(toOriginA(nestedSrcDoc), WebString::fr omUTF8(nestedSrcDoc)); |
257 | 265 |
266 URLTestHelpers::registerMockedURLLoad(toOriginSubA(emptyFile), WebString::fr omUTF8(emptyFile)); | |
267 | |
258 URLTestHelpers::registerMockedURLLoad(toOriginB(emptyFile), WebString::fromU TF8(emptyFile)); | 268 URLTestHelpers::registerMockedURLLoad(toOriginB(emptyFile), WebString::fromU TF8(emptyFile)); |
259 URLTestHelpers::registerMockedURLLoad(toOriginB(nestedOriginA), WebString::f romUTF8(nestedOriginA)); | 269 URLTestHelpers::registerMockedURLLoad(toOriginB(nestedOriginA), WebString::f romUTF8(nestedOriginA)); |
260 URLTestHelpers::registerMockedURLLoad(toOriginB(nestedOriginB), WebString::f romUTF8(nestedOriginB)); | 270 URLTestHelpers::registerMockedURLLoad(toOriginB(nestedOriginB), WebString::f romUTF8(nestedOriginB)); |
261 } | 271 } |
262 | 272 |
263 void WebDocumentFirstPartyTest::load(const char* file) | 273 void WebDocumentFirstPartyTest::load(const char* file) |
264 { | 274 { |
265 m_webViewHelper.initializeAndLoad(std::string(baseURLOriginA) + file); | 275 m_webViewHelper.initializeAndLoad(std::string(baseURLOriginA) + file); |
266 } | 276 } |
267 | 277 |
(...skipping 29 matching lines...) Expand all Loading... | |
297 | 307 |
298 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | 308 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); |
299 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); | 309 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); |
300 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies() ); | 310 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies() ); |
301 | 311 |
302 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | 312 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); |
303 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); | 313 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); |
304 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies() ); | 314 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies() ); |
305 } | 315 } |
306 | 316 |
317 TEST_F(WebDocumentFirstPartyTest, NestedOriginSubA) | |
318 { | |
319 load(nestedOriginSubA); | |
320 | |
321 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
322 ASSERT_EQ(toOriginA(nestedOriginSubA), topDocument()->firstPartyForCookies() ); | |
323 ASSERT_EQ(toOriginA(nestedOriginSubA), nestedDocument()->firstPartyForCookie s()); | |
324 | |
325 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
326 ASSERT_EQ(toOriginA(nestedOriginSubA), topDocument()->firstPartyForCookies() ); | |
327 ASSERT_EQ(toOriginA(nestedOriginSubA), nestedDocument()->firstPartyForCookie s()); | |
328 } | |
329 | |
307 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginA) | 330 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginA) |
308 { | 331 { |
309 load(nestedOriginAInOriginA); | 332 load(nestedOriginAInOriginA); |
310 | 333 |
311 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | 334 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); |
312 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), topDocument()->firstPartyForCoo kies()); | 335 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), topDocument()->firstPartyForCoo kies()); |
313 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedDocument()->firstPartyFor Cookies()); | 336 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedDocument()->firstPartyFor Cookies()); |
314 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedNestedDocument()->firstPa rtyForCookies()); | 337 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedNestedDocument()->firstPa rtyForCookies()); |
315 | 338 |
316 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | 339 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 | 419 |
397 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | 420 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); |
398 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); | 421 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); |
399 ASSERT_EQ(toOriginA(nestedData), nestedDocument()->firstPartyForCookies()); | 422 ASSERT_EQ(toOriginA(nestedData), nestedDocument()->firstPartyForCookies()); |
400 | 423 |
401 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | 424 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); |
402 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); | 425 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); |
403 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies()); | 426 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies()); |
404 } | 427 } |
405 } | 428 } |
OLD | NEW |