Bug 1266844 - use URL, not nsIURL, in css-logic.js; r=pbro
authorTom Tromey <tom@tromey.com>
Fri, 24 Jun 2016 13:55:55 -0600
changeset 303268 c6ce12a74300f69b8a8aabc2677aa4710809194a
parent 303267 69e91ad4fb9f64f27e76e51bcaa5d899d53681b9
child 303269 3e793c26a9109990f8882f8035bf060fc0f09852
push id19836
push usercbook@mozilla.com
push dateFri, 01 Jul 2016 08:55:59 +0000
treeherderfx-team@c6ce12a74300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1266844
milestone50.0a1
Bug 1266844 - use URL, not nsIURL, in css-logic.js; r=pbro MozReview-Commit-ID: F8eBQEJZkv7
devtools/shared/inspector/css-logic.js
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -107,28 +107,27 @@ exports.shortSource = function (sheet) {
   // Use a string like "inline" if there is no source href
   if (!sheet || !sheet.href) {
     return exports.l10n("rule.sourceInline");
   }
 
   // We try, in turn, the filename, filePath, query string, whole thing
   let url = {};
   try {
-    url = Services.io.newURI(sheet.href, null, null);
-    url = url.QueryInterface(Ci.nsIURL);
+    url = new URL(sheet.href);
   } catch (ex) {
     // Some UA-provided stylesheets are not valid URLs.
   }
 
-  if (url.fileName) {
-    return url.fileName;
-  }
-
-  if (url.filePath) {
-    return url.filePath;
+  if (url.pathname) {
+    let index = url.pathname.lastIndexOf("/");
+    if (index !== -1 && index < url.pathname.length) {
+      return url.pathname.slice(index + 1);
+    }
+    return url.pathname;
   }
 
   if (url.query) {
     return url.query;
   }
 
   let dataUrl = sheet.href.match(/^(data:[^,]*),/);
   return dataUrl ? dataUrl[1] : sheet.href;