From 449aaad4de7c32e7911868688282fa938a4d0f26 Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Tue, 7 Feb 2012 10:20:20 +0000 Subject: [PATCH] Bug 721729 - GCLI failed to update page resources when page changes; r=dcamp --- browser/devtools/webconsole/HUDService.jsm | 6 +++++ browser/devtools/webconsole/gcli.jsm | 29 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm index d12d4353bbc..7053809bbc6 100644 --- a/browser/devtools/webconsole/HUDService.jsm +++ b/browser/devtools/webconsole/HUDService.jsm @@ -6948,6 +6948,12 @@ GcliTerm.prototype = { 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); }, /** diff --git a/browser/devtools/webconsole/gcli.jsm b/browser/devtools/webconsole/gcli.jsm index 71468cb339f..aeb38fcd561 100644 --- a/browser/devtools/webconsole/gcli.jsm +++ b/browser/devtools/webconsole/gcli.jsm @@ -751,6 +751,20 @@ define('gcli/index', ['require', 'exports', 'module' , 'gcli/canon', 'gcli/types 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 */ @@ -5810,6 +5824,21 @@ function Console(options) { 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 */