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

Side by Side Diff: chrome/browser/task_manager/providers/web_contents/subframe_task_browsertest.cc

Issue 2946113002: Use FrameIsAd to decide whether to isolate a frame in TopDocumentIsolation mode. (Closed)
Patch Set: Addressing CR feedback from jkarlin@ and creis@. Created 3 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/scoped_feature_list.h"
9 #include "chrome/browser/task_manager/mock_web_contents_task_manager.h" 8 #include "chrome/browser/task_manager/mock_web_contents_task_manager.h"
10 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
13 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/render_widget_host.h" 15 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 16 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/common/content_features.h" 17 #include "content/public/common/content_features.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 unresponsive_task == subframe_task_2); 197 unresponsive_task == subframe_task_2);
199 } 198 }
200 199
201 // A test for top document isolation and how subframes show up in the task 200 // A test for top document isolation and how subframes show up in the task
202 // manager as SubframeTasks. 201 // manager as SubframeTasks.
203 class SubframeTaskTDIBrowserTest : public InProcessBrowserTest { 202 class SubframeTaskTDIBrowserTest : public InProcessBrowserTest {
204 public: 203 public:
205 SubframeTaskTDIBrowserTest() {} 204 SubframeTaskTDIBrowserTest() {}
206 ~SubframeTaskTDIBrowserTest() override {} 205 ~SubframeTaskTDIBrowserTest() override {}
207 206
207 void SetUpCommandLine(base::CommandLine* command_line) override {
208 InProcessBrowserTest::SetUpCommandLine(command_line);
209 content::EnableTopDocumentIsolationForTesting(command_line);
210 }
211
208 void SetUpOnMainThread() override { 212 void SetUpOnMainThread() override {
209 scoped_feature_list_.InitAndEnableFeature(features::kTopDocumentIsolation);
210 host_resolver()->AddRule("*", "127.0.0.1"); 213 host_resolver()->AddRule("*", "127.0.0.1");
211 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 214 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
212 content::SetupCrossSiteRedirector(embedded_test_server()); 215 content::SetupCrossSiteRedirector(embedded_test_server());
213 embedded_test_server()->StartAcceptingConnections(); 216 embedded_test_server()->StartAcceptingConnections();
214 } 217 }
215 218
216 void NavigateTo(const char* page_url) const { 219 void NavigateTo(const char* page_url) const {
217 ui_test_utils::NavigateToURL(browser(), 220 ui_test_utils::NavigateToURL(browser(),
218 embedded_test_server()->GetURL(page_url)); 221 embedded_test_server()->GetURL(page_url));
219 } 222 }
220 223
221 private: 224 private:
222 base::test::ScopedFeatureList scoped_feature_list_;
223
224 DISALLOW_COPY_AND_ASSIGN(SubframeTaskTDIBrowserTest); 225 DISALLOW_COPY_AND_ASSIGN(SubframeTaskTDIBrowserTest);
225 }; 226 };
226 227
227 // Makes sure that subframe row gets updated with the new title when the main 228 // Makes sure that subframe row gets updated with the new title when the main
228 // frame's title changes. 229 // frame's title changes.
229 IN_PROC_BROWSER_TEST_F(SubframeTaskTDIBrowserTest, 230 IN_PROC_BROWSER_TEST_F(SubframeTaskTDIBrowserTest,
230 SubframeRowGetsUpdatedParentPageTitle) { 231 SubframeRowGetsUpdatedParentPageTitle) {
231 if (content::AreAllSitesIsolatedForTesting()) { 232 if (content::AreAllSitesIsolatedForTesting()) {
232 // If full site isolation is turned on, it supersedes top document 233 // If full site isolation is turned on, it supersedes top document
233 // isolation, so bail if it is. 234 // isolation, so bail if it is.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 base::UTF8ToUTF16(new_title)); 266 base::UTF8ToUTF16(new_title));
266 EXPECT_TRUE(ExecuteScript(web_contents, script)); 267 EXPECT_TRUE(ExecuteScript(web_contents, script));
267 base::string16 actual_title = title_watcher.WaitAndGetTitle(); 268 base::string16 actual_title = title_watcher.WaitAndGetTitle();
268 EXPECT_EQ(new_title, base::UTF16ToUTF8(actual_title)); 269 EXPECT_EQ(new_title, base::UTF16ToUTF8(actual_title));
269 270
270 EXPECT_EQ(PrefixExpectedTabTitle(new_title), main_task->title()); 271 EXPECT_EQ(PrefixExpectedTabTitle(new_title), main_task->title());
271 EXPECT_EQ(PrefixExpectedTDIRowTitle(new_title), tdi_task->title()); 272 EXPECT_EQ(PrefixExpectedTDIRowTitle(new_title), tdi_task->title());
272 } 273 }
273 274
274 } // namespace task_manager 275 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698