Bug 721729 - GCLI failed to update page resources when page changes; r=dcamp
--- a/browser/devtools/webconsole/HUDService.jsm
+++ b/browser/devtools/webconsole/HUDService.jsm
@@ -6943,16 +6943,22 @@ GcliTerm.prototype = {
* @param object aConsole
* Console object to use within the GcliTerm.
*/
reattachConsole: function Gcli_reattachConsole(aContentWindow, aConsole)
{
this.context = Cu.getWeakReference(aContentWindow);
this.console = aConsole;
this.createSandbox();
+
+ this.opts.environment.contentDocument = aContentWindow.document;
+ this.opts.contentDocument = aContentWindow.document;
+ this.opts.jsEnvironment.globalObject = unwrap(aContentWindow);
+
+ gcli._internal.reattachConsole(this.opts);
},
/**
* Generates and attaches the GCLI Terminal part of the Web Console, which
* essentially consists of the interactive JavaScript input facility.
*/
createUI: function Gcli_createUI()
{
--- a/browser/devtools/webconsole/gcli.jsm
+++ b/browser/devtools/webconsole/gcli.jsm
@@ -747,16 +747,30 @@ define('gcli/index', ['require', 'export
if (opts.requisition == null) {
opts.requisition = new Requisition(opts.environment, opts.chromeDocument);
}
opts.console = new Console(opts);
},
/**
+ * Called when the page to which we're attached changes
+ */
+ reattachConsole: function(opts) {
+ jstype.setGlobalObject(opts.jsEnvironment.globalObject);
+ nodetype.setDocument(opts.contentDocument);
+ cli.setEvalFunction(opts.jsEnvironment.evalFunction);
+
+ opts.requisition.environment = opts.environment;
+ opts.requisition.document = opts.chromeDocument;
+
+ opts.console.reattachConsole(opts);
+ },
+
+ /**
* Undo the effects of createView() to prevent memory leaks
*/
removeView: function(opts) {
opts.console.destroy();
delete opts.console;
opts.requisition.destroy();
delete opts.requisition;
@@ -5806,16 +5820,31 @@ function Console(options) {
this.chromeWindow = options.chromeDocument.defaultView;
this.resizer = this.resizer.bind(this);
this.chromeWindow.addEventListener('resize', this.resizer, false);
this.requisition.commandChange.add(this.resizer, this);
}
/**
+ * Called when the page to which we're attached changes
+ */
+Console.prototype.reattachConsole = function(options) {
+ this.chromeWindow.removeEventListener('resize', this.resizer, false);
+ this.chromeWindow = options.chromeDocument.defaultView;
+ this.chromeWindow.addEventListener('resize', this.resizer, false);
+
+ this.focusManager.document = options.chromeDocument;
+ this.inputter.document = options.chromeDocument;
+ this.inputter.completer.document = options.chromeDocument;
+ this.menu.document = options.chromeDocument;
+ this.argFetcher.document = options.chromeDocument;
+};
+
+/**
* Avoid memory leaks
*/
Console.prototype.destroy = function() {
this.chromeWindow.removeEventListener('resize', this.resizer, false);
delete this.resizer;
delete this.chromeWindow;
delete this.consoleWrap;