OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 chrome.runtime.onConnect.addListener(function(port) { | 5 chrome.runtime.onConnect.addListener(function(port) { |
6 port.onMessage.addListener(function(msg) { | 6 port.onMessage.addListener(function(msg) { |
7 if (msg.testSendMessageToFrame) { | 7 if (msg.testSendMessageToFrame) { |
8 // page.js created this frame with an unique digit starting at 0. | 8 // page.js created this frame with an unique digit starting at 0. |
9 // This number is used in test.js to identify messages from this frame. | 9 // This number is used in test.js to identify messages from this frame. |
10 var test_id = location.search.slice(-1); | 10 var test_id = location.search.slice(-1); |
11 port.postMessage('from_' + test_id); | 11 port.postMessage('from_' + test_id); |
| 12 } else if (msg.testConnectChildFrameAndNavigate) { |
| 13 location.search = '?testConnectChildFrameAndNavigateDone'; |
12 } | 14 } |
13 }); | 15 }); |
14 }); | 16 }); |
15 | 17 |
16 // continuation of testSendMessageFromFrame() | 18 // continuation of testSendMessageFromFrame() |
17 chrome.runtime.sendMessage({frameUrl: location.href}); | 19 if (location.search.lastIndexOf('?testSendMessageFromFrame', 0) === 0) { |
| 20 chrome.runtime.sendMessage({frameUrl: location.href}); |
| 21 } else if (location.search === '?testConnectChildFrameAndNavigateSetup') { |
| 22 // continuation of connectChildFrameAndNavigate() 1/2 |
| 23 chrome.runtime.sendMessage('testConnectChildFrameAndNavigateSetupDone'); |
| 24 } |
OLD | NEW |