Chromium Code Reviews| 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 #include <vector> | |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/location.h" | 15 #include "base/location.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/extensions/extension_service.h" | 33 #include "chrome/browser/extensions/extension_service.h" |
| 33 #include "chrome/browser/extensions/test_extension_dir.h" | 34 #include "chrome/browser/extensions/test_extension_dir.h" |
| 34 #include "chrome/browser/extensions/unpacked_installer.h" | 35 #include "chrome/browser/extensions/unpacked_installer.h" |
| 35 #include "chrome/browser/lifetime/application_lifetime.h" | 36 #include "chrome/browser/lifetime/application_lifetime.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
| 38 #include "chrome/browser/ui/browser_commands.h" | 39 #include "chrome/browser/ui/browser_commands.h" |
| 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 40 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/extensions/extension_process_policy.h" | |
| 42 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
| 44 #include "chrome/test/base/in_process_browser_test.h" | 46 #include "chrome/test/base/in_process_browser_test.h" |
| 45 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" | 47 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
| 46 #include "chrome/test/base/ui_test_utils.h" | 48 #include "chrome/test/base/ui_test_utils.h" |
| 47 #include "components/app_modal/javascript_app_modal_dialog.h" | 49 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 48 #include "components/app_modal/native_app_modal_dialog.h" | 50 #include "components/app_modal/native_app_modal_dialog.h" |
| 49 #include "components/prefs/pref_service.h" | 51 #include "components/prefs/pref_service.h" |
| 50 #include "content/public/browser/child_process_data.h" | 52 #include "content/public/browser/child_process_data.h" |
| 51 #include "content/public/browser/content_browser_client.h" | 53 #include "content/public/browser/content_browser_client.h" |
| 52 #include "content/public/browser/devtools_agent_host.h" | 54 #include "content/public/browser/devtools_agent_host.h" |
| 53 #include "content/public/browser/notification_registrar.h" | 55 #include "content/public/browser/notification_registrar.h" |
| 54 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
| 57 #include "content/public/browser/render_frame_host.h" | |
| 55 #include "content/public/browser/render_view_host.h" | 58 #include "content/public/browser/render_view_host.h" |
| 56 #include "content/public/browser/render_widget_host.h" | 59 #include "content/public/browser/render_widget_host.h" |
| 57 #include "content/public/browser/render_widget_host_view.h" | 60 #include "content/public/browser/render_widget_host_view.h" |
| 58 #include "content/public/browser/url_data_source.h" | 61 #include "content/public/browser/url_data_source.h" |
| 59 #include "content/public/browser/web_contents.h" | 62 #include "content/public/browser/web_contents.h" |
| 60 #include "content/public/browser/web_ui_controller.h" | 63 #include "content/public/browser/web_ui_controller.h" |
| 61 #include "content/public/browser/worker_service.h" | 64 #include "content/public/browser/worker_service.h" |
| 62 #include "content/public/browser/worker_service_observer.h" | 65 #include "content/public/browser/worker_service_observer.h" |
| 63 #include "content/public/common/content_switches.h" | 66 #include "content/public/common/content_switches.h" |
| 67 #include "content/public/common/url_constants.h" | |
| 64 #include "content/public/test/browser_test_utils.h" | 68 #include "content/public/test/browser_test_utils.h" |
| 65 #include "content/public/test/test_navigation_observer.h" | 69 #include "content/public/test/test_navigation_observer.h" |
| 66 #include "extensions/browser/extension_registry.h" | 70 #include "extensions/browser/extension_registry.h" |
| 67 #include "extensions/browser/extension_registry_observer.h" | 71 #include "extensions/browser/extension_registry_observer.h" |
| 68 #include "extensions/browser/extension_system.h" | 72 #include "extensions/browser/extension_system.h" |
| 69 #include "extensions/browser/notification_types.h" | 73 #include "extensions/browser/notification_types.h" |
| 70 #include "extensions/browser/test_extension_registry_observer.h" | 74 #include "extensions/browser/test_extension_registry_observer.h" |
| 71 #include "extensions/common/switches.h" | 75 #include "extensions/common/switches.h" |
| 72 #include "extensions/common/value_builder.h" | 76 #include "extensions/common/value_builder.h" |
| 73 #include "net/dns/mock_host_resolver.h" | 77 #include "net/dns/mock_host_resolver.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 extensions::TestExtensionRegistryObserver observer(registry); | 498 extensions::TestExtensionRegistryObserver observer(registry); |
| 495 extensions::UnpackedInstaller::Create(service)->Load(path); | 499 extensions::UnpackedInstaller::Create(service)->Load(path); |
| 496 observer.WaitForExtensionLoaded(); | 500 observer.WaitForExtensionLoaded(); |
| 497 | 501 |
| 498 if (!WaitForExtensionViewsToLoad()) | 502 if (!WaitForExtensionViewsToLoad()) |
| 499 return nullptr; | 503 return nullptr; |
| 500 | 504 |
| 501 return GetExtensionByPath(registry->enabled_extensions(), path); | 505 return GetExtensionByPath(registry->enabled_extensions(), path); |
| 502 } | 506 } |
| 503 | 507 |
| 508 // Loads a dynamically generated extension populated with a bunch of test | |
| 509 // pages. |name| is the extension name to use in the manifest. | |
| 510 // |devtools_page|, if non-empty, indicates which test page should be be | |
| 511 // listed as a devtools_page in the manifest. If |devtools_page| is empty, a | |
| 512 // non-devtools extension is created instead. |panel_iframe_src| controls the | |
| 513 // src= attribute of the <iframe> element in the 'panel.html' test page. | |
| 514 const Extension* LoadExtensionForTest(const std::string& name, | |
| 515 const std::string& devtools_page, | |
| 516 const std::string& panel_iframe_src) { | |
| 517 test_extension_dirs_.push_back( | |
| 518 base::MakeUnique<extensions::TestExtensionDir>()); | |
| 519 extensions::TestExtensionDir* dir = test_extension_dirs_.back().get(); | |
| 520 | |
| 521 extensions::DictionaryBuilder manifest; | |
| 522 manifest.Set("name", name) | |
| 523 .Set("version", "1") | |
| 524 .Set("manifest_version", 2) | |
| 525 // simple_test_page.html is currently the only page referenced outside | |
| 526 // of its own extension in the tests | |
| 527 .Set("web_accessible_resources", | |
| 528 extensions::ListBuilder().Append("simple_test_page.html").Build()); | |
| 529 if (!devtools_page.empty()) { | |
| 530 manifest.Set("devtools_page", devtools_page); | |
| 531 } | |
| 532 | |
| 533 dir->WriteManifest(manifest.ToJSON()); | |
| 534 | |
| 535 GURL http_popup_url = | |
| 536 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 537 | |
| 538 dir->WriteFile(FILE_PATH_LITERAL("web_devtools_page.html"), | |
| 539 "<html><head></head><body><iframe src='" + | |
| 540 http_popup_url.spec() + "'></iframe></body></html>"); | |
| 541 | |
| 542 dir->WriteFile(FILE_PATH_LITERAL("simple_devtools_page.html"), | |
| 543 "<html><head></head><body></body></html>"); | |
| 544 | |
| 545 dir->WriteFile( | |
| 546 FILE_PATH_LITERAL("panel_devtools_page.html"), | |
| 547 "<html><head><script " | |
| 548 "src='panel_devtools_page.js'></script></head><body></body></html>"); | |
| 549 | |
| 550 dir->WriteFile( | |
| 551 FILE_PATH_LITERAL("panel_devtools_page.js"), | |
| 552 "chrome.devtools.panels.create('iframe_panel',\n" | |
| 553 " null,\n" | |
| 554 " 'panel.html',\n" | |
| 555 " function(panel) {\n" | |
| 556 " " | |
| 557 "chrome.devtools.inspectedWindow.eval('console.log(" | |
| 558 "\"PASS\")');\n" | |
| 559 " }\n" | |
| 560 ");\n" | |
| 561 "chrome.devtools.panels.elements.createSidebarPane('iframe_pane',\n" | |
| 562 "function(sidebar) {\n" | |
| 563 "chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" | |
| 564 "sidebar.setPage('panel.html');\n" | |
| 565 "});\n"); | |
| 566 | |
| 567 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), | |
| 568 "<html><body><iframe src='" + panel_iframe_src + | |
| 569 "'></iframe></body></html>"); | |
| 570 | |
| 571 dir->WriteFile(FILE_PATH_LITERAL("simple_test_page.html"), | |
| 572 "<html><head></head><body>This is a test</body></html>"); | |
| 573 | |
| 574 GURL about_blank_url = GURL(url::kAboutBlankURL); | |
| 575 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); | |
| 576 GURL data_url = GURL("data:text/html,foo"); | |
| 577 | |
| 578 dir->WriteFile(FILE_PATH_LITERAL("renavigation_test_page.html"), | |
| 579 "<html><body><iframe src='" + about_blank_url.spec() + | |
| 580 "'></iframe><iframe src='" + data_url.spec() + | |
| 581 "'></iframe><iframe src='" + web_url.spec() + | |
| 582 "'></iframe></body></html>"); | |
| 583 | |
| 584 // Install the extension. | |
| 585 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); | |
| 586 return extension; | |
| 587 } | |
| 588 | |
| 504 private: | 589 private: |
| 505 const Extension* GetExtensionByPath( | 590 const Extension* GetExtensionByPath( |
| 506 const extensions::ExtensionSet& extensions, | 591 const extensions::ExtensionSet& extensions, |
| 507 const base::FilePath& path) { | 592 const base::FilePath& path) { |
| 508 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); | 593 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); |
| 509 EXPECT_TRUE(!extension_path.empty()); | 594 EXPECT_TRUE(!extension_path.empty()); |
| 510 for (const scoped_refptr<const Extension>& extension : extensions) { | 595 for (const scoped_refptr<const Extension>& extension : extensions) { |
| 511 if (extension->path() == extension_path) { | 596 if (extension->path() == extension_path) { |
| 512 return extension.get(); | 597 return extension.get(); |
| 513 } | 598 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 } | 631 } |
| 547 | 632 |
| 548 void Observe(int type, | 633 void Observe(int type, |
| 549 const content::NotificationSource& source, | 634 const content::NotificationSource& source, |
| 550 const content::NotificationDetails& details) override { | 635 const content::NotificationDetails& details) override { |
| 551 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, | 636 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
| 552 type); | 637 type); |
| 553 base::MessageLoopForUI::current()->QuitWhenIdle(); | 638 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 554 } | 639 } |
| 555 | 640 |
| 641 std::vector<std::unique_ptr<extensions::TestExtensionDir>> | |
| 642 test_extension_dirs_; | |
| 556 base::FilePath test_extensions_dir_; | 643 base::FilePath test_extensions_dir_; |
| 557 }; | 644 }; |
| 558 | 645 |
| 559 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { | 646 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { |
| 560 public: | 647 public: |
| 561 void SetUpCommandLine(base::CommandLine* command_line) override { | 648 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 562 command_line->AppendSwitch( | 649 command_line->AppendSwitch( |
| 563 extensions::switches::kEnableExperimentalExtensionApis); | 650 extensions::switches::kEnableExperimentalExtensionApis); |
| 564 } | 651 } |
| 565 }; | 652 }; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 kDebuggerTestPage); | 1012 kDebuggerTestPage); |
| 926 } | 1013 } |
| 927 | 1014 |
| 928 // Tests that chrome.devtools extension is correctly exposed. | 1015 // Tests that chrome.devtools extension is correctly exposed. |
| 929 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 1016 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 930 TestDevToolsExtensionAPI) { | 1017 TestDevToolsExtensionAPI) { |
| 931 LoadExtension("devtools_extension"); | 1018 LoadExtension("devtools_extension"); |
| 932 RunTest("waitForTestResultsInConsole", std::string()); | 1019 RunTest("waitForTestResultsInConsole", std::string()); |
| 933 } | 1020 } |
| 934 | 1021 |
| 935 // Tests a chrome.devtools extension panel that embeds an http:// iframe. | 1022 // Tests that http Iframes within the visible devtools panel for the devtools |
| 936 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionWithHttpIframe) { | 1023 // extension are rendered in their own processes and not in the devtools process |
| 937 ASSERT_TRUE(embedded_test_server()->Start()); | 1024 // or the extension's process. This is tested because this is one of the |
| 938 | 1025 // extension pages with devtools access |
| 939 // Our extension must load an URL from the test server, whose port is only | 1026 // (https://developer.chrome.com/extensions/devtools). Also tests that data |
| 940 // known at runtime. So, to embed the URL, we must dynamically generate the | 1027 // URLs and about blank URLs are rendered in the devtools process, unless an |
| 941 // extension, rather than loading it from static content. | 1028 // OOPIF is navigated to about:blank, in which case it does not end up back in |
| 942 std::unique_ptr<extensions::TestExtensionDir> dir( | 1029 // the devtools process. Also tests that when a web IFrame is navigated back to |
| 943 new extensions::TestExtensionDir()); | 1030 // a devtools extension page, it gets put back in the devtools process. |
| 944 | 1031 // BUG=crbug.com/570483 |
|
ncarter (slow)
2017/03/20 17:22:12
BUG= -> https://
davidsac (gone - try alexmos)
2017/03/20 18:25:57
Done.
| |
| 945 extensions::DictionaryBuilder manifest; | 1032 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 946 dir->WriteManifest(extensions::DictionaryBuilder() | 1033 HttpIframeInDevToolsExtensionPanel) { |
| 947 .Set("name", "Devtools Panel w/ HTTP Iframe") | 1034 ASSERT_TRUE(embedded_test_server()->Start()); |
| 948 .Set("version", "1") | 1035 |
| 949 .Set("manifest_version", 2) | 1036 // Install the dynamically-generated extension. |
| 950 .Set("devtools_page", "devtools.html") | 1037 const Extension* extension = |
| 951 .ToJSON()); | 1038 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", |
| 952 | 1039 "/renavigation_test_page.html"); |
| 953 dir->WriteFile( | |
| 954 FILE_PATH_LITERAL("devtools.html"), | |
| 955 "<html><head><script src='devtools.js'></script></head></html>"); | |
| 956 | |
| 957 dir->WriteFile( | |
| 958 FILE_PATH_LITERAL("devtools.js"), | |
| 959 "chrome.devtools.panels.create('iframe_panel',\n" | |
| 960 " null,\n" | |
| 961 " 'panel.html',\n" | |
| 962 " function(panel) {\n" | |
| 963 " chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" | |
| 964 " }\n" | |
| 965 ");\n"); | |
| 966 | |
| 967 GURL http_iframe = | |
| 968 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 969 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), | |
| 970 "<html><body>Extension panel.<iframe src='" + | |
| 971 http_iframe.spec() + "'></iframe>"); | |
| 972 | |
| 973 // Install the extension. | |
| 974 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); | |
| 975 ASSERT_TRUE(extension); | 1040 ASSERT_TRUE(extension); |
| 976 | 1041 |
| 977 // Open a devtools window. | |
| 978 OpenDevToolsWindow(kDebuggerTestPage, false); | 1042 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 979 | 1043 |
| 980 // Wait for the panel extension to finish loading -- it'll output 'PASS' | 1044 // Wait for the panel extension to finish loading -- it'll output 'PASS' |
| 981 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | 1045 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 982 RunTestFunction(window_, "waitForTestResultsInConsole"); | 1046 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 983 | 1047 |
| 984 // Now that we know the panel is loaded, switch to it. We'll wait until we | 1048 // Now that we know the panel is loaded, switch to it. |
| 985 // see a 'DONE' message sent from popup_iframe.html, indicating that it | 1049 SwitchToExtensionPanel(window_, extension, "iframe_panel"); |
| 1050 content::WaitForLoadStop(main_web_contents()); | |
| 1051 | |
| 1052 std::vector<content::RenderFrameHost*> rfhs = | |
| 1053 main_web_contents()->GetAllFrames(); | |
| 1054 EXPECT_EQ(7U, rfhs.size()); | |
| 1055 | |
| 1056 content::RenderFrameHost* main_devtools_rfh = | |
| 1057 main_web_contents()->GetMainFrame(); | |
| 1058 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1059 ChildFrameAt(main_devtools_rfh, 0); | |
| 1060 content::RenderFrameHost* devtools_panel_extension_rfh = | |
| 1061 ChildFrameAt(main_devtools_rfh, 1); | |
| 1062 content::RenderFrameHost* test_frame_rfh = | |
| 1063 ChildFrameAt(devtools_panel_extension_rfh, 0); | |
| 1064 content::RenderFrameHost* about_blank_frame_rfh = | |
| 1065 ChildFrameAt(test_frame_rfh, 0); | |
| 1066 content::RenderFrameHost* data_frame_rfh = ChildFrameAt(test_frame_rfh, 1); | |
| 1067 content::RenderFrameHost* about_blank_http_iframe_rfh = | |
| 1068 ChildFrameAt(test_frame_rfh, 2); | |
| 1069 | |
| 1070 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); | |
| 1071 GURL about_blank_url = GURL(url::kAboutBlankURL); | |
| 1072 GURL data_url = GURL("data:text/html,foo"); | |
| 1073 | |
| 1074 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1075 content::kChromeDevToolsScheme)); | |
| 1076 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1077 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1078 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1079 devtools_panel_extension_rfh->GetLastCommittedURL()); | |
| 1080 EXPECT_EQ(extension->GetResourceURL("/renavigation_test_page.html"), | |
| 1081 test_frame_rfh->GetLastCommittedURL()); | |
| 1082 EXPECT_EQ(about_blank_url, about_blank_frame_rfh->GetLastCommittedURL()); | |
| 1083 EXPECT_EQ(data_url, data_frame_rfh->GetLastCommittedURL()); | |
| 1084 EXPECT_EQ(web_url, about_blank_http_iframe_rfh->GetLastCommittedURL()); | |
| 1085 | |
| 1086 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1087 content::kChromeDevToolsScheme)); | |
| 1088 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1089 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1090 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1091 devtools_panel_extension_rfh->GetSiteInstance()); | |
| 1092 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1093 test_frame_rfh->GetSiteInstance()); | |
| 1094 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1095 about_blank_frame_rfh->GetSiteInstance()); | |
| 1096 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1097 data_frame_rfh->GetSiteInstance()); | |
| 1098 EXPECT_EQ( | |
| 1099 web_url.host(), | |
| 1100 about_blank_http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1101 | |
| 1102 // Check that if an OOPIF navigates itself to about:blank, it stays an OOPIF. | |
| 1103 | |
| 1104 std::string about_blank_javascript = | |
| 1105 "location.href='" + about_blank_url.spec() + "';"; | |
| 1106 | |
| 1107 content::TestNavigationManager web_about_blank_manager(main_web_contents(), | |
| 1108 about_blank_url); | |
| 1109 | |
| 1110 ASSERT_TRUE(content::ExecuteScript(about_blank_http_iframe_rfh, | |
| 1111 about_blank_javascript)); | |
| 1112 | |
| 1113 web_about_blank_manager.WaitForNavigationFinished(); | |
| 1114 | |
| 1115 EXPECT_EQ(about_blank_url, | |
| 1116 about_blank_http_iframe_rfh->GetLastCommittedURL()); | |
| 1117 EXPECT_EQ( | |
| 1118 web_url.host(), | |
| 1119 about_blank_http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1120 | |
| 1121 // Check that when a web IFrame is navigated back to a devtools extension | |
| 1122 // page, it gets put back in the devtools process. | |
| 1123 | |
| 1124 GURL extension_simple_url = | |
| 1125 extension->GetResourceURL("/simple_test_page.html"); | |
| 1126 std::string renavigation_javascript = | |
| 1127 "location.href='" + extension_simple_url.spec() + "';"; | |
| 1128 | |
| 1129 content::TestNavigationManager renavigation_manager(main_web_contents(), | |
| 1130 extension_simple_url); | |
| 1131 | |
| 1132 ASSERT_TRUE(content::ExecuteScript(about_blank_http_iframe_rfh, | |
| 1133 renavigation_javascript)); | |
| 1134 | |
| 1135 renavigation_manager.WaitForNavigationFinished(); | |
| 1136 | |
| 1137 // The old RFH is no longer valid after the renavigation, so we must get the | |
| 1138 // new one. | |
| 1139 content::RenderFrameHost* extension_simple_frame_rfh = | |
| 1140 ChildFrameAt(test_frame_rfh, 2); | |
| 1141 | |
| 1142 EXPECT_EQ(extension_simple_url, | |
| 1143 extension_simple_frame_rfh->GetLastCommittedURL()); | |
| 1144 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1145 extension_simple_frame_rfh->GetSiteInstance()); | |
| 1146 } | |
| 1147 | |
| 1148 // Tests that http Iframes within the sidebar pane page for the devtools | |
| 1149 // extension that is visible in the elements panel are rendered in their own | |
| 1150 // processes and not in the devtools process or the extension's process. This | |
| 1151 // is tested because this is one of the extension pages with devtools access | |
| 1152 // (https://developer.chrome.com/extensions/devtools). BUG=crbug.com/570483 | |
|
ncarter (slow)
2017/03/20 17:22:12
"BUG=crbug.com/570383" -> "https://crbug.com/57038
davidsac (gone - try alexmos)
2017/03/20 18:25:57
Done.
| |
| 1153 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1154 HttpIframeInDevToolsExtensionSideBarPane) { | |
| 1155 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1156 | |
| 1157 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); | |
| 1158 | |
| 1159 // Install the dynamically-generated extension. | |
| 1160 const Extension* extension = LoadExtensionForTest( | |
| 1161 "Devtools Extension", "panel_devtools_page.html", web_url.spec()); | |
| 1162 ASSERT_TRUE(extension); | |
| 1163 | |
| 1164 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1165 | |
| 1166 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1167 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1168 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1169 | |
| 1170 // Now that we know the panel is loaded, switch to it. | |
| 1171 content::TestNavigationManager web_manager(main_web_contents(), web_url); | |
| 1172 SwitchToPanel(window_, "elements"); | |
| 1173 // This is a bit of a hack to switch to the sidebar pane in the elements panel | |
| 1174 // that the Iframe has been added to. | |
| 1175 SwitchToPanel(window_, "iframe_pane"); | |
| 1176 web_manager.WaitForNavigationFinished(); | |
| 1177 | |
| 1178 std::vector<content::RenderFrameHost*> rfhs = | |
| 1179 main_web_contents()->GetAllFrames(); | |
| 1180 EXPECT_EQ(4U, rfhs.size()); | |
| 1181 | |
| 1182 content::RenderFrameHost* main_devtools_rfh = | |
| 1183 main_web_contents()->GetMainFrame(); | |
| 1184 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1185 ChildFrameAt(main_devtools_rfh, 0); | |
| 1186 content::RenderFrameHost* devtools_sidebar_pane_extension_rfh = | |
| 1187 ChildFrameAt(main_devtools_rfh, 1); | |
| 1188 content::RenderFrameHost* http_iframe_rfh = | |
| 1189 ChildFrameAt(devtools_sidebar_pane_extension_rfh, 0); | |
| 1190 | |
| 1191 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1192 content::kChromeDevToolsScheme)); | |
| 1193 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1194 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1195 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1196 devtools_sidebar_pane_extension_rfh->GetLastCommittedURL()); | |
| 1197 EXPECT_EQ(web_url, http_iframe_rfh->GetLastCommittedURL()); | |
| 1198 | |
| 1199 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1200 content::kChromeDevToolsScheme)); | |
| 1201 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1202 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1203 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1204 devtools_sidebar_pane_extension_rfh->GetSiteInstance()); | |
| 1205 EXPECT_EQ(web_url.host(), | |
| 1206 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1207 } | |
| 1208 | |
| 1209 // Tests that http Iframes within the devtools background page, which is | |
| 1210 // different from the extension's background page, are rendered in their own | |
| 1211 // processes and not in the devtools process or the extension's process. This | |
| 1212 // is tested because this is one of the extension pages with devtools access | |
| 1213 // (https://developer.chrome.com/extensions/devtools). BUG=crbug.com/570483 | |
| 1214 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1215 HttpIframeInDevToolsExtensionDevtools) { | |
| 1216 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1217 | |
| 1218 // Install the dynamically-generated extension. | |
| 1219 const Extension* extension = | |
| 1220 LoadExtensionForTest("Devtools Extension", "web_devtools_page.html", | |
| 1221 "" /* panel_iframe_src */); | |
| 1222 ASSERT_TRUE(extension); | |
| 1223 | |
| 1224 // Wait for a 'DONE' message sent from popup_iframe.html, indicating that it | |
| 986 // loaded successfully. | 1225 // loaded successfully. |
| 987 content::DOMMessageQueue message_queue; | 1226 content::DOMMessageQueue message_queue; |
| 988 SwitchToExtensionPanel(window_, extension, "iframe_panel"); | |
| 989 std::string message; | 1227 std::string message; |
| 1228 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1229 | |
| 990 while (true) { | 1230 while (true) { |
| 991 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 1231 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 992 if (message == "\"DONE\"") | 1232 if (message == "\"DONE\"") |
| 993 break; | 1233 break; |
| 994 } | 1234 } |
| 1235 | |
| 1236 std::vector<content::RenderFrameHost*> rfhs = | |
| 1237 main_web_contents()->GetAllFrames(); | |
| 1238 EXPECT_EQ(3U, rfhs.size()); | |
| 1239 | |
| 1240 content::RenderFrameHost* main_devtools_rfh = | |
| 1241 main_web_contents()->GetMainFrame(); | |
| 1242 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1243 ChildFrameAt(main_devtools_rfh, 0); | |
| 1244 content::RenderFrameHost* http_iframe_rfh = | |
| 1245 ChildFrameAt(devtools_extension_devtools_rfh, 0); | |
| 1246 | |
| 1247 GURL web_url = embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 1248 | |
| 1249 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1250 content::kChromeDevToolsScheme)); | |
| 1251 EXPECT_EQ(extension->GetResourceURL("/web_devtools_page.html"), | |
| 1252 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1253 EXPECT_EQ(web_url, http_iframe_rfh->GetLastCommittedURL()); | |
| 1254 | |
| 1255 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1256 content::kChromeDevToolsScheme)); | |
| 1257 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1258 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1259 EXPECT_EQ(web_url.host(), | |
| 1260 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1261 } | |
| 1262 | |
| 1263 // Tests that iframes to a non-devtools extension embedded in a devtools | |
| 1264 // extension will be isolated from devtools and the devtools extension. | |
| 1265 // BUG=crbug.com/570483 | |
|
ncarter (slow)
2017/03/20 17:22:12
BUG= -> https:// as above
davidsac (gone - try alexmos)
2017/03/20 18:25:57
Done.
| |
| 1266 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1267 NonDevToolsExtensionInDevToolsExtension) { | |
| 1268 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1269 | |
| 1270 // Install the dynamically-generated non-devtools extension. | |
| 1271 const Extension* non_devtools_extension = | |
| 1272 LoadExtensionForTest("Non-DevTools Extension", "" /* devtools_page */, | |
| 1273 "" /* panel_iframe_src */); | |
| 1274 ASSERT_TRUE(non_devtools_extension); | |
| 1275 | |
| 1276 GURL non_dt_extension_test_url = | |
| 1277 non_devtools_extension->GetResourceURL("/simple_test_page.html"); | |
| 1278 | |
| 1279 // Install the dynamically-generated devtools extension. | |
| 1280 const Extension* devtools_extension = | |
| 1281 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", | |
| 1282 non_dt_extension_test_url.spec()); | |
| 1283 ASSERT_TRUE(devtools_extension); | |
| 1284 | |
| 1285 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1286 | |
| 1287 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1288 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1289 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1290 | |
| 1291 // Now that we know the panel is loaded, switch to it. | |
| 1292 content::TestNavigationManager non_devtools_manager( | |
| 1293 main_web_contents(), non_dt_extension_test_url); | |
| 1294 SwitchToExtensionPanel(window_, devtools_extension, "iframe_panel"); | |
| 1295 non_devtools_manager.WaitForNavigationFinished(); | |
| 1296 | |
| 1297 std::vector<content::RenderFrameHost*> rfhs = | |
| 1298 main_web_contents()->GetAllFrames(); | |
| 1299 EXPECT_EQ(4U, rfhs.size()); | |
| 1300 | |
| 1301 content::RenderFrameHost* main_devtools_rfh = | |
| 1302 main_web_contents()->GetMainFrame(); | |
| 1303 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1304 ChildFrameAt(main_devtools_rfh, 0); | |
| 1305 content::RenderFrameHost* devtools_extension_panel_rfh = | |
| 1306 ChildFrameAt(main_devtools_rfh, 1); | |
| 1307 content::RenderFrameHost* non_devtools_extension_test_rfh = | |
| 1308 ChildFrameAt(devtools_extension_panel_rfh, 0); | |
| 1309 | |
| 1310 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1311 content::kChromeDevToolsScheme)); | |
| 1312 EXPECT_EQ(devtools_extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1313 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1314 EXPECT_EQ(devtools_extension->GetResourceURL("/panel.html"), | |
| 1315 devtools_extension_panel_rfh->GetLastCommittedURL()); | |
| 1316 EXPECT_EQ(non_dt_extension_test_url, | |
| 1317 non_devtools_extension_test_rfh->GetLastCommittedURL()); | |
| 1318 | |
| 1319 // popup_test_page.html's frame should be in extension b's | |
| 1320 // process, not in devtools or extension a's process. | |
| 1321 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1322 content::kChromeDevToolsScheme)); | |
| 1323 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1324 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1325 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1326 devtools_extension_panel_rfh->GetSiteInstance()); | |
| 1327 EXPECT_EQ(non_dt_extension_test_url.GetOrigin(), | |
| 1328 non_devtools_extension_test_rfh->GetSiteInstance()->GetSiteURL()); | |
| 1329 } | |
| 1330 | |
| 1331 // Tests that if a devtools extension's devtools panel page has a subframe to a | |
| 1332 // page for another devtools extension, the subframe is rendered in the devtools | |
| 1333 // process as well. BUG=crbug.com/570483 | |
| 1334 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1335 DevToolsExtensionInDevToolsExtension) { | |
| 1336 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1337 | |
| 1338 // Install the dynamically-generated extension. | |
| 1339 const Extension* devtools_b_extension = | |
| 1340 LoadExtensionForTest("Devtools Extension B", "simple_devtools_page.html", | |
| 1341 "" /* panel_iframe_src */); | |
| 1342 ASSERT_TRUE(devtools_b_extension); | |
| 1343 | |
| 1344 GURL extension_b_test_url = | |
| 1345 devtools_b_extension->GetResourceURL("/simple_test_page.html"); | |
| 1346 | |
| 1347 // Install the dynamically-generated extension. | |
| 1348 const Extension* devtools_a_extension = | |
| 1349 LoadExtensionForTest("Devtools Extension A", "panel_devtools_page.html", | |
| 1350 extension_b_test_url.spec()); | |
| 1351 ASSERT_TRUE(devtools_a_extension); | |
| 1352 | |
| 1353 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1354 | |
| 1355 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1356 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1357 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1358 | |
| 1359 // Now that we know the panel is loaded, switch to it. | |
| 1360 content::TestNavigationManager extension_b_manager(main_web_contents(), | |
| 1361 extension_b_test_url); | |
| 1362 SwitchToExtensionPanel(window_, devtools_a_extension, "iframe_panel"); | |
| 1363 extension_b_manager.WaitForNavigationFinished(); | |
| 1364 | |
| 1365 std::vector<content::RenderFrameHost*> rfhs = | |
| 1366 main_web_contents()->GetAllFrames(); | |
| 1367 EXPECT_EQ(5U, rfhs.size()); | |
| 1368 | |
| 1369 content::RenderFrameHost* main_devtools_rfh = | |
| 1370 main_web_contents()->GetMainFrame(); | |
| 1371 | |
| 1372 content::RenderFrameHost* devtools_extension_a_devtools_rfh = | |
| 1373 content::FrameMatchingPredicate( | |
| 1374 main_web_contents(), base::Bind(&content::FrameHasSourceUrl, | |
| 1375 devtools_a_extension->GetResourceURL( | |
| 1376 "/panel_devtools_page.html"))); | |
| 1377 EXPECT_TRUE(devtools_extension_a_devtools_rfh); | |
| 1378 content::RenderFrameHost* devtools_extension_b_devtools_rfh = | |
| 1379 content::FrameMatchingPredicate( | |
| 1380 main_web_contents(), base::Bind(&content::FrameHasSourceUrl, | |
| 1381 devtools_b_extension->GetResourceURL( | |
| 1382 "/simple_devtools_page.html"))); | |
| 1383 EXPECT_TRUE(devtools_extension_b_devtools_rfh); | |
| 1384 | |
| 1385 content::RenderFrameHost* devtools_extension_a_panel_rfh = | |
| 1386 ChildFrameAt(main_devtools_rfh, 2); | |
| 1387 content::RenderFrameHost* devtools_extension_b_test_rfh = | |
| 1388 ChildFrameAt(devtools_extension_a_panel_rfh, 0); | |
| 1389 | |
| 1390 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1391 content::kChromeDevToolsScheme)); | |
| 1392 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1393 devtools_extension_a_devtools_rfh->GetLastCommittedURL()); | |
| 1394 EXPECT_EQ(devtools_b_extension->GetResourceURL("/simple_devtools_page.html"), | |
| 1395 devtools_extension_b_devtools_rfh->GetLastCommittedURL()); | |
| 1396 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel.html"), | |
| 1397 devtools_extension_a_panel_rfh->GetLastCommittedURL()); | |
| 1398 EXPECT_EQ(extension_b_test_url, | |
| 1399 devtools_extension_b_test_rfh->GetLastCommittedURL()); | |
| 1400 | |
| 1401 // all frames should be in the devtools process. | |
| 1402 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1403 content::kChromeDevToolsScheme)); | |
| 1404 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1405 devtools_extension_a_devtools_rfh->GetSiteInstance()); | |
| 1406 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1407 devtools_extension_b_devtools_rfh->GetSiteInstance()); | |
| 1408 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1409 devtools_extension_a_panel_rfh->GetSiteInstance()); | |
| 1410 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1411 devtools_extension_b_test_rfh->GetSiteInstance()); | |
| 1412 } | |
| 1413 | |
| 1414 // Tests that a devtools extension can still have subframes to itself in a | |
| 1415 // "devtools page" and that they will be rendered within the devtools process as | |
| 1416 // well, not in the extension process. BUG=crbug.com/570483 | |
| 1417 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionInItself) { | |
| 1418 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1419 | |
| 1420 // Install the dynamically-generated extension. | |
| 1421 const Extension* extension = | |
| 1422 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", | |
| 1423 "/simple_test_page.html"); | |
| 1424 ASSERT_TRUE(extension); | |
| 1425 | |
| 1426 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1427 | |
| 1428 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1429 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1430 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1431 | |
| 1432 // Now that we know the panel is loaded, switch to it. | |
| 1433 GURL extension_test_url = extension->GetResourceURL("/simple_test_page.html"); | |
| 1434 content::TestNavigationManager test_page_manager(main_web_contents(), | |
| 1435 extension_test_url); | |
| 1436 SwitchToExtensionPanel(window_, extension, "iframe_panel"); | |
| 1437 test_page_manager.WaitForNavigationFinished(); | |
| 1438 | |
| 1439 std::vector<content::RenderFrameHost*> rfhs = | |
| 1440 main_web_contents()->GetAllFrames(); | |
| 1441 EXPECT_EQ(4U, rfhs.size()); | |
| 1442 | |
| 1443 content::RenderFrameHost* main_devtools_rfh = | |
| 1444 main_web_contents()->GetMainFrame(); | |
| 1445 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1446 ChildFrameAt(main_devtools_rfh, 0); | |
| 1447 content::RenderFrameHost* devtools_extension_panel_rfh = | |
| 1448 ChildFrameAt(main_devtools_rfh, 1); | |
| 1449 content::RenderFrameHost* devtools_extension_test_rfh = | |
| 1450 ChildFrameAt(devtools_extension_panel_rfh, 0); | |
| 1451 | |
| 1452 // all frames should be in the devtools process, including test.html's frame | |
| 1453 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1454 content::kChromeDevToolsScheme)); | |
| 1455 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1456 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1457 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1458 devtools_extension_panel_rfh->GetLastCommittedURL()); | |
| 1459 EXPECT_EQ(extension_test_url, | |
| 1460 devtools_extension_test_rfh->GetLastCommittedURL()); | |
| 1461 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1462 content::kChromeDevToolsScheme)); | |
| 1463 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1464 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1465 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1466 devtools_extension_panel_rfh->GetSiteInstance()); | |
| 1467 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1468 devtools_extension_test_rfh->GetSiteInstance()); | |
| 1469 } | |
| 1470 | |
| 1471 // Tests that a devtools (not a devtools extension) Iframe can be injected into | |
| 1472 // devtools. BUG=crbug.com/570483 | |
| 1473 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DevtoolsInDevTools) { | |
| 1474 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1475 | |
| 1476 GURL devtools_url = GURL("chrome-devtools://devtools/bundled/inspector.html"); | |
| 1477 | |
| 1478 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1479 | |
| 1480 std::string javascript = | |
| 1481 "var devtoolsFrame = document.createElement('iframe');" | |
| 1482 "document.body.appendChild(devtoolsFrame);" | |
| 1483 "devtoolsFrame.setAttribute('src', '" + | |
| 1484 devtools_url.spec() + "');"; | |
| 1485 | |
| 1486 content::RenderFrameHost* main_devtools_rfh = | |
| 1487 main_web_contents()->GetMainFrame(); | |
| 1488 | |
| 1489 content::TestNavigationManager manager(main_web_contents(), devtools_url); | |
| 1490 | |
| 1491 ASSERT_TRUE(content::ExecuteScript(main_devtools_rfh, javascript)); | |
| 1492 | |
| 1493 manager.WaitForNavigationFinished(); | |
| 1494 std::vector<content::RenderFrameHost*> rfhs = | |
| 1495 main_web_contents()->GetAllFrames(); | |
| 1496 EXPECT_EQ(2U, rfhs.size()); | |
| 1497 content::RenderFrameHost* devtools_iframe_rfh = | |
| 1498 ChildFrameAt(main_devtools_rfh, 0); | |
| 1499 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1500 content::kChromeDevToolsScheme)); | |
| 1501 EXPECT_EQ(devtools_url, devtools_iframe_rfh->GetLastCommittedURL()); | |
| 1502 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1503 content::kChromeDevToolsScheme)); | |
| 1504 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1505 devtools_iframe_rfh->GetSiteInstance()); | |
| 1506 | |
| 1507 std::string message; | |
| 1508 | |
| 1509 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
| 1510 devtools_iframe_rfh, "domAutomationController.send(document.origin)", | |
| 1511 &message)); | |
| 1512 EXPECT_EQ("chrome-devtools://devtools", message); | |
| 995 } | 1513 } |
| 996 | 1514 |
| 997 // Some web features, when used from an extension, are subject to browser-side | 1515 // Some web features, when used from an extension, are subject to browser-side |
| 998 // security policy enforcement. Make sure they work properly from inside a | 1516 // security policy enforcement. Make sure they work properly from inside a |
| 999 // devtools extension. | 1517 // devtools extension. |
| 1000 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 1518 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1001 DevToolsExtensionSecurityPolicyGrants) { | 1519 DevToolsExtensionSecurityPolicyGrants) { |
| 1002 ASSERT_TRUE(embedded_test_server()->Start()); | 1520 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1003 | 1521 |
| 1004 std::unique_ptr<extensions::TestExtensionDir> dir( | 1522 std::unique_ptr<extensions::TestExtensionDir> dir( |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); | 2112 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
| 1595 | 2113 |
| 1596 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 2114 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 1597 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 2115 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 1598 } | 2116 } |
| 1599 | 2117 |
| 1600 // Tests scripts panel showing. | 2118 // Tests scripts panel showing. |
| 1601 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 2119 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
| 1602 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 2120 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
| 1603 } | 2121 } |
| OLD | NEW |