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

Side by Side 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: nits 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function createWebview() { 5 function createWebview() {
6 var webview = document.createElement('webview'); 6 var webview = document.createElement('webview');
7 document.body.appendChild(webview); 7 document.body.appendChild(webview);
8 return webview; 8 return webview;
9 } 9 }
10 10
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 chrome.send('testResult', [true]); 372 chrome.send('testResult', [true]);
373 return; 373 return;
374 } 374 }
375 console.log('Unexpected message: \'' + data[0] + '\''); 375 console.log('Unexpected message: \'' + data[0] + '\'');
376 chrome.send('testResult', [false]); 376 chrome.send('testResult', [false]);
377 }); 377 });
378 378
379 webview.src = url; 379 webview.src = url;
380 document.body.appendChild(webview); 380 document.body.appendChild(webview);
381 } 381 }
382
383 function testAddContentScriptWithCode(url) {
384 var webview = document.createElement('webview');
385
386 console.log("Step 1: call <webview>.addContentScripts.");
387 webview.addContentScripts(
388 [{"name": 'myrule',
389 "matches": ["http://*/empty*"],
xiyuan 2015/04/08 15:54:02 nit: double quote -> single quote in all places.
390 "code": 'document.body.style.backgroundColor = \"red\";',
391 "run_at": 'document_end'}]);
392
393 webview.addEventListener('loadstop', function() {
394 console.log('Step 2: call webview.executeScript() to check result.')
395 webview.executeScript({
396 code: "document.body.style.backgroundColor;"
397 }, onGetBackgroundExecuted);
398 });
399
400 webview.src = url;
401 document.body.appendChild(webview);
402 }
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/platform_apps/web_view/shim/main.js ('k') | chrome/test/data/webui/webview_execute_script_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698