bug 755661 part 5 - fix xpcshell test on windows; r=rcampbell
authorPanos Astithas <past@mozilla.com>
Wed, 03 Oct 2012 18:56:45 +0300
changeset 109263 ac84886e4d05a6effd913d3f778d2ba981c6c3ae
parent 109262 5fa320921d85b75c5493134490473bd1bf289c54
child 109264 d2850363666b163d6b8833f90974d1e65cc5c838
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersrcampbell
bugs755661
milestone18.0a1
bug 755661 part 5 - fix xpcshell test on windows; r=rcampbell
toolkit/devtools/debugger/server/dbg-script-actors.js
--- a/toolkit/devtools/debugger/server/dbg-script-actors.js
+++ b/toolkit/devtools/debugger/server/dbg-script-actors.js
@@ -1269,24 +1269,20 @@ SourceActor.prototype = {
    */
   _loadSource: function SA__loadSource() {
     let promise = new Promise();
     let url = this._script.url;
     let scheme;
     try {
       scheme = Services.io.extractScheme(url);
     } catch (e) {
-      // XXX: In the xpcshell tests, the script url is the absolute path of the
-      // test file, which will make a malformed URI error be thrown. Add the
-      // file scheme prefix ourselves.
-      let prefix = "file://";
-      if ("nsILocalFileWin" in Ci && url instanceof Ci.nsILocalFileWin) {
-        prefix += '/'
-      }
-      url = prefix + url;
+      // In the xpcshell tests, the script url is the absolute path of the test
+      // file, which will make a malformed URI error be thrown. Add the file
+      // scheme prefix ourselves.
+      url = "file://" + url;
       scheme = Services.io.extractScheme(url);
     }
 
     switch (scheme) {
       case "file":
       case "chrome":
       case "resource":
         try {
@@ -1301,17 +1297,25 @@ SourceActor.prototype = {
             aStream.close();
           }.bind(this));
         } catch (ex) {
           promise.reject(new Error("Request failed"));
         }
         break;
 
       default:
-        let channel = Services.io.newChannel(url, null, null);
+        let channel;
+        try {
+          channel = Services.io.newChannel(url, null, null);
+        } catch (e if e.name == "NS_ERROR_UNKNOWN_PROTOCOL") {
+          // On Windows xpcshell tests, c:/foo/bar can pass as a valid URL, but
+          // newChannel won't be able to handle it.
+          url = "file:///" + url;
+          channel = Services.io.newChannel(url, null, null);
+        }
         let chunks = [];
         let streamListener = {
           onStartRequest: function(aRequest, aContext, aStatusCode) {
             if (!Components.isSuccessCode(aStatusCode)) {
               promise.reject("Request failed");
             }
           },
           onDataAvailable: function(aRequest, aContext, aStream, aOffset, aCount) {