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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/shim/main.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/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':

Powered by Google App Engine
This is Rietveld 408576698