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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1460983002: Expose GetLastCommitedOrigin() on WebContents and use it in about:blank (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/frame_host/cross_site_transferring_request.h" 8 #include "content/browser/frame_host/cross_site_transferring_request.h"
9 #include "content/browser/frame_host/interstitial_page_impl.h" 9 #include "content/browser/frame_host/interstitial_page_impl.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 3364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 3375
3376 backend->AllowCertForHost(*cert, test_url.host(), 1); 3376 backend->AllowCertForHost(*cert, test_url.host(), 1);
3377 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3377 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3378 3378
3379 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", 3379 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type",
3380 RESOURCE_TYPE_MAIN_FRAME); 3380 RESOURCE_TYPE_MAIN_FRAME);
3381 3381
3382 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3382 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3383 } 3383 }
3384 3384
3385 // Test to simulate and validate frame origin properties namely, uniqueness and
3386 // inheritance.
3387 TEST_F(WebContentsImplTest, WebContentsOriginInfo) {
3388 // WebContent with non-standard URL has a unique origin.
3389 const GURL url_ab(url::kAboutBlankURL);
3390 const url::Origin origin_ab(url_ab);
3391 controller().LoadURL(url_ab, Referrer(), ui::PAGE_TRANSITION_TYPED,
3392 std::string());
3393
3394 FrameHostMsg_DidCommitProvisionalLoad_Params params1;
3395 int entry_id = controller().GetPendingEntry()->GetUniqueID();
3396 InitNavigateParams(&params1, 1, entry_id, true, url_ab,
3397 ui::PAGE_TRANSITION_TYPED);
3398 params1.origin = origin_ab;
3399 contents()->GetMainFrame()->SendNavigateWithParams(&params1);
3400 EXPECT_TRUE(contents()->GetLastCommittedOrigin().unique());
3401
3402 // An usual case where URL matches the Origin.
3403 const GURL url("http://www.google.com");
3404 const url::Origin origin(url);
3405 controller().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED,
3406 std::string());
3407
3408 FrameHostMsg_DidCommitProvisionalLoad_Params params2;
3409 entry_id = controller().GetPendingEntry()->GetUniqueID();
3410 InitNavigateParams(&params2, 1, entry_id, true, url,
3411 ui::PAGE_TRANSITION_TYPED);
3412 params2.origin = origin;
3413 contents()->GetMainFrame()->SendNavigateWithParams(&params2);
3414 EXPECT_TRUE(contents()->GetLastCommittedOrigin().IsSameOriginWith(origin));
3415
3416 // An 'about:blank' content inheriting origin from another content.
3417 // (Not sure if this test is correct/required)
3418 scoped_ptr<TestWebContents> contents2(
3419 static_cast<TestWebContents*>(CreateTestWebContents()));
3420 contents2->GetController().LoadURL(url_ab, Referrer(),
3421 ui::PAGE_TRANSITION_LINK, std::string());
3422
3423 FrameHostMsg_DidCommitProvisionalLoad_Params params3;
3424 entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID();
3425 InitNavigateParams(&params3, -1, 0, false, url_ab, ui::PAGE_TRANSITION_LINK);
3426 params3.origin = origin;
3427 contents2->GetMainFrame()->SendNavigateWithParams(&params3);
3428 EXPECT_TRUE(contents2->GetLastCommittedOrigin().IsSameOriginWith(
3429 contents()->GetLastCommittedOrigin()));
3430 }
3431
3385 } // namespace content 3432 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698