OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
Devlin
2015/10/30 01:21:44
ditto
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 chrome.runtime.onConnect.addListener(function(port) { | |
6 var succeed1 = chrome.test.callbackAdded(); | |
7 var succeed2 = chrome.test.callbackAdded(); | |
8 var succeed3 = chrome.test.callbackAdded(); | |
9 | |
10 port.onMessage.addListener(function(msg) { | |
11 console.log('port.onMessage was triggered.'); | |
Devlin
2015/10/30 01:21:43
nit: try to avoid noisy logs in tests. My general
robwu
2015/10/30 10:15:49
We have chrome.test.log, which causes messages to
Devlin
2015/10/30 16:03:51
Huh - thought that always logged. Apparently not.
| |
12 chrome.test.assertEq('Hello from content script', msg); | |
13 succeed1(); | |
14 }); | |
Devlin
2015/10/30 01:21:43
nit: newline
| |
15 port.onDisconnect.addListener(function() { | |
16 console.log('port.onDisconnect was triggered.'); | |
17 succeed2(); | |
18 }); | |
19 | |
20 chrome.tabs.sendMessage(port.sender.tab.id, '', function(reply) { | |
21 console.log('tab.sendMessage\'s response callback was invoked'); | |
22 chrome.test.assertEq('Reply here', reply); | |
23 succeed3(); | |
24 }); | |
25 }); | |
26 | |
27 chrome.test.getConfig(function(config) { | |
28 var url = 'http://localhost:' + config.testServer.port + | |
29 '/extensions/test_file.html?will_test_connect_and_sendMessage'; | |
Devlin
2015/10/30 01:21:44
nit: 4-space indent
| |
30 // Content script will try to connect and trigger onConnect. | |
31 chrome.tabs.create({ | |
32 url: url | |
33 }); | |
34 }); | |
OLD | NEW |