Bug 1163861 - Include windowID in all WebRequest notifications (r=Mossop)
authorBill McCloskey <billm@mozilla.com>
Fri, 08 May 2015 15:04:27 -0700
changeset 247882 dace68100bfd
parent 247881 6cc408deebe7
child 247883 fd26eba375ae
push id28885
push usercbook@mozilla.com
push date2015-06-10 13:18 +0000
treeherdermozilla-central@e101c589c242 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs1163861
milestone41.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 1163861 - Include windowID in all WebRequest notifications (r=Mossop)
toolkit/modules/addons/WebRequest.jsm
toolkit/modules/tests/browser/browser_WebRequest.js
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -240,33 +240,36 @@ let HttpObserverManager = {
            WebRequestCommon.urlMatches(uri, filter.urls);
   },
 
   runChannelListener(request, kind) {
     let listeners = this.listeners[kind];
     let channel = request.QueryInterface(Ci.nsIHttpChannel);
     let loadContext = this.getLoadContext(channel);
     let browser = loadContext ? loadContext.topFrameElement : null;
-    let policyType = channel.loadInfo.contentPolicyType;
+    let loadInfo = channel.loadInfo;
+    let policyType = loadInfo.contentPolicyType;
 
     let requestHeaders;
     let responseHeaders;
 
     let includeStatus = kind == "headersReceived" || kind == "onStart" || kind == "onStop";
 
     for (let [callback, opts] of listeners.entries()) {
       if (!this.shouldRunListener(policyType, channel.URI, opts.filter)) {
         continue;
       }
 
       let data = {
         url: channel.URI.spec,
         method: channel.requestMethod,
         browser: browser,
         type: WebRequestCommon.typeForPolicyType(policyType),
+        windowId: loadInfo.outerWindowID,
+        parentWindowId: loadInfo.parentOuterWindowID,
       };
       if (opts.requestHeaders) {
         if (!requestHeaders) {
           requestHeaders = this.getHeaders(channel, "visitRequestHeaders");
         }
         data.requestHeaders = requestHeaders;
       }
       if (opts.responseHeaders) {
--- a/toolkit/modules/tests/browser/browser_WebRequest.js
+++ b/toolkit/modules/tests/browser/browser_WebRequest.js
@@ -58,16 +58,19 @@ let sendHeaders = [];
 function onBeforeSendHeaders(details)
 {
   info(`onBeforeSendHeaders ${details.url}`);
   if (details.url.startsWith(BASE)) {
     sendHeaders.push(details.url);
 
     is(details.browser, expected_browser, "correct <browser> element");
     checkType(details);
+
+    let id = windowIDs.get(details.url);
+    is(id, details.windowId, "window ID same in onBeforeSendHeaders as onBeforeRequest");
   }
   if (details.url.indexOf("_redirect.") != -1) {
     return {redirectUrl: details.url.replace("_redirect.", "_good.")};
   }
 }
 
 let headersReceived = [];