Index: chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
index 7626d5189a8f9549574ef03e9d470dfc14f680d8..401c08c69a600e0efbaf40df11aee4abee161df2 100644 |
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js |
@@ -1078,6 +1078,31 @@ function testContentScriptIsInjectedAfterTerminateAndReloadWebView() { |
document.body.appendChild(webview); |
} |
+function testAddContentScriptWithCode() { |
+ var webview = document.createElement('webview'); |
+ |
+ console.log("Step 1: call <webview>.addContentScripts."); |
+ webview.addContentScripts( |
+ [{"name": 'myrule', |
+ "matches": ["http://*/extensions/*"], |
+ "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;"}, |
+ function(results) { |
+ embedder.test.assertEq(1, results.length); |
+ embedder.test.assertEq('red', results[0]); |
+ embedder.test.succeed(); |
+ }); |
+ }); |
+ |
+ webview.src = embedder.emptyGuestURL; |
+ document.body.appendChild(webview); |
+} |
+ |
function testExecuteScriptFail() { |
var webview = document.createElement('webview'); |
document.body.appendChild(webview); |
@@ -2562,6 +2587,7 @@ embedder.test.testList = { |
testAddContentScriptsWithNewWindowAPI, |
'testContentScriptIsInjectedAfterTerminateAndReloadWebView': |
testContentScriptIsInjectedAfterTerminateAndReloadWebView, |
+ 'testAddContentScriptWithCode': testAddContentScriptWithCode, |
'testExecuteScriptFail': testExecuteScriptFail, |
'testExecuteScript': testExecuteScript, |
'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': |