| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/lifetime/application_lifetime.h" | 35 #include "chrome/browser/lifetime/application_lifetime.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
| 38 #include "chrome/browser/ui/browser_commands.h" | 38 #include "chrome/browser/ui/browser_commands.h" |
| 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 40 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
| 44 #include "chrome/test/base/in_process_browser_test.h" | 44 #include "chrome/test/base/in_process_browser_test.h" |
| 45 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
| 45 #include "chrome/test/base/ui_test_utils.h" | 46 #include "chrome/test/base/ui_test_utils.h" |
| 46 #include "components/app_modal/javascript_app_modal_dialog.h" | 47 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 47 #include "components/app_modal/native_app_modal_dialog.h" | 48 #include "components/app_modal/native_app_modal_dialog.h" |
| 48 #include "components/prefs/pref_service.h" | 49 #include "components/prefs/pref_service.h" |
| 49 #include "content/public/browser/child_process_data.h" | 50 #include "content/public/browser/child_process_data.h" |
| 50 #include "content/public/browser/content_browser_client.h" | 51 #include "content/public/browser/content_browser_client.h" |
| 51 #include "content/public/browser/devtools_agent_host.h" | 52 #include "content/public/browser/devtools_agent_host.h" |
| 52 #include "content/public/browser/notification_registrar.h" | 53 #include "content/public/browser/notification_registrar.h" |
| 53 #include "content/public/browser/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
| 54 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
| 55 #include "content/public/browser/render_widget_host.h" | 56 #include "content/public/browser/render_widget_host.h" |
| 56 #include "content/public/browser/render_widget_host_view.h" | 57 #include "content/public/browser/render_widget_host_view.h" |
| 58 #include "content/public/browser/url_data_source.h" |
| 57 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 60 #include "content/public/browser/web_ui_controller.h" |
| 58 #include "content/public/browser/worker_service.h" | 61 #include "content/public/browser/worker_service.h" |
| 59 #include "content/public/browser/worker_service_observer.h" | 62 #include "content/public/browser/worker_service_observer.h" |
| 60 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
| 61 #include "content/public/test/browser_test_utils.h" | 64 #include "content/public/test/browser_test_utils.h" |
| 62 #include "content/public/test/test_navigation_observer.h" | 65 #include "content/public/test/test_navigation_observer.h" |
| 63 #include "extensions/browser/extension_registry.h" | 66 #include "extensions/browser/extension_registry.h" |
| 64 #include "extensions/browser/extension_system.h" | 67 #include "extensions/browser/extension_system.h" |
| 65 #include "extensions/browser/notification_types.h" | 68 #include "extensions/browser/notification_types.h" |
| 66 #include "extensions/common/switches.h" | 69 #include "extensions/common/switches.h" |
| 67 #include "extensions/common/value_builder.h" | 70 #include "extensions/common/value_builder.h" |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 void SetUpCommandLine(base::CommandLine* command_line) override { | 1355 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 1353 command_line->AppendSwitch(switches::kEnableNetworkInformation); | 1356 command_line->AppendSwitch(switches::kEnableNetworkInformation); |
| 1354 command_line->AppendSwitch( | 1357 command_line->AppendSwitch( |
| 1355 switches::kEnableExperimentalWebPlatformFeatures); | 1358 switches::kEnableExperimentalWebPlatformFeatures); |
| 1356 } | 1359 } |
| 1357 }; | 1360 }; |
| 1358 | 1361 |
| 1359 IN_PROC_BROWSER_TEST_F(DevToolsNetInfoTest, EmulateNetworkConditions) { | 1362 IN_PROC_BROWSER_TEST_F(DevToolsNetInfoTest, EmulateNetworkConditions) { |
| 1360 RunTest("testEmulateNetworkConditions", kEmulateNetworkConditionsPage); | 1363 RunTest("testEmulateNetworkConditions", kEmulateNetworkConditionsPage); |
| 1361 } | 1364 } |
| 1365 |
| 1366 class StaticURLDataSource : public content::URLDataSource { |
| 1367 public: |
| 1368 StaticURLDataSource(const std::string& source, const std::string& content) |
| 1369 : source_(source), content_(content) {} |
| 1370 |
| 1371 std::string GetSource() const override { return source_; } |
| 1372 void StartDataRequest(const std::string& path, |
| 1373 int render_process_id, |
| 1374 int render_frame_id, |
| 1375 const GotDataCallback& callback) override { |
| 1376 std::string data(content_); |
| 1377 callback.Run(base::RefCountedString::TakeString(&data)); |
| 1378 } |
| 1379 std::string GetMimeType(const std::string& path) const override { |
| 1380 return "text/html"; |
| 1381 } |
| 1382 bool ShouldAddContentSecurityPolicy() const override { return false; } |
| 1383 |
| 1384 private: |
| 1385 std::string source_; |
| 1386 std::string content_; |
| 1387 DISALLOW_COPY_AND_ASSIGN(StaticURLDataSource); |
| 1388 }; |
| 1389 |
| 1390 class MockWebUIProvider |
| 1391 : public TestChromeWebUIControllerFactory::WebUIProvider { |
| 1392 public: |
| 1393 MockWebUIProvider(const std::string& source, const std::string& content) |
| 1394 : source_(source), content_(content) {} |
| 1395 |
| 1396 content::WebUIController* NewWebUI(content::WebUI* web_ui, |
| 1397 const GURL& url) override { |
| 1398 content::URLDataSource::Add(Profile::FromWebUI(web_ui), |
| 1399 new StaticURLDataSource(source_, content_)); |
| 1400 return new content::WebUIController(web_ui); |
| 1401 } |
| 1402 |
| 1403 private: |
| 1404 std::string source_; |
| 1405 std::string content_; |
| 1406 DISALLOW_COPY_AND_ASSIGN(MockWebUIProvider); |
| 1407 }; |
| 1408 |
| 1409 // This tests checks that window is correctly initialized when DevTools is |
| 1410 // opened while navigation through history with forward and back actions. |
| 1411 // (crbug.com/627407) |
| 1412 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, |
| 1413 TestWindowInitializedOnNavigateBack) { |
| 1414 TestChromeWebUIControllerFactory test_factory; |
| 1415 MockWebUIProvider mock_provider("dummyurl", |
| 1416 "<script>\n" |
| 1417 " window.abc = 239;\n" |
| 1418 " console.log(abc);\n" |
| 1419 "</script>"); |
| 1420 test_factory.AddFactoryOverride(GURL("chrome://dummyurl").host(), |
| 1421 &mock_provider); |
| 1422 content::WebUIControllerFactory::RegisterFactory(&test_factory); |
| 1423 |
| 1424 ui_test_utils::NavigateToURL(browser(), GURL("chrome://dummyurl")); |
| 1425 DevToolsWindow* window = |
| 1426 DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), true); |
| 1427 chrome::DuplicateTab(browser()); |
| 1428 chrome::SelectPreviousTab(browser()); |
| 1429 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 1430 chrome::GoBack(browser(), CURRENT_TAB); |
| 1431 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
| 1432 |
| 1433 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 1434 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 1435 } |
| OLD | NEW |