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; |
}); |