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

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 var REQUEST_TO_COMM_CHANNEL_1 = 'connect'; 5 var REQUEST_TO_COMM_CHANNEL_1 = 'connect';
6 var REQUEST_TO_COMM_CHANNEL_2 = 'connect_request'; 6 var REQUEST_TO_COMM_CHANNEL_2 = 'connect_request';
7 var RESPONSE_FROM_COMM_CHANNEL_1 = 'connected'; 7 var RESPONSE_FROM_COMM_CHANNEL_1 = 'connected';
8 var RESPONSE_FROM_COMM_CHANNEL_2 = 'connected_response'; 8 var RESPONSE_FROM_COMM_CHANNEL_2 = 'connected_response';
9 9
10 function createWebview() { 10 function createWebview() {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 console.log('Step 5: check the result of content script injected again.'); 437 console.log('Step 5: check the result of content script injected again.');
438 webview.executeScript({ 438 webview.executeScript({
439 code: 'document.body.style.backgroundColor;' 439 code: 'document.body.style.backgroundColor;'
440 }, onGetBackgroundExecuted); 440 }, onGetBackgroundExecuted);
441 } 441 }
442 }); 442 });
443 443
444 webview.src = url; 444 webview.src = url;
445 document.body.appendChild(webview); 445 document.body.appendChild(webview);
446 } 446 }
447
448 function testAddContentScriptWithCode(url) {
449 var webview = document.createElement('webview');
450
451 console.log('Step 1: call <webview>.addContentScripts.');
452 webview.addContentScripts(
453 [{'name': 'myrule',
454 'matches': ['http://*/empty*'],
455 'code': 'document.body.style.backgroundColor = \'red\';',
456 'run_at': 'document_end'}]);
457
458 webview.addEventListener('loadstop', function() {
459 console.log('Step 2: call webview.executeScript() to check result.')
460 webview.executeScript({
461 code: 'document.body.style.backgroundColor;'
462 }, onGetBackgroundExecuted);
463 });
464
465 webview.src = url;
466 document.body.appendChild(webview);
467 }
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