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

Unified Diff: chrome/test/data/webui/webview_execute_script_test.js

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/test/data/webui/webview_execute_script_test.js
diff --git a/chrome/test/data/webui/webview_execute_script_test.js b/chrome/test/data/webui/webview_execute_script_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..bdde12df5214afa7e35941afb080b7474f983715
--- /dev/null
+++ b/chrome/test/data/webui/webview_execute_script_test.js
@@ -0,0 +1,32 @@
+// 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.
+
+function createWebview() {
+ var webview = document.createElement('webview');
+ document.body.appendChild(webview);
+ return webview;
+}
+
+function testExecuteScriptCode(url) {
+ var webview = createWebview();
+
+ var onGetBackgroundExecuted = function(results) {
+ chrome.send('testResult', [results.length == 1 && results[0] == 'red']);
+ };
+
+ var onSetBackgroundExecuted = function() {
+ webview.executeScript({
+ code: 'document.body.style.backgroundColor'
Devlin 2015/03/09 16:04:42 nit: add a semicolon.
Xi Han 2015/03/09 17:59:56 Tried to add a semicolon, but the semicolon caused
Devlin 2015/03/09 18:07:59 I find that very surprising. To be clear, I'm sug
Xi Han 2015/03/09 18:28:33 You are right. I put the semicolon after the "'",
+ }, onGetBackgroundExecuted);
+ };
+
+ var onLoadStop = function() {
+ webview.executeScript({
+ code: 'document.body.style.backgroundColor = \'red\''
Devlin 2015/03/09 16:04:42 nit: add a semicolon.
Xi Han 2015/03/09 17:59:56 Same above.
+ }, onSetBackgroundExecuted);
+ };
+
+ webview.addEventListener('loadstop', onLoadStop);
+ webview.src = url;
+}

Powered by Google App Engine
This is Rietveld 408576698