Bug 721729 - GCLI failed to update page resources when page changes; r=dcamp

This commit is contained in:
Joe Walker 2012-02-07 10:20:20 +00:00
Родитель 28e9623cb0
Коммит 449aaad4de
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -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);
},
/**

Просмотреть файл

@ -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
*/