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

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: 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 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 console.log('Step 5: check the result of content script injected again.'); 429 console.log('Step 5: check the result of content script injected again.');
430 webview.executeScript({ 430 webview.executeScript({
431 code: 'document.body.style.backgroundColor;' 431 code: 'document.body.style.backgroundColor;'
432 }, onGetBackgroundExecuted); 432 }, onGetBackgroundExecuted);
433 } 433 }
434 }); 434 });
435 435
436 webview.src = url; 436 webview.src = url;
437 document.body.appendChild(webview); 437 document.body.appendChild(webview);
438 } 438 }
439
440 function testAddContentScriptWithCode(url) {
441 var webview = document.createElement('webview');
442
443 console.log("Step 1: call <webview>.addContentScripts.");
444 webview.addContentScripts(
445 [{"name": 'myrule',
446 "matches": ['http://*/empty*'],
447 "code": 'document.body.style.backgroundColor = \'red\';',
448 "run_at": 'document_end'}]);
449
450 webview.addEventListener('loadstop', function() {
451 console.log('Step 2: call webview.executeScript() to check result.')
452 webview.executeScript({
453 code: 'document.body.style.backgroundColor;'
454 }, onGetBackgroundExecuted);
455 });
456
457 webview.src = url;
458 document.body.appendChild(webview);
459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698