Index: chrome/content/ui/sendReport.js |
=================================================================== |
--- a/chrome/content/ui/sendReport.js |
+++ b/chrome/content/ui/sendReport.js |
@@ -312,64 +312,79 @@ var subscriptionsDataSource = |
subscriptionXML.setAttribute("hardExpiration", subscription.expires - now); |
subscriptionXML.setAttribute("downloadStatus", subscription.downloadStatus); |
} |
} |
callback(); |
} |
}; |
+var remoteDataSource = |
+{ |
+ collectData: function(wnd, windowURI, 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); |
+ framesDataSource.setData(windowURI, data && data.opener, data && data.referrer, data && data.frames); |
+ callback(); |
+ }); |
+ } |
+} |
+ |
var screenshotDataSource = |
{ |
imageOffset: 10, |
// Fields used for user interaction |
_enabled: true, |
_canvas: null, |
_context: null, |
_selectionType: "mark", |
_currentData: null, |
_undoQueue: [], |
- collectData: function(wnd, windowURI, callback) |
+ getWidth: function() |
{ |
- let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
- .getInterface(Ci.nsIDOMWindowUtils) |
- .outerWindowID; |
- let dataCollector = require("dataCollector"); |
let canvas = E("screenshotCanvas"); |
- let screenshotWidth = canvas.offsetWidth - this.imageOffset * 2; |
+ return canvas.offsetWidth - this.imageOffset * 2; |
+ }, |
+ |
+ setData: function(screenshot) |
+ { |
+ let canvas = E("screenshotCanvas"); |
// Do not resize canvas any more (no idea why Gecko requires both to be set) |
canvas.parentNode.style.MozBoxAlign = "center"; |
canvas.parentNode.align = "center"; |
// Init canvas settings |
let context = canvas.getContext("2d"); |
context.fillStyle = "rgb(0, 0, 0)"; |
context.strokeStyle = "rgba(255, 0, 0, 0.7)"; |
context.lineWidth = 3; |
context.lineJoin = "round"; |
this._canvas = canvas; |
this._context = context; |
- dataCollector.collectData(outerWindowID, screenshotWidth, data => { |
- if (data && data.screenshot) |
- { |
- let image = new Image(); |
- image.src = data.screenshot; |
- image.addEventListener("load", () => { |
- canvas.width = image.width + this.imageOffset * 2; |
- canvas.height = image.height + this.imageOffset * 2; |
- context.drawImage(image, this.imageOffset, this.imageOffset); |
- }); |
- } |
- callback(); |
- }); |
+ if (screenshot) |
+ { |
+ let image = new Image(); |
+ image.src = screenshot; |
+ image.addEventListener("load", () => { |
+ canvas.width = image.width + this.imageOffset * 2; |
+ canvas.height = image.height + this.imageOffset * 2; |
+ context.drawImage(image, this.imageOffset, this.imageOffset); |
+ }); |
+ } |
}, |
get enabled() this._enabled, |
set enabled(enabled) |
{ |
if (this._enabled == enabled) |
return; |
@@ -524,57 +539,46 @@ var screenshotDataSource = |
E("screenshotUndoButton").disabled = true; |
} |
}; |
var framesDataSource = |
{ |
site: null, |
- collectData: function(wnd, windowURI, callback) |
+ setData: function(windowURI, opener, referrer, frames) |
{ |
try |
{ |
this.site = windowURI.host; |
if (this.site) |
document.title += " (" + this.site + ")"; |
} |
catch (e) |
{ |
// Expected exception - not all URL schemes have a host name |
} |
let window = reportElement("window"); |
- window.setAttribute("url", censorURL(windowURI ? windowURI.spec : wnd.location.href)); |
- if (wnd.opener && wnd.opener.location.href) |
- window.setAttribute("opener", censorURL(wnd.opener.location.href)); |
- if (wnd.document.referrer) |
- window.setAttribute("referrer", censorURL(wnd.document.referrer)); |
- this.scanFrames(wnd, window); |
- |
- callback(); |
+ window.setAttribute("url", censorURL(windowURI.spec)); |
+ if (opener) |
+ window.setAttribute("opener", censorURL(opener)); |
+ if (referrer) |
+ window.setAttribute("referrer", censorURL(referrer)); |
+ this.addFrames(frames || [], window); |
}, |
- scanFrames: function(wnd, xmlList) |
+ addFrames: function(frames, xmlList) |
{ |
- try |
+ for (let frame of frames) |
{ |
- for (let i = 0; i < wnd.frames.length; i++) |
- { |
- let frame = wnd.frames[i]; |
- let frameXML = appendElement(xmlList, "frame", { |
- url: censorURL(frame.location.href) |
- }); |
- this.scanFrames(frame, frameXML); |
- } |
- } |
- catch (e) |
- { |
- // Don't break if something goes wrong |
- Cu.reportError(e); |
+ let frameXML = appendElement(xmlList, "frame", { |
+ url: censorURL(frame.url) |
+ }); |
+ this.addFrames(frame.frames, frameXML); |
} |
} |
}; |
var errorsDataSource = |
{ |
collectData: function(wnd, windowURI, callback) |
{ |
@@ -1140,17 +1144,17 @@ var issuesDataSource = |
node.parentNode.removeChild(node); |
if (!E("issuesDisabledSubscriptions").firstChild) |
E("issuesDisabledSubscriptionsBox").hidden = true; |
this.forceReload(); |
} |
}; |
let dataCollectors = [reportsListDataSource, requestsDataSource, filtersDataSource, subscriptionsDataSource, |
- screenshotDataSource, framesDataSource, errorsDataSource, extensionsDataSource, |
+ remoteDataSource, errorsDataSource, extensionsDataSource, |
subscriptionUpdateDataSource, issuesDataSource]; |
// |
// Wizard logic |
// |
function initWizard() |
{ |