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

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

Issue 1058113002: Implement <webview>.addContentScript/removeContentScript API [3] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webui_api_1
Patch Set: 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
index b59666e6444d37230d3aeb6f7ca375ebd9907379..39c5aa4ba5e816a8634b47ecded17cc5d058f77d 100644
--- a/chrome/test/data/webui/webview_execute_script_test.js
+++ b/chrome/test/data/webui/webview_execute_script_test.js
@@ -379,3 +379,24 @@ function testContentScriptIsInjectedAfterTerminateAndReloadWebView(url) {
webview.src = url;
document.body.appendChild(webview);
}
+
+function testAddContentScriptWithCode(url) {
+ var webview = document.createElement('webview');
+
+ console.log("Step 1: call <webview>.addContentScripts.");
+ webview.addContentScripts(
+ [{"name": 'myrule',
+ "matches": ["http://*/empty*"],
+ "code": ["document.body.style.backgroundColor = \"red\";"],
+ "run_at": "document_end"}]);
+
+ webview.addEventListener('loadstop', function() {
+ console.log('Step 2: call webview.executeScript() to check result.')
+ webview.executeScript({
+ code: "document.body.style.backgroundColor;"
+ }, onGetBackgroundExecuted);
+ });
+
+ webview.src = url;
+ document.body.appendChild(webview);
+}

Powered by Google App Engine
This is Rietveld 408576698