Bug 993985 - Fix broken tooltip in Developer Toolbar; r=mratcliffe
authorJoe Walker <jwalker@mozilla.com>
Fri, 18 Apr 2014 09:21:12 +0100
changeset 197677 45d9d4a20b13a932ff43332aac1478ae0ec5950e
parent 197676 20ec0888f6329ff634cd0ae31816ca68b0b357ca
child 197693 bf19c003ffc3bf08f82cf39cda37834fe13c6823
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs993985
milestone31.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 993985 - Fix broken tooltip in Developer Toolbar; r=mratcliffe
toolkit/devtools/gcli/source/lib/gcli/ui/menu.js
toolkit/devtools/gcli/source/lib/gcli/util/host.js
--- a/toolkit/devtools/gcli/source/lib/gcli/ui/menu.js
+++ b/toolkit/devtools/gcli/source/lib/gcli/ui/menu.js
@@ -55,25 +55,25 @@ function Menu(options) {
   if (menuCssPromise == null) {
     menuCssPromise = host.staticRequire(module, './menu.css');
   }
   menuCssPromise.then(function(menuCss) {
     // Pull the HTML into the DOM, but don't add it to the document
     if (menuCss != null) {
       util.importCss(menuCss, this.document, 'gcli-menu');
     }
-  }.bind(this));
+  }.bind(this), console.error);
 
   this.templateOptions = { blankNullUndefined: true, stack: 'menu.html' };
   if (menuHtmlPromise == null) {
     menuHtmlPromise = host.staticRequire(module, './menu.html');
   }
   menuHtmlPromise.then(function(menuHtml) {
     this.template = util.toDom(this.document, menuHtml);
-  }.bind(this));
+  }.bind(this), console.error);
 
   // Contains the items that should be displayed
   this.items = [];
 
   this.onItemClick = util.createEvent('Menu.onItemClick');
 }
 
 /**
--- a/toolkit/devtools/gcli/source/lib/gcli/util/host.js
+++ b/toolkit/devtools/gcli/source/lib/gcli/util/host.js
@@ -61,27 +61,43 @@ exports.Highlighter = Highlighter;
 /**
  * See docs in lib/gcli/util/host.js:exec
  */
 exports.exec = function(execSpec) {
   throw new Error('Not supported');
 };
 
 /**
+ * When dealing with module paths on windows we want to use the unix
+ * directory separator rather than the windows one, so we avoid using
+ * OS.Path.dirname, and use unix version on all platforms.
+ */
+let resourceDirName = function(path) {
+  let index = path.lastIndexOf("/");
+  if (index == -1) {
+    return ".";
+  }
+  while (index >= 0 && path[index] == "/") {
+    --index;
+  }
+  return path.slice(0, index + 1);
+};
+
+/**
  * Asynchronously load a text resource
  * @see lib/gcli/util/host.js
  */
 exports.staticRequire = function(requistingModule, name) {
   var deferred = promise.defer();
 
   if (name.match(/\.css$/)) {
     deferred.resolve('');
   }
   else {
-    var filename = OS.Path.dirname(requistingModule.id) + '/' + name;
+    var filename = resourceDirName(requistingModule.id) + '/' + name;
     filename = filename.replace(/\/\.\//g, '/');
     filename = 'resource://gre/modules/devtools/' + filename;
 
     var xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1']
                 .createInstance(Ci.nsIXMLHttpRequest);
 
     xhr.onload = function onload() {
       deferred.resolve(xhr.responseText);