Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Side by Side Diff: chrome/test/data/extensions/api_test/messaging/connect/frame.js

Issue 1413543005: Use FrameTreeNode ID as frameId in extension APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Vend frameIds at 1 location; minimize thread hops for webRequest Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698