Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/ext/background.js

Issue 5703008528629760: Issue 2071 - Fixed issues when sending messages from the popup to the background page (Closed)
Patch Set: Addressed comment Created March 2, 2015, 7:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/ext/popup.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -433,9 +433,14 @@
chrome.runtime.onMessage.addListener(function(message, rawSender, sendResponse)
{
- var sender = {
- page: new Page(rawSender.tab),
- frame: {
+ var sender = {};
+
+ // Add "page" and "frame" if the message was sent by a content script.
+ // If sent by popup or the background page itself, there is no "tab".
+ if ("tab" in rawSender)
+ {
+ sender.page = new Page(rawSender.tab);
+ sender.frame = {
url: new URL(rawSender.url),
get parent()
{
@@ -463,8 +468,8 @@
return frames[0];
}
- }
- };
+ };
+ }
return ext.onMessage._dispatch(message, sender, sendResponse).indexOf(true) != -1;
});
« no previous file with comments | « no previous file | chrome/ext/popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld