Bug 1223116 P2 Make webconsole use new nsIServiceWorkerManager.shouldReportToWindow(). r=bgrins

This commit is contained in:
Ben Kelly 2015-11-16 08:04:12 -08:00
parent a7dd691c86
commit 775e208fab

View File

@ -18,6 +18,11 @@ loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
XPCOMUtils.defineLazyServiceGetter(this,
"swm",
"@mozilla.org/serviceworkers/manager;1",
"nsIServiceWorkerManager");
// Match the function name from the result of toString() or toSource().
//
// Examples:
@ -126,29 +131,6 @@ var WebConsoleUtils = {
aTo.style.fontStyle = style.getPropertyCSSValue("font-style").cssText;
},
/**
* Recursively gather a list of window locations given
* a top level window.
*
* @param nsIDOMWindow aWindow
* @return Array
* list of window locations as strings
*/
getLocationsForFrames: function(aWindow)
{
let location = aWindow.location.toString();
let locations = [location];
if (aWindow.frames) {
for (let i = 0; i < aWindow.frames.length; i++) {
let frame = aWindow.frames[i];
locations = locations.concat(this.getLocationsForFrames(frame));
}
}
return locations;
},
/**
* Gets the ID of the inner window of this DOM window.
*
@ -994,9 +976,8 @@ ConsoleAPIListener.prototype =
// scope, which can be used to determine whether it's controlling
// a window.
let scope = message.ID;
let locations = WebConsoleUtils.getLocationsForFrames(this.window);
if (!locations.some(loc => loc.startsWith(scope))) {
if (!swm.shouldReportToWindow(this.window, scope)) {
return false;
}
}