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> |
|
ncarter (slow)
2017/03/15 20:01:02
#include <vector>
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
| 33 #include "chrome/browser/extensions/test_extension_dir.h" | 33 #include "chrome/browser/extensions/test_extension_dir.h" |
| 34 #include "chrome/browser/extensions/unpacked_installer.h" | 34 #include "chrome/browser/extensions/unpacked_installer.h" |
| 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/extensions/extension_process_policy.h" | |
| 42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 44 #include "chrome/test/base/in_process_browser_test.h" | 45 #include "chrome/test/base/in_process_browser_test.h" |
| 45 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" | 46 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
| 46 #include "chrome/test/base/ui_test_utils.h" | 47 #include "chrome/test/base/ui_test_utils.h" |
| 47 #include "components/app_modal/javascript_app_modal_dialog.h" | 48 #include "components/app_modal/javascript_app_modal_dialog.h" |
| 48 #include "components/app_modal/native_app_modal_dialog.h" | 49 #include "components/app_modal/native_app_modal_dialog.h" |
| 49 #include "components/prefs/pref_service.h" | 50 #include "components/prefs/pref_service.h" |
| 50 #include "content/public/browser/child_process_data.h" | 51 #include "content/public/browser/child_process_data.h" |
| 51 #include "content/public/browser/content_browser_client.h" | 52 #include "content/public/browser/content_browser_client.h" |
| 52 #include "content/public/browser/devtools_agent_host.h" | 53 #include "content/public/browser/devtools_agent_host.h" |
| 53 #include "content/public/browser/notification_registrar.h" | 54 #include "content/public/browser/notification_registrar.h" |
| 54 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
| 56 #include "content/public/browser/render_frame_host.h" | |
| 55 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
| 56 #include "content/public/browser/render_widget_host.h" | 58 #include "content/public/browser/render_widget_host.h" |
| 57 #include "content/public/browser/render_widget_host_view.h" | 59 #include "content/public/browser/render_widget_host_view.h" |
| 58 #include "content/public/browser/url_data_source.h" | 60 #include "content/public/browser/url_data_source.h" |
| 59 #include "content/public/browser/web_contents.h" | 61 #include "content/public/browser/web_contents.h" |
| 60 #include "content/public/browser/web_ui_controller.h" | 62 #include "content/public/browser/web_ui_controller.h" |
| 61 #include "content/public/browser/worker_service.h" | 63 #include "content/public/browser/worker_service.h" |
| 62 #include "content/public/browser/worker_service_observer.h" | 64 #include "content/public/browser/worker_service_observer.h" |
| 63 #include "content/public/common/content_switches.h" | 65 #include "content/public/common/content_switches.h" |
| 66 #include "content/public/common/url_constants.h" | |
| 64 #include "content/public/test/browser_test_utils.h" | 67 #include "content/public/test/browser_test_utils.h" |
| 65 #include "content/public/test/test_navigation_observer.h" | 68 #include "content/public/test/test_navigation_observer.h" |
| 66 #include "extensions/browser/extension_registry.h" | 69 #include "extensions/browser/extension_registry.h" |
| 67 #include "extensions/browser/extension_system.h" | 70 #include "extensions/browser/extension_system.h" |
| 68 #include "extensions/browser/notification_types.h" | 71 #include "extensions/browser/notification_types.h" |
| 69 #include "extensions/common/switches.h" | 72 #include "extensions/common/switches.h" |
| 70 #include "extensions/common/value_builder.h" | 73 #include "extensions/common/value_builder.h" |
| 71 #include "net/dns/mock_host_resolver.h" | 74 #include "net/dns/mock_host_resolver.h" |
| 72 #include "net/test/spawned_test_server/spawned_test_server.h" | 75 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 73 #include "net/test/url_request/url_request_mock_http_job.h" | 76 #include "net/test/url_request/url_request_mock_http_job.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 } | 508 } |
| 506 size_t num_after = registry->enabled_extensions().size(); | 509 size_t num_after = registry->enabled_extensions().size(); |
| 507 if (num_after != (num_before + 1)) | 510 if (num_after != (num_before + 1)) |
| 508 return nullptr; | 511 return nullptr; |
| 509 | 512 |
| 510 if (!WaitForExtensionViewsToLoad()) | 513 if (!WaitForExtensionViewsToLoad()) |
| 511 return nullptr; | 514 return nullptr; |
| 512 | 515 |
| 513 return GetExtensionByPath(registry->enabled_extensions(), path); | 516 return GetExtensionByPath(registry->enabled_extensions(), path); |
| 514 } | 517 } |
| 515 | 518 |
|
ncarter (slow)
2017/03/15 20:01:02
// Loads a dynamically generated extension populat
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done. Good call on a comment here. I also mentio
| |
| 519 const Extension* LoadExtensionForTest(const std::string& name, | |
| 520 const std::string& devtools_page_url, | |
|
ncarter (slow)
2017/03/15 20:01:02
this actually isn't an URL, it's a file, right? Ca
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 521 const std::string& test_page_url) { | |
|
ncarter (slow)
2017/03/15 20:01:02
Rename "test_page_url -> panel_iframe_src"
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 522 test_extension_dirs_.push_back( | |
| 523 base::MakeUnique<extensions::TestExtensionDir>()); | |
| 524 extensions::TestExtensionDir* dir = test_extension_dirs_.back().get(); | |
| 525 | |
| 526 extensions::DictionaryBuilder manifest; | |
| 527 manifest.Set("name", name) | |
| 528 .Set("version", "1") | |
| 529 .Set("manifest_version", 2) | |
| 530 // popup_test_page.html is currently the only page referenced outside of | |
| 531 // its own extension in the tests | |
| 532 .Set("web_accessible_resources", | |
| 533 extensions::ListBuilder().Append("popup_test_page.html").Build()); | |
| 534 if (!devtools_page_url.empty()) { | |
| 535 manifest.Set("devtools_page", devtools_page_url); | |
| 536 } | |
| 537 | |
| 538 dir->WriteManifest(manifest.ToJSON()); | |
| 539 | |
| 540 GURL http_popup_url = | |
| 541 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 542 | |
| 543 dir->WriteFile(FILE_PATH_LITERAL("popup_devtools_page.html"), | |
| 544 "<html><head></head><body><iframe src='" + | |
| 545 http_popup_url.spec() + "'></iframe></body></html>"); | |
| 546 | |
| 547 dir->WriteFile( | |
| 548 FILE_PATH_LITERAL("panel_devtools_page.html"), | |
| 549 "<html><head><script " | |
| 550 "src='panel_devtools_page.js'></script></head><body></body></html>"); | |
| 551 | |
| 552 dir->WriteFile( | |
| 553 FILE_PATH_LITERAL("panel_devtools_page.js"), | |
| 554 "chrome.devtools.panels.create('iframe_panel',\n" | |
| 555 " null,\n" | |
| 556 " 'panel.html',\n" | |
| 557 " function(panel) {\n" | |
| 558 " " | |
| 559 "chrome.devtools.inspectedWindow.eval('console.log(" | |
| 560 "\"PASS\")');\n" | |
| 561 " }\n" | |
| 562 ");\n" | |
| 563 "chrome.devtools.panels.elements.createSidebarPane('iframe_pane',\n" | |
| 564 "function(sidebar) {\n" | |
| 565 "chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" | |
| 566 "sidebar.setPage('panel.html');\n" | |
| 567 "});\n"); | |
| 568 | |
| 569 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), | |
| 570 "<html><body><iframe src='" + test_page_url + | |
| 571 "'></iframe></body></html>"); | |
| 572 | |
| 573 dir->WriteFile(FILE_PATH_LITERAL("simple_devtools_page.html"), | |
| 574 "<html><head></head><body></body></html>"); | |
| 575 | |
| 576 dir->WriteFile(FILE_PATH_LITERAL("popup_test_page.html"), | |
| 577 "<html><head><script " | |
| 578 "src='popup_test_page.js'></script></head><body>This " | |
| 579 "is a test</body></html>"); | |
| 580 | |
| 581 dir->WriteFile(FILE_PATH_LITERAL("popup_test_page.js"), | |
| 582 "window.onload = function() {\n" | |
| 583 " domAutomationController.setAutomationId(0);\n" | |
| 584 " domAutomationController.send('DONE');\n" | |
| 585 "}\n"); | |
| 586 | |
| 587 dir->WriteFile(FILE_PATH_LITERAL("simple_test_page.html"), | |
| 588 "<html><head></head><body>This is a test</body></html>"); | |
| 589 | |
| 590 GURL about_blank_url = GURL(url::kAboutBlankURL); | |
| 591 | |
| 592 GURL data_url = GURL("data:text/html,foo"); | |
| 593 | |
| 594 dir->WriteFile(FILE_PATH_LITERAL("renavigation_test_page.html"), | |
| 595 "<html><body><iframe src='" + about_blank_url.spec() + | |
| 596 "'></iframe><iframe src='" + data_url.spec() + | |
| 597 "'></iframe><iframe src='" + http_popup_url.spec() + | |
| 598 "'></iframe></body></html>"); | |
| 599 | |
| 600 // Install the extension. | |
| 601 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); | |
| 602 return extension; | |
| 603 } | |
| 604 | |
| 516 private: | 605 private: |
| 517 const Extension* GetExtensionByPath( | 606 const Extension* GetExtensionByPath( |
| 518 const extensions::ExtensionSet& extensions, | 607 const extensions::ExtensionSet& extensions, |
| 519 const base::FilePath& path) { | 608 const base::FilePath& path) { |
| 520 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); | 609 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); |
| 521 EXPECT_TRUE(!extension_path.empty()); | 610 EXPECT_TRUE(!extension_path.empty()); |
| 522 for (const scoped_refptr<const Extension>& extension : extensions) { | 611 for (const scoped_refptr<const Extension>& extension : extensions) { |
| 523 if (extension->path() == extension_path) { | 612 if (extension->path() == extension_path) { |
| 524 return extension.get(); | 613 return extension.get(); |
| 525 } | 614 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | 653 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 565 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD: | 654 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD: |
| 566 base::MessageLoopForUI::current()->QuitWhenIdle(); | 655 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 567 break; | 656 break; |
| 568 default: | 657 default: |
| 569 NOTREACHED(); | 658 NOTREACHED(); |
| 570 break; | 659 break; |
| 571 } | 660 } |
| 572 } | 661 } |
| 573 | 662 |
| 663 std::vector<std::unique_ptr<extensions::TestExtensionDir>> | |
| 664 test_extension_dirs_; | |
| 574 base::FilePath test_extensions_dir_; | 665 base::FilePath test_extensions_dir_; |
| 575 }; | 666 }; |
| 576 | 667 |
| 577 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { | 668 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { |
| 578 public: | 669 public: |
| 579 void SetUpCommandLine(base::CommandLine* command_line) override { | 670 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 580 command_line->AppendSwitch( | 671 command_line->AppendSwitch( |
| 581 extensions::switches::kEnableExperimentalExtensionApis); | 672 extensions::switches::kEnableExperimentalExtensionApis); |
| 582 } | 673 } |
| 583 }; | 674 }; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 kDebuggerTestPage); | 987 kDebuggerTestPage); |
| 897 } | 988 } |
| 898 | 989 |
| 899 // Tests that chrome.devtools extension is correctly exposed. | 990 // Tests that chrome.devtools extension is correctly exposed. |
| 900 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 991 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 901 TestDevToolsExtensionAPI) { | 992 TestDevToolsExtensionAPI) { |
| 902 LoadExtension("devtools_extension"); | 993 LoadExtension("devtools_extension"); |
| 903 RunTest("waitForTestResultsInConsole", std::string()); | 994 RunTest("waitForTestResultsInConsole", std::string()); |
| 904 } | 995 } |
| 905 | 996 |
| 906 // Tests a chrome.devtools extension panel that embeds an http:// iframe. | 997 // The following three tests check that http Iframes within the three "devtools |
|
ncarter (slow)
2017/03/15 20:01:02
A comment that applies to 'the next three tests' i
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 907 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionWithHttpIframe) { | 998 // pages" (the visible devtools panel for the devtools extension, the sidebar |
| 908 ASSERT_TRUE(embedded_test_server()->Start()); | 999 // pane page for the devtools extension that is visible in the elemanets panel, |
| 909 | 1000 // and the devtools background page, which is different from the extension's |
| 910 // Our extension must load an URL from the test server, whose port is only | 1001 // background page)(https://developer.chrome.com/extensions/devtools) are |
| 911 // known at runtime. So, to embed the URL, we must dynamically generate the | 1002 // rendered in their own processes and not in the devtools process or the |
| 912 // extension, rather than loading it from static content. | 1003 // extension's process. |
| 913 std::unique_ptr<extensions::TestExtensionDir> dir( | 1004 |
| 914 new extensions::TestExtensionDir()); | 1005 // Tests that http Iframes within the visible devtools panel for the devtools |
| 915 | 1006 // extension are rendered in their own processes and not in the devtools process |
| 916 extensions::DictionaryBuilder manifest; | 1007 // or the extension's process. Also tests that data URLs and about blank URLs |
| 917 dir->WriteManifest(extensions::DictionaryBuilder() | 1008 // are rendered in the devtools process, unless an OOPIF is navigated to |
| 918 .Set("name", "Devtools Panel w/ HTTP Iframe") | 1009 // about:blank, in which case it does not end up back in the devtools process. |
| 919 .Set("version", "1") | 1010 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 920 .Set("manifest_version", 2) | 1011 HttpIframeInDevToolsExtensionPanel) { |
| 921 .Set("devtools_page", "devtools.html") | 1012 ASSERT_TRUE(embedded_test_server()->Start()); |
| 922 .ToJSON()); | 1013 |
| 923 | 1014 // Install the dynamically-generated extension. |
| 924 dir->WriteFile( | 1015 const Extension* extension = |
| 925 FILE_PATH_LITERAL("devtools.html"), | 1016 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", |
| 926 "<html><head><script src='devtools.js'></script></head></html>"); | 1017 "/renavigation_test_page.html"); |
| 927 | 1018 ASSERT_TRUE(extension); |
| 928 dir->WriteFile( | 1019 |
| 929 FILE_PATH_LITERAL("devtools.js"), | 1020 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 930 "chrome.devtools.panels.create('iframe_panel',\n" | 1021 |
| 931 " null,\n" | 1022 // Wait for the panel extension to finish loading -- it'll output 'PASS' |
| 932 " 'panel.html',\n" | 1023 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 933 " function(panel) {\n" | 1024 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 934 " chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" | 1025 |
| 935 " }\n" | 1026 // Now that we know the panel is loaded, switch to it. We'll wait until we |
| 936 ");\n"); | 1027 // see a 'DONE' message sent from popup_iframe.html, indicating that it |
| 937 | 1028 // loaded successfully. |
| 938 GURL http_iframe = | 1029 content::DOMMessageQueue message_queue; |
| 1030 std::string message; | |
| 1031 SwitchToExtensionPanel(window_, extension, "iframe_panel"); | |
| 1032 | |
| 1033 while (true) { | |
| 1034 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 1035 if (message == "\"DONE\"") | |
| 1036 break; | |
| 1037 } | |
| 1038 | |
| 1039 std::vector<content::RenderFrameHost*> rfhs = | |
| 1040 main_web_contents()->GetAllFrames(); | |
| 1041 EXPECT_EQ(7U, rfhs.size()); | |
| 1042 | |
| 1043 content::RenderFrameHost* main_devtools_rfh = | |
| 1044 main_web_contents()->GetMainFrame(); | |
| 1045 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1046 ChildFrameAt(main_devtools_rfh, 0); | |
| 1047 content::RenderFrameHost* devtools_panel_extension_rfh = | |
| 1048 ChildFrameAt(main_devtools_rfh, 1); | |
| 1049 content::RenderFrameHost* test_frame_rfh = | |
| 1050 ChildFrameAt(devtools_panel_extension_rfh, 0); | |
| 1051 content::RenderFrameHost* about_blank_frame_rfh = | |
| 1052 ChildFrameAt(test_frame_rfh, 0); | |
| 1053 content::RenderFrameHost* data_frame_rfh = ChildFrameAt(test_frame_rfh, 1); | |
| 1054 content::RenderFrameHost* about_blank_http_iframe_rfh = | |
| 1055 ChildFrameAt(test_frame_rfh, 2); | |
| 1056 | |
| 1057 GURL http_popup_url = | |
| 939 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | 1058 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); |
| 940 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), | 1059 GURL about_blank_url = GURL(url::kAboutBlankURL); |
| 941 "<html><body>Extension panel.<iframe src='" + | 1060 GURL data_url = GURL("data:text/html,foo"); |
| 942 http_iframe.spec() + "'></iframe>"); | 1061 |
| 943 | 1062 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 944 // Install the extension. | 1063 content::kChromeDevToolsScheme)); |
| 945 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); | 1064 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), |
| 1065 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1066 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1067 devtools_panel_extension_rfh->GetLastCommittedURL()); | |
| 1068 EXPECT_EQ(extension->GetResourceURL("/renavigation_test_page.html"), | |
| 1069 test_frame_rfh->GetLastCommittedURL()); | |
| 1070 EXPECT_EQ(about_blank_url, about_blank_frame_rfh->GetLastCommittedURL()); | |
| 1071 EXPECT_EQ(data_url, data_frame_rfh->GetLastCommittedURL()); | |
| 1072 EXPECT_EQ(http_popup_url, about_blank_http_iframe_rfh->GetLastCommittedURL()); | |
| 1073 | |
| 1074 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1075 content::kChromeDevToolsScheme)); | |
| 1076 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1077 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1078 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1079 devtools_panel_extension_rfh->GetSiteInstance()); | |
| 1080 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1081 test_frame_rfh->GetSiteInstance()); | |
| 1082 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1083 about_blank_frame_rfh->GetSiteInstance()); | |
| 1084 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1085 data_frame_rfh->GetSiteInstance()); | |
| 1086 EXPECT_EQ( | |
| 1087 http_popup_url.host(), | |
| 1088 about_blank_http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1089 | |
| 1090 std::string about_blank_javascript = | |
| 1091 "location.href='" + about_blank_url.spec() + "';"; | |
| 1092 | |
| 1093 content::TestNavigationManager manager(main_web_contents(), about_blank_url); | |
| 1094 | |
| 1095 ASSERT_TRUE(content::ExecuteScript(about_blank_http_iframe_rfh, | |
| 1096 about_blank_javascript)); | |
| 1097 | |
| 1098 manager.WaitForNavigationFinished(); | |
| 1099 | |
| 1100 EXPECT_EQ(about_blank_url, | |
| 1101 about_blank_http_iframe_rfh->GetLastCommittedURL()); | |
| 1102 EXPECT_EQ( | |
| 1103 http_popup_url.host(), | |
| 1104 about_blank_http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1105 } | |
| 1106 | |
| 1107 // Tests that http Iframes within the sidebar pane page for the devtools | |
| 1108 // extension that is visible in the elemanets panel are rendered in their own | |
|
ncarter (slow)
2017/03/15 20:01:02
elemanets is a typo (occurs a couple times in this
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 1109 // processes and not in the devtools process or the extension's process. | |
| 1110 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1111 HttpIframeInDevToolsExtensionSideBarPane) { | |
| 1112 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1113 | |
| 1114 GURL http_iframe_url = | |
| 1115 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 1116 | |
| 1117 // Install the dynamically-generated extension. | |
| 1118 const Extension* extension = LoadExtensionForTest( | |
| 1119 "Devtools Extension", "panel_devtools_page.html", http_iframe_url.spec()); | |
| 946 ASSERT_TRUE(extension); | 1120 ASSERT_TRUE(extension); |
| 947 | 1121 |
| 948 // Open a devtools window. | |
| 949 OpenDevToolsWindow(kDebuggerTestPage, false); | 1122 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 950 | 1123 |
| 951 // Wait for the panel extension to finish loading -- it'll output 'PASS' | 1124 // Wait for the panel extension to finish loading -- it'll output 'PASS' |
| 1125 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1126 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1127 | |
| 1128 // Now that we know the panel is loaded, switch to it. | |
| 1129 content::DOMMessageQueue message_queue; | |
| 1130 SwitchToPanel(window_, "elements"); | |
| 1131 // This is a bit of a hack to switch to the sidebar pane in the elements panel | |
| 1132 // that the Iframe has been added to. We'll wait until we see a 'DONE' | |
| 1133 // message sent from popup_iframe.html, indicating that it loaded | |
| 1134 // successfully. | |
| 1135 SwitchToPanel(window_, "iframe_pane"); | |
| 1136 std::string message; | |
| 1137 | |
| 1138 while (true) { | |
| 1139 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 1140 if (message == "\"DONE\"") | |
| 1141 break; | |
| 1142 } | |
| 1143 | |
| 1144 std::vector<content::RenderFrameHost*> rfhs = | |
| 1145 main_web_contents()->GetAllFrames(); | |
| 1146 EXPECT_EQ(4U, rfhs.size()); | |
| 1147 | |
| 1148 content::RenderFrameHost* main_devtools_rfh = | |
| 1149 main_web_contents()->GetMainFrame(); | |
| 1150 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1151 ChildFrameAt(main_devtools_rfh, 0); | |
| 1152 content::RenderFrameHost* devtools_sidebar_pane_extension_rfh = | |
| 1153 ChildFrameAt(main_devtools_rfh, 1); | |
| 1154 content::RenderFrameHost* http_iframe_rfh = | |
| 1155 ChildFrameAt(devtools_sidebar_pane_extension_rfh, 0); | |
| 1156 | |
| 1157 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1158 content::kChromeDevToolsScheme)); | |
| 1159 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1160 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1161 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1162 devtools_sidebar_pane_extension_rfh->GetLastCommittedURL()); | |
| 1163 EXPECT_EQ(http_iframe_url, http_iframe_rfh->GetLastCommittedURL()); | |
| 1164 | |
| 1165 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1166 content::kChromeDevToolsScheme)); | |
| 1167 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1168 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1169 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1170 devtools_sidebar_pane_extension_rfh->GetSiteInstance()); | |
| 1171 EXPECT_EQ(http_iframe_url.host(), | |
| 1172 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1173 } | |
| 1174 | |
| 1175 // Tests that http Iframes within the devtools background page, which is | |
| 1176 // different from the extension's background page, are rendered in their own | |
| 1177 // processes and not in the devtools process or the extension's process. | |
| 1178 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1179 HttpIframeInDevToolsExtensionDevtools) { | |
| 1180 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1181 | |
| 1182 // Install the dynamically-generated extension. | |
| 1183 const Extension* extension = LoadExtensionForTest( | |
| 1184 "Devtools Extension", "popup_devtools_page.html", "" /* test_page_url */); | |
| 1185 ASSERT_TRUE(extension); | |
| 1186 | |
| 1187 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1188 | |
| 1189 // Now that we know the panel is loaded, switch to it. We'll wait until we | |
| 1190 // see a 'DONE' message sent from popup_iframe.html, indicating that it | |
| 1191 // loaded successfully. | |
| 1192 content::DOMMessageQueue message_queue; | |
| 1193 std::string message; | |
| 1194 | |
| 1195 while (true) { | |
| 1196 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 1197 if (message == "\"DONE\"") | |
| 1198 break; | |
| 1199 } | |
| 1200 | |
| 1201 std::vector<content::RenderFrameHost*> rfhs = | |
| 1202 main_web_contents()->GetAllFrames(); | |
| 1203 EXPECT_EQ(3U, rfhs.size()); | |
| 1204 | |
| 1205 content::RenderFrameHost* main_devtools_rfh = | |
| 1206 main_web_contents()->GetMainFrame(); | |
| 1207 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1208 ChildFrameAt(main_devtools_rfh, 0); | |
| 1209 content::RenderFrameHost* http_iframe_rfh = | |
| 1210 ChildFrameAt(devtools_extension_devtools_rfh, 0); | |
| 1211 | |
| 1212 GURL http_iframe_url = | |
| 1213 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); | |
| 1214 | |
| 1215 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1216 content::kChromeDevToolsScheme)); | |
| 1217 EXPECT_EQ(extension->GetResourceURL("/popup_devtools_page.html"), | |
| 1218 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1219 EXPECT_EQ(http_iframe_url, http_iframe_rfh->GetLastCommittedURL()); | |
| 1220 | |
| 1221 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1222 content::kChromeDevToolsScheme)); | |
| 1223 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1224 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1225 EXPECT_EQ(http_iframe_url.host(), | |
| 1226 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); | |
| 1227 } | |
| 1228 | |
| 1229 // Tests that iframes to a non-devtools extension embedded in a devtools | |
| 1230 // extension will be isolated from devtools and the devtools extension. | |
| 1231 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1232 NonDevToolsExtensionInDevToolsExtension) { | |
| 1233 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1234 | |
| 1235 // Install the dynamically-generated non-devtools extension. | |
| 1236 const Extension* non_devtools_extension = | |
| 1237 LoadExtensionForTest("Non-DevTools Extension", "" /* devtools_page_url */, | |
| 1238 "" /* test_page_url */); | |
| 1239 ASSERT_TRUE(non_devtools_extension); | |
| 1240 | |
| 1241 GURL non_dt_extension_test_url = | |
| 1242 non_devtools_extension->GetResourceURL("/popup_test_page.html"); | |
| 1243 | |
| 1244 // Install the dynamically-generated devtools extension. | |
| 1245 const Extension* devtools_extension = | |
| 1246 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", | |
| 1247 non_dt_extension_test_url.spec()); | |
| 1248 ASSERT_TRUE(devtools_extension); | |
| 1249 | |
| 1250 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1251 | |
| 1252 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1253 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1254 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1255 | |
| 1256 // Now that we know the panel is loaded, switch to it. We'll wait until we | |
| 1257 // see a 'DONE' message sent from popup_iframe.html, indicating that it | |
| 1258 // loaded successfully. | |
| 1259 content::DOMMessageQueue message_queue; | |
| 1260 SwitchToExtensionPanel(window_, devtools_extension, "iframe_panel"); | |
| 1261 std::string message; | |
| 1262 | |
| 1263 while (true) { | |
| 1264 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 1265 if (message == "\"DONE\"") | |
| 1266 break; | |
| 1267 } | |
| 1268 | |
| 1269 std::vector<content::RenderFrameHost*> rfhs = | |
| 1270 main_web_contents()->GetAllFrames(); | |
| 1271 EXPECT_EQ(4U, rfhs.size()); | |
| 1272 | |
| 1273 content::RenderFrameHost* main_devtools_rfh = | |
| 1274 main_web_contents()->GetMainFrame(); | |
| 1275 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1276 ChildFrameAt(main_devtools_rfh, 0); | |
| 1277 content::RenderFrameHost* devtools_extension_panel_rfh = | |
| 1278 ChildFrameAt(main_devtools_rfh, 1); | |
| 1279 content::RenderFrameHost* non_devtools_extension_test_rfh = | |
| 1280 ChildFrameAt(devtools_extension_panel_rfh, 0); | |
| 1281 | |
| 1282 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1283 content::kChromeDevToolsScheme)); | |
| 1284 EXPECT_EQ(devtools_extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1285 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1286 EXPECT_EQ(devtools_extension->GetResourceURL("/panel.html"), | |
| 1287 devtools_extension_panel_rfh->GetLastCommittedURL()); | |
| 1288 EXPECT_EQ(non_dt_extension_test_url, | |
| 1289 non_devtools_extension_test_rfh->GetLastCommittedURL()); | |
| 1290 | |
| 1291 // popup_test_page.html's frame should be in extension b's | |
| 1292 // process, not in devtools or extension a's process. | |
| 1293 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1294 content::kChromeDevToolsScheme)); | |
| 1295 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1296 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1297 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1298 devtools_extension_panel_rfh->GetSiteInstance()); | |
| 1299 EXPECT_EQ(non_dt_extension_test_url.GetOrigin(), | |
| 1300 non_devtools_extension_test_rfh->GetSiteInstance()->GetSiteURL()); | |
| 1301 } | |
| 1302 | |
| 1303 // Tests that if a devtools extension's devtools panel page has a subframe to a | |
| 1304 // page for another devtools extension, the subframe is rendered in the devtools | |
| 1305 // process as well. | |
| 1306 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | |
| 1307 DevToolsExtensionInDevToolsExtension) { | |
| 1308 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1309 | |
| 1310 // Install the dynamically-generated extension. | |
| 1311 const Extension* devtools_b_extension = | |
| 1312 LoadExtensionForTest("Devtools Extension B", "simple_devtools_page.html", | |
| 1313 "" /* test_page_url */); | |
| 1314 ASSERT_TRUE(devtools_b_extension); | |
| 1315 | |
| 1316 GURL extension_b_test_url = | |
| 1317 devtools_b_extension->GetResourceURL("/popup_test_page.html"); | |
| 1318 | |
| 1319 // Install the dynamically-generated extension. | |
| 1320 const Extension* devtools_a_extension = | |
| 1321 LoadExtensionForTest("Devtools Extension A", "panel_devtools_page.html", | |
| 1322 extension_b_test_url.spec()); | |
| 1323 ASSERT_TRUE(devtools_a_extension); | |
| 1324 | |
| 1325 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1326 | |
| 1327 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 1328 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | |
| 1329 RunTestFunction(window_, "waitForTestResultsInConsole"); | |
| 1330 | |
| 1331 // Now that we know the panel is loaded, switch to it. We'll wait until we | |
| 1332 // see a 'DONE' message sent from popup_iframe.html, indicating that it | |
| 1333 // loaded successfully. | |
| 1334 content::DOMMessageQueue message_queue; | |
| 1335 SwitchToExtensionPanel(window_, devtools_a_extension, "iframe_panel"); | |
| 1336 std::string message; | |
| 1337 | |
| 1338 while (true) { | |
| 1339 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | |
| 1340 if (message == "\"DONE\"") | |
| 1341 break; | |
| 1342 } | |
| 1343 | |
| 1344 std::vector<content::RenderFrameHost*> rfhs = | |
| 1345 main_web_contents()->GetAllFrames(); | |
| 1346 EXPECT_EQ(5U, rfhs.size()); | |
| 1347 | |
| 1348 content::RenderFrameHost* main_devtools_rfh = | |
| 1349 main_web_contents()->GetMainFrame(); | |
| 1350 | |
| 1351 content::RenderFrameHost* devtools_extension_a_devtools_rfh = | |
| 1352 content::FrameMatchingPredicate( | |
| 1353 main_web_contents(), | |
| 1354 base::Bind(&content::FrameHasSourceUrl, | |
| 1355 devtools_a_extension->GetResourceURL( | |
| 1356 "/panel_devtools_page.html"))); | |
| 1357 EXPECT_TRUE(devtools_extension_a_devtools_rfh); | |
| 1358 content::RenderFrameHost* devtools_extension_b_devtools_rfh = | |
| 1359 content::FrameMatchingPredicate( | |
| 1360 main_web_contents(), | |
| 1361 base::Bind(&content::FrameHasSourceUrl, | |
| 1362 devtools_b_extension->GetResourceURL( | |
| 1363 "/simple_devtools_page.html"))); | |
| 1364 EXPECT_TRUE(devtools_extension_b_devtools_rfh); | |
| 1365 | |
| 1366 content::RenderFrameHost* devtools_extension_a_panel_rfh = | |
| 1367 ChildFrameAt(main_devtools_rfh, 2); | |
| 1368 content::RenderFrameHost* devtools_extension_b_test_rfh = | |
| 1369 ChildFrameAt(devtools_extension_a_panel_rfh, 0); | |
| 1370 | |
| 1371 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1372 content::kChromeDevToolsScheme)); | |
| 1373 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1374 devtools_extension_a_devtools_rfh->GetLastCommittedURL()); | |
| 1375 EXPECT_EQ(devtools_b_extension->GetResourceURL("/simple_devtools_page.html"), | |
| 1376 devtools_extension_b_devtools_rfh->GetLastCommittedURL()); | |
| 1377 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel.html"), | |
| 1378 devtools_extension_a_panel_rfh->GetLastCommittedURL()); | |
| 1379 EXPECT_EQ(extension_b_test_url, | |
| 1380 devtools_extension_b_test_rfh->GetLastCommittedURL()); | |
| 1381 | |
| 1382 // all frames should be in the devtools process. | |
| 1383 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1384 content::kChromeDevToolsScheme)); | |
| 1385 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1386 devtools_extension_a_devtools_rfh->GetSiteInstance()); | |
| 1387 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1388 devtools_extension_b_devtools_rfh->GetSiteInstance()); | |
| 1389 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1390 devtools_extension_a_panel_rfh->GetSiteInstance()); | |
| 1391 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1392 devtools_extension_b_test_rfh->GetSiteInstance()); | |
| 1393 } | |
| 1394 | |
| 1395 // Tests that a devtools extension can still have subframes to itself in a | |
| 1396 // "devtools page" and that they will be rendered within the devtools process as | |
| 1397 // well, not in the extension process. | |
| 1398 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionInItself) { | |
| 1399 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1400 | |
| 1401 // Install the dynamically-generated extension. | |
| 1402 const Extension* extension = | |
| 1403 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", | |
| 1404 "/popup_test_page.html"); | |
| 1405 ASSERT_TRUE(extension); | |
| 1406 | |
| 1407 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1408 | |
| 1409 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 952 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | 1410 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 953 RunTestFunction(window_, "waitForTestResultsInConsole"); | 1411 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 954 | 1412 |
| 955 // Now that we know the panel is loaded, switch to it. We'll wait until we | 1413 // Now that we know the panel is loaded, switch to it. We'll wait until we |
| 956 // see a 'DONE' message sent from popup_iframe.html, indicating that it | 1414 // see a 'DONE' message sent from popup_iframe.html, indicating that it |
| 957 // loaded successfully. | 1415 // loaded successfully. |
| 958 content::DOMMessageQueue message_queue; | 1416 content::DOMMessageQueue message_queue; |
| 959 SwitchToExtensionPanel(window_, extension, "iframe_panel"); | 1417 SwitchToExtensionPanel(window_, extension, "iframe_panel"); |
| 960 std::string message; | 1418 std::string message; |
| 1419 | |
| 961 while (true) { | 1420 while (true) { |
| 962 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 1421 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 963 if (message == "\"DONE\"") | 1422 if (message == "\"DONE\"") |
| 964 break; | 1423 break; |
| 965 } | 1424 } |
| 1425 | |
| 1426 GURL extension_test_url = extension->GetResourceURL("/popup_test_page.html"); | |
| 1427 | |
| 1428 std::vector<content::RenderFrameHost*> rfhs = | |
| 1429 main_web_contents()->GetAllFrames(); | |
| 1430 EXPECT_EQ(4U, rfhs.size()); | |
| 1431 | |
| 1432 content::RenderFrameHost* main_devtools_rfh = | |
| 1433 main_web_contents()->GetMainFrame(); | |
| 1434 content::RenderFrameHost* devtools_extension_devtools_rfh = | |
| 1435 ChildFrameAt(main_devtools_rfh, 0); | |
| 1436 content::RenderFrameHost* devtools_extension_panel_rfh = | |
| 1437 ChildFrameAt(main_devtools_rfh, 1); | |
| 1438 content::RenderFrameHost* devtools_extension_test_rfh = | |
| 1439 ChildFrameAt(devtools_extension_panel_rfh, 0); | |
| 1440 | |
| 1441 // all frames should be in the devtools process, including test.html's frame | |
| 1442 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1443 content::kChromeDevToolsScheme)); | |
| 1444 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), | |
| 1445 devtools_extension_devtools_rfh->GetLastCommittedURL()); | |
| 1446 EXPECT_EQ(extension->GetResourceURL("/panel.html"), | |
| 1447 devtools_extension_panel_rfh->GetLastCommittedURL()); | |
| 1448 EXPECT_EQ(extension_test_url, | |
| 1449 devtools_extension_test_rfh->GetLastCommittedURL()); | |
| 1450 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1451 content::kChromeDevToolsScheme)); | |
| 1452 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1453 devtools_extension_devtools_rfh->GetSiteInstance()); | |
| 1454 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1455 devtools_extension_panel_rfh->GetSiteInstance()); | |
| 1456 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1457 devtools_extension_test_rfh->GetSiteInstance()); | |
| 1458 } | |
| 1459 | |
| 1460 // Tests that a devtools (not a devtools extension) Iframe can still be injected | |
|
ncarter (slow)
2017/03/15 20:01:02
'can still be' -> 'can be'
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 1461 // into devtools. | |
| 1462 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DevtoolsInDevTools) { | |
| 1463 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1464 | |
| 1465 GURL devtools_url = GURL("chrome-devtools://devtools/bundled/inspector.html"); | |
| 1466 | |
| 1467 OpenDevToolsWindow(kDebuggerTestPage, false); | |
| 1468 | |
| 1469 std::string javascript = | |
| 1470 "var devtoolsFrame = document.createElement('iframe');" | |
| 1471 "document.body.appendChild(devtoolsFrame);" | |
| 1472 "devtoolsFrame.setAttribute('src', '" + | |
| 1473 devtools_url.spec() + "');"; | |
| 1474 | |
| 1475 content::RenderFrameHost* main_devtools_rfh = | |
| 1476 main_web_contents()->GetMainFrame(); | |
| 1477 | |
| 1478 content::TestNavigationManager manager(main_web_contents(), devtools_url); | |
| 1479 | |
| 1480 ASSERT_TRUE(content::ExecuteScript(main_devtools_rfh, javascript)); | |
| 1481 | |
| 1482 manager.WaitForNavigationFinished(); | |
| 1483 std::vector<content::RenderFrameHost*> rfhs = | |
| 1484 main_web_contents()->GetAllFrames(); | |
| 1485 EXPECT_EQ(2U, rfhs.size()); | |
| 1486 content::RenderFrameHost* devtools_iframe_rfh = | |
| 1487 ChildFrameAt(main_devtools_rfh, 0); | |
| 1488 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( | |
| 1489 content::kChromeDevToolsScheme)); | |
| 1490 EXPECT_EQ(devtools_url, devtools_iframe_rfh->GetLastCommittedURL()); | |
| 1491 EXPECT_TRUE(main_devtools_rfh->GetSiteInstance()->GetSiteURL().SchemeIs( | |
| 1492 content::kChromeDevToolsScheme)); | |
| 1493 EXPECT_EQ(main_devtools_rfh->GetSiteInstance(), | |
| 1494 devtools_iframe_rfh->GetSiteInstance()); | |
|
ncarter (slow)
2017/03/15 20:01:02
Might be worthwhile to interact with the loaded pa
davidsac (gone - try alexmos)
2017/03/18 01:32:41
Done.
| |
| 966 } | 1495 } |
| 967 | 1496 |
| 968 // Some web features, when used from an extension, are subject to browser-side | 1497 // Some web features, when used from an extension, are subject to browser-side |
| 969 // security policy enforcement. Make sure they work properly from inside a | 1498 // security policy enforcement. Make sure they work properly from inside a |
| 970 // devtools extension. | 1499 // devtools extension. |
| 971 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 1500 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 972 DevToolsExtensionSecurityPolicyGrants) { | 1501 DevToolsExtensionSecurityPolicyGrants) { |
| 973 ASSERT_TRUE(embedded_test_server()->Start()); | 1502 ASSERT_TRUE(embedded_test_server()->Start()); |
| 974 | 1503 |
| 975 std::unique_ptr<extensions::TestExtensionDir> dir( | 1504 std::unique_ptr<extensions::TestExtensionDir> dir( |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1566 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); | 2095 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
| 1567 | 2096 |
| 1568 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 2097 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 1569 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 2098 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 1570 } | 2099 } |
| 1571 | 2100 |
| 1572 // Tests scripts panel showing. | 2101 // Tests scripts panel showing. |
| 1573 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 2102 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
| 1574 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 2103 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
| 1575 } | 2104 } |
| OLD | NEW |