Index: chrome/test/data/extensions/api_test/messaging/connect_crash/page.js |
diff --git a/chrome/test/data/extensions/api_test/messaging/connect_crash/page.js b/chrome/test/data/extensions/api_test/messaging/connect_crash/page.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b3fc833ace622b5a95755fe6b82d964d6739d57c |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/messaging/connect_crash/page.js |
@@ -0,0 +1,24 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var port = chrome.runtime.connect(); |
+port.onDisconnect.addListener(function() { |
+ chrome.test.fail('onDisconnect should not be triggered because the ' + |
+ 'background page exists and the tab should have been crashed'); |
+}); |
+ |
+var ref; |
+chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { |
+ chrome.test.assertEq('Rob says hi', msg); |
+ port.postMessage('is_ready_to_crash'); |
+ // Keep the callback around to avoid test flakiness due to GC. |
+ ref = sendResponse; |
+ |
+ // TODO(robwu): Remove the following line once crbug.com/439780 is fixed. |
+ // (the response callback is not automatically invoked when the tab crashes). |
+ sendResponse(); |
+ |
+ // Keep the port open - do not send a response. |
+ return true; |
+}); |