Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4293)

Unified Diff: chrome/browser/ui/webui/webui_webview_browsertest.cc

Issue 942533003: Enable <webview>.executeScript outside of Apps and Extensions [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_routingid_user_script_UserScriptSet_non_hostset_2
Patch Set: Add a test. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/webui_webview_browsertest.cc
diff --git a/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chrome/browser/ui/webui/webui_webview_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9750dba172a34181e78a62b7270a2962dac283eb
--- /dev/null
+++ b/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/macros.h"
+#include "base/path_service.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/base/web_ui_browser_test.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+
+class WebUIWebViewBrowserTest : public WebUIBrowserTest {
+ public:
+ WebUIWebViewBrowserTest() {}
+
+ void SetUpOnMainThread() override {
+ WebUIBrowserTest::SetUpOnMainThread();
+ AddLibrary(
+ base::FilePath(FILE_PATH_LITERAL("webview_execute_script_test.js")));
+
+ base::FilePath test_data_dir;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ }
+
+ GURL GetTestUrl(const std::string& path) const {
+ return embedded_test_server()->base_url().Resolve(path);
+ }
+
+ GURL GetWebViewEnabledWebUIURL() const {
+ return GURL(chrome::kChromeUIChromeSigninURL);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebUIWebViewBrowserTest);
+};
+
+IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, ExecuteScriptCode) {
+ ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL());
+
+ ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
+ "testExecuteScriptCode",
+ new base::StringValue(GetTestUrl("empty.html").spec())));
+}

Powered by Google App Engine
This is Rietveld 408576698