OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 function createWebview() { | |
6 var webview = document.createElement('webview'); | |
7 document.body.appendChild(webview); | |
8 return webview; | |
9 } | |
10 | |
11 function testExecuteScriptCode(url) { | |
12 var webview = createWebview(); | |
13 | |
14 var onGetBackgroundExecuted = function(results) { | |
15 chrome.send('testResult', [results.length == 1 && results[0] == 'red']); | |
16 }; | |
17 | |
18 var onSetBackgroundExecuted = function() { | |
19 webview.executeScript({ | |
20 code: 'document.body.style.backgroundColor' | |
Devlin
2015/03/09 16:04:42
nit: add a semicolon.
Xi Han
2015/03/09 17:59:56
Tried to add a semicolon, but the semicolon caused
Devlin
2015/03/09 18:07:59
I find that very surprising. To be clear, I'm sug
Xi Han
2015/03/09 18:28:33
You are right. I put the semicolon after the "'",
| |
21 }, onGetBackgroundExecuted); | |
22 }; | |
23 | |
24 var onLoadStop = function() { | |
25 webview.executeScript({ | |
26 code: 'document.body.style.backgroundColor = \'red\'' | |
Devlin
2015/03/09 16:04:42
nit: add a semicolon.
Xi Han
2015/03/09 17:59:56
Same above.
| |
27 }, onSetBackgroundExecuted); | |
28 }; | |
29 | |
30 webview.addEventListener('loadstop', onLoadStop); | |
31 webview.src = url; | |
32 } | |
OLD | NEW |