Bug 1394841 - Check iframes for related tabs in WebExt. r=kmag
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 01 Nov 2017 17:19:19 -0500
changeset 444238 4aa421a32de9a1bb122062ebec128cea5789baa8
parent 444237 b98366a27c05e617771746cd10f1f685a1b82dff
child 444239 134b46ce0aa580d9b181cc7d1ad3752fd7cc6460
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1394841
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394841 - Check iframes for related tabs in WebExt. r=kmag When using WebExt messaging with Responsive Design Mode, message manager messages traveling from content to parent such as "MessageChannel:Messages" are received with `event.target` set to the <iframe mozbrowser> inside RDM that hosts the content. Here we change `getSender` processing for messages like this to also check HTML iframes for related tabs, in addition to XUL elements as before. MozReview-Commit-ID: 3qphe2W8jHM
browser/components/extensions/ext-browser.js
--- a/browser/components/extensions/ext-browser.js
+++ b/browser/components/extensions/ext-browser.js
@@ -30,17 +30,18 @@ let windowTracker;
 const getSender = (extension, target, sender) => {
   let tabId;
   if ("tabId" in sender) {
     // The message came from a privileged extension page running in a tab. In
     // that case, it should include a tabId property (which is filled in by the
     // page-open listener below).
     tabId = sender.tabId;
     delete sender.tabId;
-  } else if (target instanceof Ci.nsIDOMXULElement) {
+  } else if (target instanceof Ci.nsIDOMXULElement ||
+             ExtensionUtils.instanceOf(target, "HTMLIFrameElement")) {
     tabId = tabTracker.getBrowserData(target).tabId;
   }
 
   if (tabId) {
     let tab = extension.tabManager.get(tabId, null);
     if (tab) {
       sender.tab = tab.convert();
     }