| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/tab_contents/tab_contents.h" | 7 #include "chrome/browser/tab_contents/tab_contents.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/test/ui_test_utils.h" | 9 #include "chrome/test/ui_test_utils.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // A web host that has permission. | 39 // A web host that has permission. |
| 40 ui_test_utils::NavigateToURL( | 40 ui_test_utils::NavigateToURL( |
| 41 browser(), web_resource.ReplaceComponents(make_host_a_com)); | 41 browser(), web_resource.ReplaceComponents(make_host_a_com)); |
| 42 std::string result; | 42 std::string result; |
| 43 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 43 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 44 browser()->GetSelectedTabContents()->render_view_host(), L"", | 44 browser()->GetSelectedTabContents()->render_view_host(), L"", |
| 45 L"window.domAutomationController.send(document.title)", | 45 L"window.domAutomationController.send(document.title)", |
| 46 &result)); | 46 &result)); |
| 47 EXPECT_EQ(result, "Loaded"); | 47 EXPECT_EQ(result, "Loaded"); |
| 48 | 48 |
| 49 // A web host that does not have permission. | 49 // A web host that loads a non-existent extension. |
| 50 ui_test_utils::NavigateToURL( | 50 GURL non_existent_extension( |
| 51 browser(), web_resource.ReplaceComponents(make_host_b_com)); | 51 test_server()->GetURL( |
| 52 "files/extensions/api_test/extension_resource_request_policy/" |
| 53 "non_existent_extension.html")); |
| 54 ui_test_utils::NavigateToURL(browser(), non_existent_extension); |
| 52 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 55 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 53 browser()->GetSelectedTabContents()->render_view_host(), L"", | 56 browser()->GetSelectedTabContents()->render_view_host(), L"", |
| 54 L"window.domAutomationController.send(document.title)", | 57 L"window.domAutomationController.send(document.title)", |
| 55 &result)); | 58 &result)); |
| 56 EXPECT_EQ(result, "Image failed to load"); | 59 EXPECT_EQ(result, "Image failed to load"); |
| 57 | 60 |
| 58 // A data URL. Data URLs should always be able to load chrome-extension:// | 61 // A data URL. Data URLs should always be able to load chrome-extension:// |
| 59 // resources. | 62 // resources. |
| 60 std::string file_source; | 63 std::string file_source; |
| 61 ASSERT_TRUE(file_util::ReadFileToString( | 64 ASSERT_TRUE(file_util::ReadFileToString( |
| 62 test_data_dir_.AppendASCII("extension_resource_request_policy") | 65 test_data_dir_.AppendASCII("extension_resource_request_policy") |
| 63 .AppendASCII("index.html"), &file_source)); | 66 .AppendASCII("index.html"), &file_source)); |
| 64 ui_test_utils::NavigateToURL(browser(), | 67 ui_test_utils::NavigateToURL(browser(), |
| 65 GURL(std::string("data:text/html;charset=utf-8,") + file_source)); | 68 GURL(std::string("data:text/html;charset=utf-8,") + file_source)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 EXPECT_TRUE(RunExtensionSubtest( | 102 EXPECT_TRUE(RunExtensionSubtest( |
| 100 "extension_resource_request_policy/extension2", | 103 "extension_resource_request_policy/extension2", |
| 101 "audio.html")); | 104 "audio.html")); |
| 102 } | 105 } |
| 103 | 106 |
| 104 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Video) { | 107 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Video) { |
| 105 EXPECT_TRUE(RunExtensionSubtest( | 108 EXPECT_TRUE(RunExtensionSubtest( |
| 106 "extension_resource_request_policy/extension2", | 109 "extension_resource_request_policy/extension2", |
| 107 "video.html")); | 110 "video.html")); |
| 108 } | 111 } |
| OLD | NEW |