Bug 874023 - GCLI: context.environment.window not always defined when running GCLI commands; r=mratcliffe
authorJoe Walker <jwalker@mozilla.com>
Tue, 21 May 2013 10:18:56 +0100
changeset 143917 6cf5ac92530bbec37fabe1518ec897dcf512d6c4
parent 143916 b0895c6dfd65ab58079bb2979eb87df7344b12f5
child 143918 957f5f047a9461982930b0534fe2755d5c44ca41
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs874023
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 874023 - GCLI: context.environment.window not always defined when running GCLI commands; r=mratcliffe
browser/devtools/framework/toolbox.js
browser/devtools/shared/DeveloperToolbar.jsm
--- a/browser/devtools/framework/toolbox.js
+++ b/browser/devtools/framework/toolbox.js
@@ -315,18 +315,19 @@ Toolbox.prototype = {
    * Add buttons to the UI as specified in the devtools.window.toolbarSpec pref
    */
   _buildButtons: function TBOX_buildButtons() {
     if (!this.target.isLocalTab) {
       return;
     }
 
     let toolbarSpec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
-    let environment = { chromeDocument: this.target.tab.ownerDocument };
-    let requisition = new Requisition(environment);
+    let env = CommandUtils.createEnvironment(this.target.tab.ownerDocument,
+                                             this.target.window.document);
+    let requisition = new Requisition(env);
 
     let buttons = CommandUtils.createButtons(toolbarSpec, this._target, this.doc, requisition);
 
     let container = this.doc.getElementById("toolbox-buttons");
     buttons.forEach(function(button) {
       container.appendChild(button);
     }.bind(this));
   },
--- a/browser/devtools/shared/DeveloperToolbar.jsm
+++ b/browser/devtools/shared/DeveloperToolbar.jsm
@@ -151,17 +151,17 @@ let CommandUtils = {
    * GCLI commands.
    */
   createEnvironment: function(chromeDocument, contentDocument) {
     let environment = {
       chromeDocument: chromeDocument,
       chromeWindow: chromeDocument.defaultView,
 
       document: contentDocument,
-      window: contentDocument.defaultView
+      window: contentDocument != null ? contentDocument.defaultView : undefined
     };
 
     Object.defineProperty(environment, "target", {
       get: function() {
         let tab = chromeDocument.defaultView.getBrowser().selectedTab;
         return devtools.TargetFactory.forTab(tab);
       },
       enumerable: true