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: Created March 2, 2015, 11:57 a.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') | chrome/ext/popup.js » ('J')
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 messsage were sent by content script.
kzar 2015/03/02 19:00:32 Nit: "...if the message was sent by a..."
Sebastian Noack 2015/03/02 19:42:08 Done.
+ // 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') | chrome/ext/popup.js » ('J')

Powered by Google App Engine
This is Rietveld