OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 appName = 'com.google.chrome.test.echo'; | 5 var appName = 'com.google.chrome.test.echo'; |
6 | 6 |
7 chrome.test.getConfig(function(config) { | 7 chrome.test.getConfig(function(config) { |
8 chrome.test.runTests([ | 8 chrome.test.runTests([ |
9 function invalidHostName() { | 9 function invalidHostName() { |
10 var message = {"text": "Hello!"}; | 10 var message = {"text": "Hello!"}; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 }); | 69 }); |
70 }, | 70 }, |
71 | 71 |
72 // Verify that the case when host stops itself is handled properly. | 72 // Verify that the case when host stops itself is handled properly. |
73 function stopHost() { | 73 function stopHost() { |
74 port = chrome.extension.connectNative(appName); | 74 port = chrome.extension.connectNative(appName); |
75 | 75 |
76 port.onMessage.addListener(function(message) { | 76 port.onMessage.addListener(function(message) { |
77 port.onDisconnect.addListener(chrome.test.callback( | 77 port.onDisconnect.addListener(chrome.test.callback( |
78 function() {}, | 78 function() {}, |
79 "Error when communicating with the native messaging host.")); | 79 "Native host has exited.")); |
80 // Sending second message here should fail because the host has | |
81 // already stopped. | |
82 port.postMessage({ "secondMessage" : "foo" }); | |
83 }); | 80 }); |
84 | 81 |
85 // Send first message that should stop the host. | 82 // Send first message that should stop the host. |
86 port.postMessage({ "stopHostTest": true }); | 83 port.postMessage({ "stopHostTest": true }); |
87 } | 84 } |
88 ]); | 85 ]); |
89 }); | 86 }); |
OLD | NEW |