| Index: chrome/content/ui/sendReport.js |
| =================================================================== |
| --- a/chrome/content/ui/sendReport.js |
| +++ b/chrome/content/ui/sendReport.js |
| @@ -24,17 +24,20 @@ let {FileUtils} = Cu.import("resource:// |
| let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", {}); |
| const MILLISECONDS_IN_SECOND = 1000; |
| const SECONDS_IN_MINUTE = 60; |
| const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; |
| const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; |
| let contentWindow = window.arguments[0]; |
| -let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1] : null); |
| +let windowURI = window.arguments[1]; |
| +if (typeof windowURI == "string") |
| + windowURI = Services.newURI(windowURI, null, null); |
| +let browser = window.arguments[2]; |
| let reportData = new DOMParser().parseFromString("<report></report>", "text/xml"); |
| // Some helper functions to work with the report data |
| function reportElement(tag) |
| { |
| for (let child = reportData.documentElement.firstChild; child; child = child.nextSibling) |
| if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tag) |
| @@ -104,17 +107,17 @@ function serializeReportData() |
| // |
| // Data collectors |
| // |
| var reportsListDataSource = |
| { |
| list: [], |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let data = Prefs.recentReports; |
| if (data && "length" in data) |
| { |
| for (let i = 0; i < data.length; i++) |
| { |
| let entry = data[i]; |
| if (typeof entry.reportURL == "string" && entry.reportURL && |
| @@ -187,17 +190,17 @@ var reportsListDataSource = |
| var requestsDataSource = |
| { |
| requests: reportElement("requests"), |
| origRequests: [], |
| requestNotifier: null, |
| callback: null, |
| nodeByKey: Object.create(null), |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
| .getInterface(Ci.nsIDOMWindowUtils) |
| .outerWindowID; |
| this.callback = callback; |
| this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFound, this); |
| }, |
| @@ -241,17 +244,17 @@ var requestsDataSource = |
| } |
| } |
| }; |
| var filtersDataSource = |
| { |
| origFilters: [], |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
| .getInterface(Ci.nsIDOMWindowUtils) |
| .outerWindowID; |
| RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) => |
| { |
| if (wndStats) |
| { |
| @@ -279,17 +282,17 @@ var subscriptionsDataSource = |
| { |
| if (s.disabled || !(s instanceof RegularSubscription)) |
| return false; |
| if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.url)) |
| return false; |
| return true; |
| }, |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let subscriptions = reportElement("subscriptions"); |
| let now = Math.round(Date.now() / 1000); |
| for (let i = 0; i < FilterStorage.subscriptions.length; i++) |
| { |
| let subscription = FilterStorage.subscriptions[i]; |
| if (!this.subscriptionFilter(subscription)) |
| continue; |
| @@ -314,17 +317,17 @@ var subscriptionsDataSource = |
| } |
| } |
| callback(); |
| } |
| }; |
| var remoteDataSource = |
| { |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
| .getInterface(Ci.nsIDOMWindowUtils) |
| .outerWindowID; |
| let dataCollector = require("dataCollector"); |
| let screenshotWidth = screenshotDataSource.getWidth(); |
| dataCollector.collectData(outerWindowID, screenshotWidth, data => { |
| screenshotDataSource.setData(data && data.screenshot); |
| @@ -575,17 +578,17 @@ var framesDataSource = |
| }); |
| this.addFrames(frame.frames, frameXML); |
| } |
| } |
| }; |
| var errorsDataSource = |
| { |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| let {addonID} = require("info"); |
| addonID = addonID.replace(/[\{\}]/g, ""); |
| // See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with |
| // Gecko 19 this function returns the result, before that it wrote to a |
| // parameter. |
| let outparam = {}; |
| @@ -650,17 +653,17 @@ var errorsDataSource = |
| callback(); |
| } |
| }; |
| var extensionsDataSource = |
| { |
| data: reportData.createElement("extensions"), |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| try |
| { |
| let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm", null).AddonManager; |
| AddonManager.getAddonsByTypes(["extension", "plugin"], function(items) |
| { |
| for (let i = 0; i < items.length; i++) |
| { |
| @@ -690,32 +693,32 @@ var extensionsDataSource = |
| reportData.documentElement.appendChild(this.data); |
| else if (this.data.parentNode) |
| this.data.parentNode.removeChild(this.data); |
| } |
| }; |
| var subscriptionUpdateDataSource = |
| { |
| - contentWnd: null, |
| + browser: null, |
| type: null, |
| outdated: null, |
| needUpdate: null, |
| subscriptionFilter: function(s) |
| { |
| if (s instanceof DownloadableSubscription) |
| return subscriptionsDataSource.subscriptionFilter(s); |
| else |
| return false; |
| }, |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| - this.contentWnd = wnd; |
| + this.browser = browser; |
| let now = Date.now() / MILLISECONDS_IN_SECOND; |
| let outdatedThreshold = now - 14 * SECONDS_IN_DAY; |
| let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR; |
| this.outdated = []; |
| this.needUpdate = []; |
| let subscriptions = FilterStorage.subscriptions.filter(this.subscriptionFilter); |
| @@ -796,27 +799,27 @@ var subscriptionUpdateDataSource = |
| if (filtersRemoved) |
| { |
| // Force the user to reload the page |
| E("updateFixedIssue").hidden = false; |
| document.documentElement.canAdvance = true; |
| let nextButton = document.documentElement.getButton("next"); |
| [nextButton.label, nextButton.accessKey] = Utils.splitLabel(E("updatePage").getAttribute("reloadButtonLabel")); |
| - document.documentElement.addEventListener("wizardnext", function(event) |
| + document.documentElement.addEventListener("wizardnext", event => |
| { |
| event.preventDefault(); |
| event.stopPropagation(); |
| window.close(); |
| - this.contentWnd.location.reload(); |
| - }.bind(this), true); |
| + this.browser.reload(); |
|
Erik
2016/01/08 04:00:45
the only problem I see with this is that the curre
Wladimir Palant
2016/01/08 13:46:20
Given that it is a specific <browser> element rath
|
| + }, true); |
| } |
| else |
| { |
| - this.collectData(null, null, function() {}); |
| + this.collectData(null, null, null, function() {}); |
| this.needUpdate = []; |
| if (this.outdated.length) |
| { |
| document.documentElement.canRewind = true; |
| this.updatePage(this.type); |
| this.showPage(); |
| } |
| @@ -848,17 +851,17 @@ var subscriptionUpdateDataSource = |
| { |
| for (let i = 0; i < this.outdated.length; i++) |
| Synchronizer.execute(this.outdated[i], true); |
| } |
| } |
| var issuesDataSource = |
| { |
| - contentWnd: null, |
| + browser: null, |
| isEnabled: Prefs.enabled, |
| whitelistFilter: null, |
| disabledFilters: [], |
| disabledSubscriptions: [], |
| ownFilters: [], |
| numSubscriptions: 0, |
| numAppliedFilters: Infinity, |
| @@ -869,19 +872,19 @@ var issuesDataSource = |
| s.url != Prefs.subscriptions_antiadblockurl) |
| { |
| return subscriptionsDataSource.subscriptionFilter(s); |
| } |
| else |
| return false; |
| }, |
| - collectData: function(wnd, windowURI, callback) |
| + collectData: function(wnd, windowURI, browser, callback) |
| { |
| - this.contentWnd = wnd; |
| + this.browser = browser; |
| this.whitelistFilter = Policy.isWhitelisted(windowURI.spec); |
| if (!this.whitelistFilter && this.isEnabled) |
| { |
| // Find disabled filters in active subscriptions matching any of the requests |
| let disabledMatcher = new CombinedMatcher(); |
| for (let subscription of FilterStorage.subscriptions) |
| { |
| @@ -1048,25 +1051,24 @@ var issuesDataSource = |
| { |
| // User changed configuration, don't allow sending report now - page needs |
| // to be reloaded |
| E("issuesOverride").hidden = true; |
| E("issuesChangeMessage").hidden = false; |
| document.documentElement.canRewind = false; |
| document.documentElement.canAdvance = true; |
| - let contentWnd = this.contentWnd; |
| let nextButton = document.documentElement.getButton("next"); |
| [nextButton.label, nextButton.accessKey] = Utils.splitLabel(E("updatePage").getAttribute("reloadButtonLabel")); |
| - document.documentElement.addEventListener("wizardnext", function(event) |
| + document.documentElement.addEventListener("wizardnext", event => |
| { |
| event.preventDefault(); |
| event.stopPropagation(); |
| window.close(); |
| - contentWnd.location.reload(); |
| + this.browser.reload(); |
| }, true); |
| }, |
| removeWhitelist: function() |
| { |
| if (this.whitelistFilter && this.whitelistFilter.subscriptions.length) |
| this.whitelistFilter.disabled = true; |
| E("issuesWhitelistBox").hidden = true; |
| @@ -1228,17 +1230,17 @@ function initDataCollectorPage() |
| progressMeter.mode = "determined"; |
| progressMeter.value = progress; |
| } |
| // Continue with the next data source, asynchronously to allow progress meter to update |
| let dataSource = dataCollectors.shift(); |
| Utils.runAsync(function() |
| { |
| - dataSource.collectData(contentWindow, windowURI, initNextDataSource); |
| + dataSource.collectData(contentWindow, windowURI, browser, initNextDataSource); |
| }); |
| }; |
| initNextDataSource(); |
| } |
| function initTypeSelectorPage() |
| { |