| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/macros.h" | 5 #include "base/macros.h" | 
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" | 
| 7 #include "chrome/common/chrome_paths.h" | 7 #include "chrome/common/chrome_paths.h" | 
| 8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" | 
| 9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" | 
| 10 #include "chrome/test/base/web_ui_browser_test.h" | 10 #include "chrome/test/base/web_ui_browser_test.h" | 
| 11 #include "net/test/embedded_test_server/embedded_test_server.h" | 11 #include "net/test/embedded_test_server/embedded_test_server.h" | 
| 12 | 12 | 
| 13 class WebUIWebViewBrowserTest : public WebUIBrowserTest { | 13 class WebUIWebViewBrowserTest : public WebUIBrowserTest { | 
| 14  public: | 14  public: | 
| 15   WebUIWebViewBrowserTest() {} | 15   WebUIWebViewBrowserTest() {} | 
| 16 | 16 | 
| 17   void SetUpOnMainThread() override { | 17   void SetUpOnMainThread() override { | 
| 18     WebUIBrowserTest::SetUpOnMainThread(); | 18     WebUIBrowserTest::SetUpOnMainThread(); | 
| 19     AddLibrary( | 19     AddLibrary( | 
| 20         base::FilePath(FILE_PATH_LITERAL("webview_execute_script_test.js"))); | 20         base::FilePath(FILE_PATH_LITERAL("webview_content_script_test.js"))); | 
| 21 | 21 | 
| 22     base::FilePath test_data_dir; | 22     base::FilePath test_data_dir; | 
| 23     PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 23     PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 
| 24     embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 24     embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 
| 25     ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 25     ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 
| 26   } | 26   } | 
| 27 | 27 | 
| 28   GURL GetTestUrl(const std::string& path) const { | 28   GURL GetTestUrl(const std::string& path) const { | 
| 29     return embedded_test_server()->base_url().Resolve(path); | 29     return embedded_test_server()->base_url().Resolve(path); | 
| 30   } | 30   } | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 116 } | 116 } | 
| 117 | 117 | 
| 118 IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, | 118 IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, | 
| 119                        ContentScriptExistsAsLongAsWebViewTagExists) { | 119                        ContentScriptExistsAsLongAsWebViewTagExists) { | 
| 120   ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()); | 120   ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()); | 
| 121 | 121 | 
| 122   ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest( | 122   ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest( | 
| 123       "testContentScriptExistsAsLongAsWebViewTagExists", | 123       "testContentScriptExistsAsLongAsWebViewTagExists", | 
| 124       new base::StringValue(GetTestUrl("empty.html").spec()))); | 124       new base::StringValue(GetTestUrl("empty.html").spec()))); | 
| 125 } | 125 } | 
|  | 126 | 
|  | 127 IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddContentScriptWithCode) { | 
|  | 128   ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()); | 
|  | 129 | 
|  | 130   ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest( | 
|  | 131       "testAddContentScriptWithCode", | 
|  | 132       new base::StringValue(GetTestUrl("empty.html").spec()))); | 
|  | 133 } | 
| OLD | NEW | 
|---|