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