| 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" |
| 74 #include "net/test/spawned_test_server/spawned_test_server.h" | 78 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 75 #include "net/test/url_request/url_request_mock_http_job.h" | 79 #include "net/test/url_request/url_request_mock_http_job.h" |
| 76 #include "net/url_request/url_request_context.h" | 80 #include "net/url_request/url_request_context.h" |
| 77 #include "net/url_request/url_request_filter.h" | 81 #include "net/url_request/url_request_filter.h" |
| 78 #include "net/url_request/url_request_http_job.h" | 82 #include "net/url_request/url_request_http_job.h" |
| 79 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 83 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 80 #include "ui/compositor/compositor_switches.h" | 84 #include "ui/compositor/compositor_switches.h" |
| 81 #include "ui/gl/gl_switches.h" | 85 #include "ui/gl/gl_switches.h" |
| 82 #include "url/gurl.h" | 86 #include "url/gurl.h" |
| 83 | 87 |
| 84 using app_modal::AppModalDialog; | 88 using app_modal::AppModalDialog; |
| 85 using app_modal::JavaScriptAppModalDialog; | 89 using app_modal::JavaScriptAppModalDialog; |
| 86 using app_modal::NativeAppModalDialog; | 90 using app_modal::NativeAppModalDialog; |
| 87 using content::BrowserThread; | 91 using content::BrowserThread; |
| 88 using content::DevToolsAgentHost; | 92 using content::DevToolsAgentHost; |
| 89 using content::NavigationController; | 93 using content::NavigationController; |
| 94 using content::RenderFrameHost; |
| 90 using content::RenderViewHost; | 95 using content::RenderViewHost; |
| 91 using content::WebContents; | 96 using content::WebContents; |
| 92 using content::WorkerService; | 97 using content::WorkerService; |
| 93 using content::WorkerServiceObserver; | 98 using content::WorkerServiceObserver; |
| 94 using extensions::Extension; | 99 using extensions::Extension; |
| 95 | 100 |
| 96 namespace { | 101 namespace { |
| 97 | 102 |
| 98 const char kDebuggerTestPage[] = "files/devtools/debugger_test_page.html"; | 103 const char kDebuggerTestPage[] = "files/devtools/debugger_test_page.html"; |
| 99 const char kPauseWhenLoadingDevTools[] = | 104 const char kPauseWhenLoadingDevTools[] = |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 extensions::TestExtensionRegistryObserver observer(registry); | 499 extensions::TestExtensionRegistryObserver observer(registry); |
| 495 extensions::UnpackedInstaller::Create(service)->Load(path); | 500 extensions::UnpackedInstaller::Create(service)->Load(path); |
| 496 observer.WaitForExtensionLoaded(); | 501 observer.WaitForExtensionLoaded(); |
| 497 | 502 |
| 498 if (!WaitForExtensionViewsToLoad()) | 503 if (!WaitForExtensionViewsToLoad()) |
| 499 return nullptr; | 504 return nullptr; |
| 500 | 505 |
| 501 return GetExtensionByPath(registry->enabled_extensions(), path); | 506 return GetExtensionByPath(registry->enabled_extensions(), path); |
| 502 } | 507 } |
| 503 | 508 |
| 509 // Loads a dynamically generated extension populated with a bunch of test |
| 510 // pages. |name| is the extension name to use in the manifest. |
| 511 // |devtools_page|, if non-empty, indicates which test page should be be |
| 512 // listed as a devtools_page in the manifest. If |devtools_page| is empty, a |
| 513 // non-devtools extension is created instead. |panel_iframe_src| controls the |
| 514 // src= attribute of the <iframe> element in the 'panel.html' test page. |
| 515 const Extension* LoadExtensionForTest(const std::string& name, |
| 516 const std::string& devtools_page, |
| 517 const std::string& panel_iframe_src) { |
| 518 test_extension_dirs_.push_back( |
| 519 base::MakeUnique<extensions::TestExtensionDir>()); |
| 520 extensions::TestExtensionDir* dir = test_extension_dirs_.back().get(); |
| 521 |
| 522 extensions::DictionaryBuilder manifest; |
| 523 manifest.Set("name", name) |
| 524 .Set("version", "1") |
| 525 .Set("manifest_version", 2) |
| 526 // simple_test_page.html is currently the only page referenced outside |
| 527 // of its own extension in the tests |
| 528 .Set("web_accessible_resources", |
| 529 extensions::ListBuilder().Append("simple_test_page.html").Build()); |
| 530 |
| 531 // If |devtools_page| isn't empty, make it a devtools extension in the |
| 532 // manifest. |
| 533 if (!devtools_page.empty()) |
| 534 manifest.Set("devtools_page", devtools_page); |
| 535 |
| 536 dir->WriteManifest(manifest.ToJSON()); |
| 537 |
| 538 GURL http_frame_url = |
| 539 embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); |
| 540 |
| 541 // If this is a devtools extension, |devtools_page| will indicate which of |
| 542 // these devtools_pages will end up being used. Different tests use |
| 543 // different devtools_pages. |
| 544 dir->WriteFile(FILE_PATH_LITERAL("web_devtools_page.html"), |
| 545 "<html><body><iframe src='" + http_frame_url.spec() + |
| 546 "'></iframe></body></html>"); |
| 547 |
| 548 dir->WriteFile(FILE_PATH_LITERAL("simple_devtools_page.html"), |
| 549 "<html><body></body></html>"); |
| 550 |
| 551 dir->WriteFile( |
| 552 FILE_PATH_LITERAL("panel_devtools_page.html"), |
| 553 "<html><head><script " |
| 554 "src='panel_devtools_page.js'></script></head><body></body></html>"); |
| 555 |
| 556 dir->WriteFile(FILE_PATH_LITERAL("panel_devtools_page.js"), |
| 557 "chrome.devtools.panels.create('iframe_panel',\n" |
| 558 " null,\n" |
| 559 " 'panel.html',\n" |
| 560 " function(panel) {\n" |
| 561 " chrome.devtools.inspectedWindow.eval(\n" |
| 562 " 'console.log(\"PASS\")');\n" |
| 563 " }\n" |
| 564 ");\n"); |
| 565 |
| 566 dir->WriteFile(FILE_PATH_LITERAL("sidebarpane_devtools_page.html"), |
| 567 "<html><head><script src='sidebarpane_devtools_page.js'>" |
| 568 "</script></head><body></body></html>"); |
| 569 |
| 570 dir->WriteFile( |
| 571 FILE_PATH_LITERAL("sidebarpane_devtools_page.js"), |
| 572 "chrome.devtools.panels.elements.createSidebarPane('iframe_pane',\n" |
| 573 " function(sidebar) {\n" |
| 574 " chrome.devtools.inspectedWindow.eval(\n" |
| 575 " 'console.log(\"PASS\")');\n" |
| 576 " sidebar.setPage('panel.html');\n" |
| 577 " }\n" |
| 578 ");\n"); |
| 579 |
| 580 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), |
| 581 "<html><body><iframe src='" + panel_iframe_src + |
| 582 "'></iframe></body></html>"); |
| 583 |
| 584 dir->WriteFile(FILE_PATH_LITERAL("simple_test_page.html"), |
| 585 "<html><body>This is a test</body></html>"); |
| 586 |
| 587 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); |
| 588 |
| 589 dir->WriteFile(FILE_PATH_LITERAL("multi_frame_page.html"), |
| 590 "<html><body><iframe src='about:blank'>" |
| 591 "</iframe><iframe src='data:text/html,foo'>" |
| 592 "</iframe><iframe src='" + |
| 593 web_url.spec() + "'></iframe></body></html>"); |
| 594 |
| 595 // Install the extension. |
| 596 return LoadExtensionFromPath(dir->UnpackedPath()); |
| 597 } |
| 598 |
| 504 private: | 599 private: |
| 505 const Extension* GetExtensionByPath( | 600 const Extension* GetExtensionByPath( |
| 506 const extensions::ExtensionSet& extensions, | 601 const extensions::ExtensionSet& extensions, |
| 507 const base::FilePath& path) { | 602 const base::FilePath& path) { |
| 508 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); | 603 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); |
| 509 EXPECT_TRUE(!extension_path.empty()); | 604 EXPECT_TRUE(!extension_path.empty()); |
| 510 for (const scoped_refptr<const Extension>& extension : extensions) { | 605 for (const scoped_refptr<const Extension>& extension : extensions) { |
| 511 if (extension->path() == extension_path) { | 606 if (extension->path() == extension_path) { |
| 512 return extension.get(); | 607 return extension.get(); |
| 513 } | 608 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 } | 641 } |
| 547 | 642 |
| 548 void Observe(int type, | 643 void Observe(int type, |
| 549 const content::NotificationSource& source, | 644 const content::NotificationSource& source, |
| 550 const content::NotificationDetails& details) override { | 645 const content::NotificationDetails& details) override { |
| 551 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, | 646 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
| 552 type); | 647 type); |
| 553 base::MessageLoopForUI::current()->QuitWhenIdle(); | 648 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 554 } | 649 } |
| 555 | 650 |
| 651 std::vector<std::unique_ptr<extensions::TestExtensionDir>> |
| 652 test_extension_dirs_; |
| 556 base::FilePath test_extensions_dir_; | 653 base::FilePath test_extensions_dir_; |
| 557 }; | 654 }; |
| 558 | 655 |
| 559 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { | 656 class DevToolsExperimentalExtensionTest : public DevToolsExtensionTest { |
| 560 public: | 657 public: |
| 561 void SetUpCommandLine(base::CommandLine* command_line) override { | 658 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 562 command_line->AppendSwitch( | 659 command_line->AppendSwitch( |
| 563 extensions::switches::kEnableExperimentalExtensionApis); | 660 extensions::switches::kEnableExperimentalExtensionApis); |
| 564 } | 661 } |
| 565 }; | 662 }; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 kDebuggerTestPage); | 1022 kDebuggerTestPage); |
| 926 } | 1023 } |
| 927 | 1024 |
| 928 // Tests that chrome.devtools extension is correctly exposed. | 1025 // Tests that chrome.devtools extension is correctly exposed. |
| 929 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 1026 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 930 TestDevToolsExtensionAPI) { | 1027 TestDevToolsExtensionAPI) { |
| 931 LoadExtension("devtools_extension"); | 1028 LoadExtension("devtools_extension"); |
| 932 RunTest("waitForTestResultsInConsole", std::string()); | 1029 RunTest("waitForTestResultsInConsole", std::string()); |
| 933 } | 1030 } |
| 934 | 1031 |
| 935 // Tests a chrome.devtools extension panel that embeds an http:// iframe. | 1032 // Tests that http Iframes within the visible devtools panel for the devtools |
| 936 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionWithHttpIframe) { | 1033 // extension are rendered in their own processes and not in the devtools process |
| 937 ASSERT_TRUE(embedded_test_server()->Start()); | 1034 // or the extension's process. This is tested because this is one of the |
| 938 | 1035 // extension pages with devtools access |
| 939 // Our extension must load an URL from the test server, whose port is only | 1036 // (https://developer.chrome.com/extensions/devtools). Also tests that frames |
| 940 // known at runtime. So, to embed the URL, we must dynamically generate the | 1037 // with data URLs and about:blank URLs are rendered in the devtools process, |
| 941 // extension, rather than loading it from static content. | 1038 // unless a web OOPIF navigates itself to about:blank, in which case it does not |
| 942 std::unique_ptr<extensions::TestExtensionDir> dir( | 1039 // end up back in the devtools process. Also tests that when a web IFrame is |
| 943 new extensions::TestExtensionDir()); | 1040 // navigated back to a devtools extension page, it gets put back in the devtools |
| 944 | 1041 // process. |
| 945 extensions::DictionaryBuilder manifest; | 1042 // http://crbug.com/570483 |
| 946 dir->WriteManifest(extensions::DictionaryBuilder() | 1043 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 947 .Set("name", "Devtools Panel w/ HTTP Iframe") | 1044 HttpIframeInDevToolsExtensionPanel) { |
| 948 .Set("version", "1") | 1045 ASSERT_TRUE(embedded_test_server()->Start()); |
| 949 .Set("manifest_version", 2) | 1046 |
| 950 .Set("devtools_page", "devtools.html") | 1047 // Install the dynamically-generated extension. |
| 951 .ToJSON()); | 1048 const Extension* extension = |
| 952 | 1049 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", |
| 953 dir->WriteFile( | 1050 "/multi_frame_page.html"); |
| 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); | 1051 ASSERT_TRUE(extension); |
| 976 | 1052 |
| 977 // Open a devtools window. | 1053 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 978 OpenDevToolsWindow(kDebuggerTestPage, false); | 1054 |
| 979 | 1055 // Wait for the extension's panel to finish loading -- it'll output 'PASS' |
| 980 // Wait for the panel extension to finish loading -- it'll output 'PASS' | |
| 981 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | 1056 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 982 RunTestFunction(window_, "waitForTestResultsInConsole"); | 1057 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 983 | 1058 |
| 984 // Now that we know the panel is loaded, switch to it. We'll wait until we | 1059 // Now that we know the panel is loaded, switch to it. |
| 985 // see a 'DONE' message sent from popup_iframe.html, indicating that it | 1060 SwitchToExtensionPanel(window_, extension, "iframe_panel"); |
| 1061 content::WaitForLoadStop(main_web_contents()); |
| 1062 |
| 1063 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1064 EXPECT_EQ(7U, rfhs.size()); |
| 1065 |
| 1066 // This test creates a page with the following frame tree: |
| 1067 // - DevTools |
| 1068 // - devtools_page from DevTools extension |
| 1069 // - Panel (DevTools extension) |
| 1070 // - iframe (DevTools extension) |
| 1071 // - about:blank |
| 1072 // - data: |
| 1073 // - web URL |
| 1074 |
| 1075 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1076 RenderFrameHost* devtools_extension_devtools_page_rfh = |
| 1077 ChildFrameAt(main_devtools_rfh, 0); |
| 1078 RenderFrameHost* devtools_extension_panel_rfh = |
| 1079 ChildFrameAt(main_devtools_rfh, 1); |
| 1080 RenderFrameHost* panel_frame_rfh = |
| 1081 ChildFrameAt(devtools_extension_panel_rfh, 0); |
| 1082 RenderFrameHost* about_blank_frame_rfh = ChildFrameAt(panel_frame_rfh, 0); |
| 1083 RenderFrameHost* data_frame_rfh = ChildFrameAt(panel_frame_rfh, 1); |
| 1084 RenderFrameHost* web_frame_rfh = ChildFrameAt(panel_frame_rfh, 2); |
| 1085 |
| 1086 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); |
| 1087 GURL about_blank_url = GURL(url::kAboutBlankURL); |
| 1088 GURL data_url = GURL("data:text/html,foo"); |
| 1089 |
| 1090 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1091 content::kChromeDevToolsScheme)); |
| 1092 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), |
| 1093 devtools_extension_devtools_page_rfh->GetLastCommittedURL()); |
| 1094 EXPECT_EQ(extension->GetResourceURL("/panel.html"), |
| 1095 devtools_extension_panel_rfh->GetLastCommittedURL()); |
| 1096 EXPECT_EQ(extension->GetResourceURL("/multi_frame_page.html"), |
| 1097 panel_frame_rfh->GetLastCommittedURL()); |
| 1098 EXPECT_EQ(about_blank_url, about_blank_frame_rfh->GetLastCommittedURL()); |
| 1099 EXPECT_EQ(data_url, data_frame_rfh->GetLastCommittedURL()); |
| 1100 EXPECT_EQ(web_url, web_frame_rfh->GetLastCommittedURL()); |
| 1101 |
| 1102 content::SiteInstance* devtools_instance = |
| 1103 main_devtools_rfh->GetSiteInstance(); |
| 1104 EXPECT_TRUE( |
| 1105 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1106 EXPECT_EQ(devtools_instance, |
| 1107 devtools_extension_devtools_page_rfh->GetSiteInstance()); |
| 1108 EXPECT_EQ(devtools_instance, devtools_extension_panel_rfh->GetSiteInstance()); |
| 1109 EXPECT_EQ(devtools_instance, panel_frame_rfh->GetSiteInstance()); |
| 1110 EXPECT_EQ(devtools_instance, about_blank_frame_rfh->GetSiteInstance()); |
| 1111 EXPECT_EQ(devtools_instance, data_frame_rfh->GetSiteInstance()); |
| 1112 EXPECT_EQ(web_url.host(), |
| 1113 web_frame_rfh->GetSiteInstance()->GetSiteURL().host()); |
| 1114 EXPECT_NE(devtools_instance, web_frame_rfh->GetSiteInstance()); |
| 1115 |
| 1116 // Check that if the web iframe navigates itself to about:blank, it stays in |
| 1117 // the web SiteInstance. |
| 1118 std::string about_blank_javascript = "location.href='about:blank';"; |
| 1119 |
| 1120 content::TestNavigationManager web_about_blank_manager(main_web_contents(), |
| 1121 about_blank_url); |
| 1122 |
| 1123 ASSERT_TRUE(content::ExecuteScript(web_frame_rfh, about_blank_javascript)); |
| 1124 |
| 1125 web_about_blank_manager.WaitForNavigationFinished(); |
| 1126 |
| 1127 EXPECT_EQ(about_blank_url, web_frame_rfh->GetLastCommittedURL()); |
| 1128 EXPECT_EQ(web_url.host(), |
| 1129 web_frame_rfh->GetSiteInstance()->GetSiteURL().host()); |
| 1130 EXPECT_NE(devtools_instance, web_frame_rfh->GetSiteInstance()); |
| 1131 |
| 1132 // Check that if the web IFrame is navigated back to a devtools extension |
| 1133 // page, it gets put back in the devtools process. |
| 1134 GURL extension_simple_url = |
| 1135 extension->GetResourceURL("/simple_test_page.html"); |
| 1136 std::string renavigation_javascript = |
| 1137 "location.href='" + extension_simple_url.spec() + "';"; |
| 1138 |
| 1139 content::TestNavigationManager renavigation_manager(main_web_contents(), |
| 1140 extension_simple_url); |
| 1141 |
| 1142 ASSERT_TRUE(content::ExecuteScript(web_frame_rfh, renavigation_javascript)); |
| 1143 |
| 1144 renavigation_manager.WaitForNavigationFinished(); |
| 1145 |
| 1146 // The old RFH is no longer valid after the renavigation, so we must get the |
| 1147 // new one. |
| 1148 RenderFrameHost* extension_simple_frame_rfh = |
| 1149 ChildFrameAt(panel_frame_rfh, 2); |
| 1150 |
| 1151 EXPECT_EQ(extension_simple_url, |
| 1152 extension_simple_frame_rfh->GetLastCommittedURL()); |
| 1153 EXPECT_EQ(devtools_instance, extension_simple_frame_rfh->GetSiteInstance()); |
| 1154 } |
| 1155 |
| 1156 // Tests that http Iframes within the sidebar pane page for the devtools |
| 1157 // extension that is visible in the elements panel are rendered in their own |
| 1158 // processes and not in the devtools process or the extension's process. This |
| 1159 // is tested because this is one of the extension pages with devtools access |
| 1160 // (https://developer.chrome.com/extensions/devtools). http://crbug.com/570483 |
| 1161 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1162 HttpIframeInDevToolsExtensionSideBarPane) { |
| 1163 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1164 |
| 1165 GURL web_url = embedded_test_server()->GetURL("a.com", "/title3.html"); |
| 1166 |
| 1167 // Install the dynamically-generated extension. |
| 1168 const Extension* extension = LoadExtensionForTest( |
| 1169 "Devtools Extension", "sidebarpane_devtools_page.html", web_url.spec()); |
| 1170 ASSERT_TRUE(extension); |
| 1171 |
| 1172 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1173 |
| 1174 // Wait for the extension's sidebarpane to finish loading -- it'll output |
| 1175 // 'PASS' when it's installed. waitForTestResultsInConsole waits until that |
| 1176 // 'PASS'. |
| 1177 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 1178 |
| 1179 // Now that we know the sidebarpane is loaded, switch to it. |
| 1180 content::TestNavigationManager web_manager(main_web_contents(), web_url); |
| 1181 SwitchToPanel(window_, "elements"); |
| 1182 // This is a bit of a hack to switch to the sidebar pane in the elements panel |
| 1183 // that the Iframe has been added to. |
| 1184 SwitchToPanel(window_, "iframe_pane"); |
| 1185 web_manager.WaitForNavigationFinished(); |
| 1186 |
| 1187 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1188 EXPECT_EQ(4U, rfhs.size()); |
| 1189 |
| 1190 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1191 RenderFrameHost* devtools_extension_devtools_page_rfh = |
| 1192 ChildFrameAt(main_devtools_rfh, 0); |
| 1193 RenderFrameHost* devtools_sidebar_pane_extension_rfh = |
| 1194 ChildFrameAt(main_devtools_rfh, 1); |
| 1195 RenderFrameHost* http_iframe_rfh = |
| 1196 ChildFrameAt(devtools_sidebar_pane_extension_rfh, 0); |
| 1197 |
| 1198 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1199 content::kChromeDevToolsScheme)); |
| 1200 EXPECT_EQ(extension->GetResourceURL("/sidebarpane_devtools_page.html"), |
| 1201 devtools_extension_devtools_page_rfh->GetLastCommittedURL()); |
| 1202 EXPECT_EQ(extension->GetResourceURL("/panel.html"), |
| 1203 devtools_sidebar_pane_extension_rfh->GetLastCommittedURL()); |
| 1204 EXPECT_EQ(web_url, http_iframe_rfh->GetLastCommittedURL()); |
| 1205 |
| 1206 content::SiteInstance* devtools_instance = |
| 1207 main_devtools_rfh->GetSiteInstance(); |
| 1208 EXPECT_TRUE( |
| 1209 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1210 EXPECT_EQ(devtools_instance, |
| 1211 devtools_extension_devtools_page_rfh->GetSiteInstance()); |
| 1212 EXPECT_EQ(devtools_instance, |
| 1213 devtools_sidebar_pane_extension_rfh->GetSiteInstance()); |
| 1214 EXPECT_EQ(web_url.host(), |
| 1215 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); |
| 1216 EXPECT_NE(devtools_instance, http_iframe_rfh->GetSiteInstance()); |
| 1217 } |
| 1218 |
| 1219 // Tests that http Iframes within the devtools background page, which is |
| 1220 // different from the extension's background page, are rendered in their own |
| 1221 // processes and not in the devtools process or the extension's process. This |
| 1222 // is tested because this is one of the extension pages with devtools access |
| 1223 // (https://developer.chrome.com/extensions/devtools). http://crbug.com/570483 |
| 1224 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1225 HttpIframeInDevToolsExtensionDevtools) { |
| 1226 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1227 |
| 1228 // Install the dynamically-generated extension. |
| 1229 const Extension* extension = |
| 1230 LoadExtensionForTest("Devtools Extension", "web_devtools_page.html", |
| 1231 "" /* panel_iframe_src */); |
| 1232 ASSERT_TRUE(extension); |
| 1233 |
| 1234 // Wait for a 'DONE' message sent from popup_iframe.html, indicating that it |
| 986 // loaded successfully. | 1235 // loaded successfully. |
| 987 content::DOMMessageQueue message_queue; | 1236 content::DOMMessageQueue message_queue; |
| 988 SwitchToExtensionPanel(window_, extension, "iframe_panel"); | |
| 989 std::string message; | 1237 std::string message; |
| 1238 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1239 |
| 990 while (true) { | 1240 while (true) { |
| 991 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 1241 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 992 if (message == "\"DONE\"") | 1242 if (message == "\"DONE\"") |
| 993 break; | 1243 break; |
| 994 } | 1244 } |
| 1245 |
| 1246 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1247 EXPECT_EQ(3U, rfhs.size()); |
| 1248 |
| 1249 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1250 RenderFrameHost* devtools_extension_devtools_page_rfh = |
| 1251 ChildFrameAt(main_devtools_rfh, 0); |
| 1252 RenderFrameHost* http_iframe_rfh = |
| 1253 ChildFrameAt(devtools_extension_devtools_page_rfh, 0); |
| 1254 |
| 1255 GURL web_url = embedded_test_server()->GetURL("a.com", "/popup_iframe.html"); |
| 1256 |
| 1257 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1258 content::kChromeDevToolsScheme)); |
| 1259 EXPECT_EQ(extension->GetResourceURL("/web_devtools_page.html"), |
| 1260 devtools_extension_devtools_page_rfh->GetLastCommittedURL()); |
| 1261 EXPECT_EQ(web_url, http_iframe_rfh->GetLastCommittedURL()); |
| 1262 |
| 1263 content::SiteInstance* devtools_instance = |
| 1264 main_devtools_rfh->GetSiteInstance(); |
| 1265 EXPECT_TRUE( |
| 1266 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1267 EXPECT_EQ(devtools_instance, |
| 1268 devtools_extension_devtools_page_rfh->GetSiteInstance()); |
| 1269 EXPECT_EQ(web_url.host(), |
| 1270 http_iframe_rfh->GetSiteInstance()->GetSiteURL().host()); |
| 1271 EXPECT_NE(devtools_instance, http_iframe_rfh->GetSiteInstance()); |
| 1272 } |
| 1273 |
| 1274 // Tests that iframes to a non-devtools extension embedded in a devtools |
| 1275 // extension will be isolated from devtools and the devtools extension. |
| 1276 // http://crbug.com/570483 |
| 1277 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1278 NonDevToolsExtensionInDevToolsExtension) { |
| 1279 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1280 |
| 1281 // Install the dynamically-generated non-devtools extension. |
| 1282 const Extension* non_devtools_extension = |
| 1283 LoadExtensionForTest("Non-DevTools Extension", "" /* devtools_page */, |
| 1284 "" /* panel_iframe_src */); |
| 1285 ASSERT_TRUE(non_devtools_extension); |
| 1286 |
| 1287 GURL non_dt_extension_test_url = |
| 1288 non_devtools_extension->GetResourceURL("/simple_test_page.html"); |
| 1289 |
| 1290 // Install the dynamically-generated devtools extension. |
| 1291 const Extension* devtools_extension = |
| 1292 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", |
| 1293 non_dt_extension_test_url.spec()); |
| 1294 ASSERT_TRUE(devtools_extension); |
| 1295 |
| 1296 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1297 |
| 1298 // Wait for the extension's panel to finish loading -- it'll output 'PASS' |
| 1299 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 1300 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 1301 |
| 1302 // Now that we know the panel is loaded, switch to it. |
| 1303 content::TestNavigationManager non_devtools_manager( |
| 1304 main_web_contents(), non_dt_extension_test_url); |
| 1305 SwitchToExtensionPanel(window_, devtools_extension, "iframe_panel"); |
| 1306 non_devtools_manager.WaitForNavigationFinished(); |
| 1307 |
| 1308 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1309 EXPECT_EQ(4U, rfhs.size()); |
| 1310 |
| 1311 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1312 RenderFrameHost* devtools_extension_devtools_page_rfh = |
| 1313 ChildFrameAt(main_devtools_rfh, 0); |
| 1314 RenderFrameHost* devtools_extension_panel_rfh = |
| 1315 ChildFrameAt(main_devtools_rfh, 1); |
| 1316 RenderFrameHost* non_devtools_extension_rfh = |
| 1317 ChildFrameAt(devtools_extension_panel_rfh, 0); |
| 1318 |
| 1319 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1320 content::kChromeDevToolsScheme)); |
| 1321 EXPECT_EQ(devtools_extension->GetResourceURL("/panel_devtools_page.html"), |
| 1322 devtools_extension_devtools_page_rfh->GetLastCommittedURL()); |
| 1323 EXPECT_EQ(devtools_extension->GetResourceURL("/panel.html"), |
| 1324 devtools_extension_panel_rfh->GetLastCommittedURL()); |
| 1325 EXPECT_EQ(non_dt_extension_test_url, |
| 1326 non_devtools_extension_rfh->GetLastCommittedURL()); |
| 1327 |
| 1328 // simple_test_page.html's frame should be in |non_devtools_extension|'s |
| 1329 // process, not in devtools or |devtools_extension|'s process. |
| 1330 content::SiteInstance* devtools_instance = |
| 1331 main_devtools_rfh->GetSiteInstance(); |
| 1332 EXPECT_TRUE( |
| 1333 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1334 EXPECT_EQ(devtools_instance, |
| 1335 devtools_extension_devtools_page_rfh->GetSiteInstance()); |
| 1336 EXPECT_EQ(devtools_instance, devtools_extension_panel_rfh->GetSiteInstance()); |
| 1337 EXPECT_EQ(non_dt_extension_test_url.GetOrigin(), |
| 1338 non_devtools_extension_rfh->GetSiteInstance()->GetSiteURL()); |
| 1339 EXPECT_NE(devtools_instance, non_devtools_extension_rfh->GetSiteInstance()); |
| 1340 } |
| 1341 |
| 1342 // Tests that if a devtools extension's devtools panel page has a subframe to a |
| 1343 // page for another devtools extension, the subframe is rendered in the devtools |
| 1344 // process as well. http://crbug.com/570483 |
| 1345 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1346 DevToolsExtensionInDevToolsExtension) { |
| 1347 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1348 |
| 1349 // Install the dynamically-generated extension. |
| 1350 const Extension* devtools_b_extension = |
| 1351 LoadExtensionForTest("Devtools Extension B", "simple_devtools_page.html", |
| 1352 "" /* panel_iframe_src */); |
| 1353 ASSERT_TRUE(devtools_b_extension); |
| 1354 |
| 1355 GURL extension_b_page_url = |
| 1356 devtools_b_extension->GetResourceURL("/simple_test_page.html"); |
| 1357 |
| 1358 // Install another dynamically-generated extension. This extension's |
| 1359 // panel.html's iframe will point to an extension b URL. |
| 1360 const Extension* devtools_a_extension = |
| 1361 LoadExtensionForTest("Devtools Extension A", "panel_devtools_page.html", |
| 1362 extension_b_page_url.spec()); |
| 1363 ASSERT_TRUE(devtools_a_extension); |
| 1364 |
| 1365 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1366 |
| 1367 // Wait for the extension's panel to finish loading -- it'll output 'PASS' |
| 1368 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 1369 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 1370 |
| 1371 // Now that we know the panel is loaded, switch to it. |
| 1372 content::TestNavigationManager extension_b_manager(main_web_contents(), |
| 1373 extension_b_page_url); |
| 1374 SwitchToExtensionPanel(window_, devtools_a_extension, "iframe_panel"); |
| 1375 extension_b_manager.WaitForNavigationFinished(); |
| 1376 |
| 1377 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1378 EXPECT_EQ(5U, rfhs.size()); |
| 1379 |
| 1380 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1381 |
| 1382 RenderFrameHost* devtools_extension_a_devtools_rfh = |
| 1383 content::FrameMatchingPredicate( |
| 1384 main_web_contents(), base::Bind(&content::FrameHasSourceUrl, |
| 1385 devtools_a_extension->GetResourceURL( |
| 1386 "/panel_devtools_page.html"))); |
| 1387 EXPECT_TRUE(devtools_extension_a_devtools_rfh); |
| 1388 RenderFrameHost* devtools_extension_b_devtools_rfh = |
| 1389 content::FrameMatchingPredicate( |
| 1390 main_web_contents(), base::Bind(&content::FrameHasSourceUrl, |
| 1391 devtools_b_extension->GetResourceURL( |
| 1392 "/simple_devtools_page.html"))); |
| 1393 EXPECT_TRUE(devtools_extension_b_devtools_rfh); |
| 1394 |
| 1395 RenderFrameHost* devtools_extension_a_panel_rfh = |
| 1396 ChildFrameAt(main_devtools_rfh, 2); |
| 1397 RenderFrameHost* devtools_extension_b_frame_rfh = |
| 1398 ChildFrameAt(devtools_extension_a_panel_rfh, 0); |
| 1399 |
| 1400 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1401 content::kChromeDevToolsScheme)); |
| 1402 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel_devtools_page.html"), |
| 1403 devtools_extension_a_devtools_rfh->GetLastCommittedURL()); |
| 1404 EXPECT_EQ(devtools_b_extension->GetResourceURL("/simple_devtools_page.html"), |
| 1405 devtools_extension_b_devtools_rfh->GetLastCommittedURL()); |
| 1406 EXPECT_EQ(devtools_a_extension->GetResourceURL("/panel.html"), |
| 1407 devtools_extension_a_panel_rfh->GetLastCommittedURL()); |
| 1408 EXPECT_EQ(extension_b_page_url, |
| 1409 devtools_extension_b_frame_rfh->GetLastCommittedURL()); |
| 1410 |
| 1411 // All frames should be in the devtools process. |
| 1412 content::SiteInstance* devtools_instance = |
| 1413 main_devtools_rfh->GetSiteInstance(); |
| 1414 EXPECT_TRUE( |
| 1415 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1416 EXPECT_EQ(devtools_instance, |
| 1417 devtools_extension_a_devtools_rfh->GetSiteInstance()); |
| 1418 EXPECT_EQ(devtools_instance, |
| 1419 devtools_extension_b_devtools_rfh->GetSiteInstance()); |
| 1420 EXPECT_EQ(devtools_instance, |
| 1421 devtools_extension_a_panel_rfh->GetSiteInstance()); |
| 1422 EXPECT_EQ(devtools_instance, |
| 1423 devtools_extension_b_frame_rfh->GetSiteInstance()); |
| 1424 } |
| 1425 |
| 1426 // Tests that a devtools extension can still have subframes to itself in a |
| 1427 // "devtools page" and that they will be rendered within the devtools process as |
| 1428 // well, not in the extension process. http://crbug.com/570483 |
| 1429 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, DevToolsExtensionInItself) { |
| 1430 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1431 |
| 1432 // Install the dynamically-generated extension. |
| 1433 const Extension* extension = |
| 1434 LoadExtensionForTest("Devtools Extension", "panel_devtools_page.html", |
| 1435 "/simple_test_page.html"); |
| 1436 ASSERT_TRUE(extension); |
| 1437 |
| 1438 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1439 |
| 1440 // Wait for the extension's panel to finish loading -- it'll output 'PASS' |
| 1441 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 1442 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 1443 |
| 1444 // Now that we know the panel is loaded, switch to it. |
| 1445 GURL extension_test_url = extension->GetResourceURL("/simple_test_page.html"); |
| 1446 content::TestNavigationManager test_page_manager(main_web_contents(), |
| 1447 extension_test_url); |
| 1448 SwitchToExtensionPanel(window_, extension, "iframe_panel"); |
| 1449 test_page_manager.WaitForNavigationFinished(); |
| 1450 |
| 1451 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1452 EXPECT_EQ(4U, rfhs.size()); |
| 1453 |
| 1454 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1455 RenderFrameHost* devtools_extension_devtools_page_rfh = |
| 1456 ChildFrameAt(main_devtools_rfh, 0); |
| 1457 RenderFrameHost* devtools_extension_panel_rfh = |
| 1458 ChildFrameAt(main_devtools_rfh, 1); |
| 1459 RenderFrameHost* devtools_extension_panel_frame_rfh = |
| 1460 ChildFrameAt(devtools_extension_panel_rfh, 0); |
| 1461 |
| 1462 // All frames should be in the devtools process, including |
| 1463 // simple_test_page.html |
| 1464 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1465 content::kChromeDevToolsScheme)); |
| 1466 EXPECT_EQ(extension->GetResourceURL("/panel_devtools_page.html"), |
| 1467 devtools_extension_devtools_page_rfh->GetLastCommittedURL()); |
| 1468 EXPECT_EQ(extension->GetResourceURL("/panel.html"), |
| 1469 devtools_extension_panel_rfh->GetLastCommittedURL()); |
| 1470 EXPECT_EQ(extension_test_url, |
| 1471 devtools_extension_panel_frame_rfh->GetLastCommittedURL()); |
| 1472 |
| 1473 content::SiteInstance* devtools_instance = |
| 1474 main_devtools_rfh->GetSiteInstance(); |
| 1475 EXPECT_TRUE( |
| 1476 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1477 EXPECT_EQ(devtools_instance, |
| 1478 devtools_extension_devtools_page_rfh->GetSiteInstance()); |
| 1479 EXPECT_EQ(devtools_instance, devtools_extension_panel_rfh->GetSiteInstance()); |
| 1480 EXPECT_EQ(devtools_instance, |
| 1481 devtools_extension_panel_frame_rfh->GetSiteInstance()); |
| 1482 } |
| 1483 |
| 1484 // Tests that a devtools (not a devtools extension) Iframe can be injected into |
| 1485 // devtools. http://crbug.com/570483 |
| 1486 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DevtoolsInDevTools) { |
| 1487 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1488 |
| 1489 GURL devtools_url = GURL(chrome::kChromeUIDevToolsURL); |
| 1490 |
| 1491 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1492 |
| 1493 std::string javascript = |
| 1494 "var devtoolsFrame = document.createElement('iframe');" |
| 1495 "document.body.appendChild(devtoolsFrame);" |
| 1496 "devtoolsFrame.src = '" + |
| 1497 devtools_url.spec() + "';"; |
| 1498 |
| 1499 RenderFrameHost* main_devtools_rfh = main_web_contents()->GetMainFrame(); |
| 1500 |
| 1501 content::TestNavigationManager manager(main_web_contents(), devtools_url); |
| 1502 ASSERT_TRUE(content::ExecuteScript(main_devtools_rfh, javascript)); |
| 1503 manager.WaitForNavigationFinished(); |
| 1504 |
| 1505 std::vector<RenderFrameHost*> rfhs = main_web_contents()->GetAllFrames(); |
| 1506 EXPECT_EQ(2U, rfhs.size()); |
| 1507 RenderFrameHost* devtools_iframe_rfh = ChildFrameAt(main_devtools_rfh, 0); |
| 1508 EXPECT_TRUE(main_devtools_rfh->GetLastCommittedURL().SchemeIs( |
| 1509 content::kChromeDevToolsScheme)); |
| 1510 EXPECT_EQ(devtools_url, devtools_iframe_rfh->GetLastCommittedURL()); |
| 1511 content::SiteInstance* devtools_instance = |
| 1512 main_devtools_rfh->GetSiteInstance(); |
| 1513 EXPECT_TRUE( |
| 1514 devtools_instance->GetSiteURL().SchemeIs(content::kChromeDevToolsScheme)); |
| 1515 EXPECT_EQ(devtools_instance, devtools_iframe_rfh->GetSiteInstance()); |
| 1516 |
| 1517 std::string message; |
| 1518 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 1519 devtools_iframe_rfh, "domAutomationController.send(document.origin)", |
| 1520 &message)); |
| 1521 EXPECT_EQ(devtools_url.GetOrigin().spec(), message + "/"); |
| 995 } | 1522 } |
| 996 | 1523 |
| 997 // Some web features, when used from an extension, are subject to browser-side | 1524 // 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 | 1525 // security policy enforcement. Make sure they work properly from inside a |
| 999 // devtools extension. | 1526 // devtools extension. |
| 1000 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, | 1527 IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, |
| 1001 DevToolsExtensionSecurityPolicyGrants) { | 1528 DevToolsExtensionSecurityPolicyGrants) { |
| 1002 ASSERT_TRUE(embedded_test_server()->Start()); | 1529 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1003 | 1530 |
| 1004 std::unique_ptr<extensions::TestExtensionDir> dir( | 1531 std::unique_ptr<extensions::TestExtensionDir> dir( |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); | 2121 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
| 1595 | 2122 |
| 1596 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 2123 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 1597 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 2124 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 1598 } | 2125 } |
| 1599 | 2126 |
| 1600 // Tests scripts panel showing. | 2127 // Tests scripts panel showing. |
| 1601 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 2128 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
| 1602 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 2129 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
| 1603 } | 2130 } |
| OLD | NEW |