OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 output(msg) { | 5 function output(msg) { |
6 chrome.devtools.inspectedWindow.eval("console.log(unescape('" + | 6 chrome.devtools.inspectedWindow.eval("console.log(unescape('" + |
7 escape(msg) + "'));") | 7 escape(msg) + "'));") |
8 } | 8 } |
9 | 9 |
10 var hadErrors = false; | 10 var hadErrors = false; |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 function step1() { | 25 function step1() { |
26 chrome.extension.sendRequest("foo", function(response) { | 26 chrome.extension.sendRequest("foo", function(response) { |
27 assertEquals('onRequest callback: "foo"', response); | 27 assertEquals('onRequest callback: "foo"', response); |
28 step2(); | 28 step2(); |
29 }); | 29 }); |
30 } | 30 } |
31 | 31 |
32 function step2() { | 32 function step2() { |
33 var object = { "string": "foo", "number": 42 }; | 33 var object = [{"string": "foo"}, {"number": 42}]; |
34 chrome.extension.sendRequest(object, function(response) { | 34 chrome.extension.sendRequest(object, function(response) { |
35 assertEquals('onRequest callback: ' + JSON.stringify(object), response); | 35 assertEquals('onRequest callback: ' + JSON.stringify(object), response); |
36 step3(); | 36 step3(); |
37 }); | 37 }); |
38 } | 38 } |
39 | 39 |
40 function step3() { | 40 function step3() { |
41 function onMessage(message) { | 41 function onMessage(message) { |
42 assertEquals("port.onMessage: foo", message); | 42 assertEquals("port.onMessage: foo", message); |
43 completeTest(); | 43 completeTest(); |
44 } | 44 } |
45 var port = chrome.runtime.connect(); | 45 var port = chrome.runtime.connect(); |
46 port.onMessage.addListener(onMessage); | 46 port.onMessage.addListener(onMessage); |
47 port.postMessage("foo"); | 47 port.postMessage("foo"); |
48 } | 48 } |
49 | 49 |
50 step1(); | 50 step1(); |
OLD | NEW |