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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 Document* WebDocumentFirstPartyTest::nestedNestedDocument() const | 288 Document* WebDocumentFirstPartyTest::nestedNestedDocument() const |
289 { | 289 { |
290 return toLocalFrame(m_webViewHelper.webViewImpl()->page()->mainFrame()->tree
().firstChild()->tree().firstChild())->document(); | 290 return toLocalFrame(m_webViewHelper.webViewImpl()->page()->mainFrame()->tree
().firstChild()->tree().firstChild())->document(); |
291 } | 291 } |
292 | 292 |
293 TEST_F(WebDocumentFirstPartyTest, Empty) | 293 TEST_F(WebDocumentFirstPartyTest, Empty) |
294 { | 294 { |
295 load(emptyFile); | 295 load(emptyFile); |
296 | 296 |
297 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
298 ASSERT_EQ(toOriginA(emptyFile), topDocument()->firstPartyForCookies()); | |
299 | |
300 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
301 ASSERT_EQ(toOriginA(emptyFile), topDocument()->firstPartyForCookies()); | 297 ASSERT_EQ(toOriginA(emptyFile), topDocument()->firstPartyForCookies()); |
302 } | 298 } |
303 | 299 |
304 TEST_F(WebDocumentFirstPartyTest, NestedOriginA) | 300 TEST_F(WebDocumentFirstPartyTest, NestedOriginA) |
305 { | 301 { |
306 load(nestedOriginA); | 302 load(nestedOriginA); |
307 | 303 |
308 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
309 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); | |
310 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies()
); | |
311 | |
312 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
313 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); | 304 ASSERT_EQ(toOriginA(nestedOriginA), topDocument()->firstPartyForCookies()); |
314 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies()
); | 305 ASSERT_EQ(toOriginA(nestedOriginA), nestedDocument()->firstPartyForCookies()
); |
315 } | 306 } |
316 | 307 |
317 TEST_F(WebDocumentFirstPartyTest, NestedOriginSubA) | 308 TEST_F(WebDocumentFirstPartyTest, NestedOriginSubA) |
318 { | 309 { |
319 load(nestedOriginSubA); | 310 load(nestedOriginSubA); |
320 | 311 |
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()
); | 312 ASSERT_EQ(toOriginA(nestedOriginSubA), topDocument()->firstPartyForCookies()
); |
327 ASSERT_EQ(toOriginA(nestedOriginSubA), nestedDocument()->firstPartyForCookie
s()); | 313 ASSERT_EQ(toOriginA(nestedOriginSubA), nestedDocument()->firstPartyForCookie
s()); |
328 } | 314 } |
329 | 315 |
330 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginA) | 316 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginA) |
331 { | 317 { |
332 load(nestedOriginAInOriginA); | 318 load(nestedOriginAInOriginA); |
333 | 319 |
334 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
335 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), topDocument()->firstPartyForCoo
kies()); | 320 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), topDocument()->firstPartyForCoo
kies()); |
336 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedDocument()->firstPartyFor
Cookies()); | 321 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedDocument()->firstPartyFor
Cookies()); |
337 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedNestedDocument()->firstPa
rtyForCookies()); | 322 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedNestedDocument()->firstPa
rtyForCookies()); |
338 | |
339 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
340 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), topDocument()->firstPartyForCoo
kies()); | |
341 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedDocument()->firstPartyFor
Cookies()); | |
342 ASSERT_EQ(toOriginA(nestedOriginAInOriginA), nestedNestedDocument()->firstPa
rtyForCookies()); | |
343 } | 323 } |
344 | 324 |
345 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginB) | 325 TEST_F(WebDocumentFirstPartyTest, NestedOriginAInOriginB) |
346 { | 326 { |
347 load(nestedOriginAInOriginB); | 327 load(nestedOriginAInOriginB); |
348 | 328 |
349 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
350 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), topDocument()->firstPartyForCoo
kies()); | |
351 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedDocument()->firstPartyFor
Cookies()); | |
352 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedNestedDocument()->firstPa
rtyForCookies()); | |
353 | |
354 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
355 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), topDocument()->firstPartyForCoo
kies()); | 329 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), topDocument()->firstPartyForCoo
kies()); |
356 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); | 330 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); |
357 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); | 331 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); |
358 } | 332 } |
359 | 333 |
360 TEST_F(WebDocumentFirstPartyTest, NestedOriginB) | 334 TEST_F(WebDocumentFirstPartyTest, NestedOriginB) |
361 { | 335 { |
362 load(nestedOriginB); | 336 load(nestedOriginB); |
363 | 337 |
364 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
365 ASSERT_EQ(toOriginA(nestedOriginB), topDocument()->firstPartyForCookies()); | |
366 ASSERT_EQ(toOriginA(nestedOriginB), nestedDocument()->firstPartyForCookies()
); | |
367 | |
368 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
369 ASSERT_EQ(toOriginA(nestedOriginB), topDocument()->firstPartyForCookies()); | 338 ASSERT_EQ(toOriginA(nestedOriginB), topDocument()->firstPartyForCookies()); |
370 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); | 339 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); |
371 } | 340 } |
372 | 341 |
373 TEST_F(WebDocumentFirstPartyTest, NestedOriginBInOriginA) | 342 TEST_F(WebDocumentFirstPartyTest, NestedOriginBInOriginA) |
374 { | 343 { |
375 load(nestedOriginBInOriginA); | 344 load(nestedOriginBInOriginA); |
376 | 345 |
377 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
378 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), topDocument()->firstPartyForCoo
kies()); | |
379 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), nestedDocument()->firstPartyFor
Cookies()); | |
380 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), nestedNestedDocument()->firstPa
rtyForCookies()); | |
381 | |
382 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
383 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), topDocument()->firstPartyForCoo
kies()); | 346 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), topDocument()->firstPartyForCoo
kies()); |
384 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), nestedDocument()->firstPartyFor
Cookies()); | 347 ASSERT_EQ(toOriginA(nestedOriginBInOriginA), nestedDocument()->firstPartyFor
Cookies()); |
385 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); | 348 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); |
386 } | 349 } |
387 | 350 |
388 TEST_F(WebDocumentFirstPartyTest, NestedOriginBInOriginB) | 351 TEST_F(WebDocumentFirstPartyTest, NestedOriginBInOriginB) |
389 { | 352 { |
390 load(nestedOriginBInOriginB); | 353 load(nestedOriginBInOriginB); |
391 | 354 |
392 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
393 ASSERT_EQ(toOriginA(nestedOriginBInOriginB), topDocument()->firstPartyForCoo
kies()); | |
394 ASSERT_EQ(toOriginA(nestedOriginBInOriginB), nestedDocument()->firstPartyFor
Cookies()); | |
395 ASSERT_EQ(toOriginA(nestedOriginBInOriginB), nestedNestedDocument()->firstPa
rtyForCookies()); | |
396 | |
397 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
398 ASSERT_EQ(toOriginA(nestedOriginBInOriginB), topDocument()->firstPartyForCoo
kies()); | 355 ASSERT_EQ(toOriginA(nestedOriginBInOriginB), topDocument()->firstPartyForCoo
kies()); |
399 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); | 356 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); |
400 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); | 357 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedNestedDocumen
t()->firstPartyForCookies()); |
401 } | 358 } |
402 | 359 |
403 TEST_F(WebDocumentFirstPartyTest, NestedSrcdoc) | 360 TEST_F(WebDocumentFirstPartyTest, NestedSrcdoc) |
404 { | 361 { |
405 load(nestedSrcDoc); | 362 load(nestedSrcDoc); |
406 | 363 |
407 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
408 ASSERT_EQ(toOriginA(nestedSrcDoc), topDocument()->firstPartyForCookies()); | |
409 ASSERT_EQ(toOriginA(nestedSrcDoc), nestedDocument()->firstPartyForCookies())
; | |
410 | |
411 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
412 ASSERT_EQ(toOriginA(nestedSrcDoc), topDocument()->firstPartyForCookies()); | 364 ASSERT_EQ(toOriginA(nestedSrcDoc), topDocument()->firstPartyForCookies()); |
413 ASSERT_EQ(toOriginA(nestedSrcDoc), nestedDocument()->firstPartyForCookies())
; | 365 ASSERT_EQ(toOriginA(nestedSrcDoc), nestedDocument()->firstPartyForCookies())
; |
414 } | 366 } |
415 | 367 |
416 TEST_F(WebDocumentFirstPartyTest, NestedData) | 368 TEST_F(WebDocumentFirstPartyTest, NestedData) |
417 { | 369 { |
418 load(nestedData); | 370 load(nestedData); |
419 | 371 |
420 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(false); | |
421 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); | |
422 ASSERT_EQ(toOriginA(nestedData), nestedDocument()->firstPartyForCookies()); | |
423 | |
424 RuntimeEnabledFeatures::setFirstPartyIncludesAncestorsEnabled(true); | |
425 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); | 372 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); |
426 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); | 373 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f
irstPartyForCookies()); |
427 } | 374 } |
| 375 |
428 } | 376 } |
OLD | NEW |