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

Unified Diff: chrome/test/data/webui/webview_content_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: Rebase and replace \" by \'. Created 5 years, 8 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_content_script_test.js
diff --git a/chrome/test/data/webui/webview_execute_script_test.js b/chrome/test/data/webui/webview_content_script_test.js
similarity index 95%
rename from chrome/test/data/webui/webview_execute_script_test.js
rename to chrome/test/data/webui/webview_content_script_test.js
index e2cdb7294922b47000f0ae3900d098fbd03615eb..bf18e75b13223ce5ec1bcbf0582e920f55a5097e 100644
--- a/chrome/test/data/webui/webview_execute_script_test.js
+++ b/chrome/test/data/webui/webview_content_script_test.js
@@ -436,3 +436,24 @@ function testContentScriptExistsAsLongAsWebViewTagExists(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