| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |