diff --git a/src/LiveDevelopment/LiveDevelopment.js b/src/LiveDevelopment/LiveDevelopment.js index a6942e06917..c89b63cebda 100644 --- a/src/LiveDevelopment/LiveDevelopment.js +++ b/src/LiveDevelopment/LiveDevelopment.js @@ -99,7 +99,21 @@ define(function LiveDevelopment(require, exports, module) { "edit" : require("LiveDevelopment/Agents/EditAgent") }; - var launcherUrl = window.location.href.replace(/\/index.html.*/, "") + "/LiveDevelopment/launch.html"; + // construct path to launch.html + // window location is can be one of the following: + // Installed: /path/to/Brackets.app/Contents/www/index.html + // Installed, dev: /path/to/Brackets.app/Contents/dev/src/index.html + // Installed, dev, test: /path/to/Brackets.app/Contents/dev/test/SpecRunner.html + // Arbitrary git repo: /path/to/brackets/src/index.html + // Arbitrary git repo, test: /path/to/brackets/test/SpecRunner.html + var launcherUrl = window.location.pathname; + + // special case for test/SpecRunner.html since we can't tell how requirejs + // baseUrl is configured dynamically + launcherUrl = launcherUrl.replace("/test/SpecRunner.html", "/src/index.html"); + + launcherUrl = launcherUrl.substr(0, launcherUrl.lastIndexOf("/")) + "/LiveDevelopment/launch.html"; + launcherUrl = window.location.origin + launcherUrl; // Some agents are still experimental, so we don't enable them all by default // However, extensions can enable them by calling enableAgent(). @@ -556,9 +570,6 @@ define(function LiveDevelopment(require, exports, module) { // helper function that actually does the launch once we are sure we have // a doc and the server for that doc is up and running. function doLaunchAfterServerReady() { - var targetUrl = doc.root.url; - var interstitialUrl = launcherUrl + "?" + encodeURIComponent(targetUrl); - _setStatus(STATUS_CONNECTING); if (_serverProvider) { @@ -579,7 +590,7 @@ define(function LiveDevelopment(require, exports, module) { }); } - Inspector.connectToURL(interstitialUrl).done(result.resolve).fail(function onConnectFail(err) { + Inspector.connectToURL(launcherUrl).done(result.resolve).fail(function onConnectFail(err) { if (err === "CANCEL") { result.reject(err); return; @@ -617,7 +628,7 @@ define(function LiveDevelopment(require, exports, module) { if (!browserStarted && exports.status !== STATUS_ERROR) { NativeApp.openLiveBrowser( - interstitialUrl, + launcherUrl, true // enable remote debugging ) .done(function () { @@ -650,7 +661,7 @@ define(function LiveDevelopment(require, exports, module) { if (exports.status !== STATUS_ERROR) { window.setTimeout(function retryConnect() { - Inspector.connectToURL(interstitialUrl).done(result.resolve).fail(onConnectFail); + Inspector.connectToURL(launcherUrl).done(result.resolve).fail(onConnectFail); }, 500); } }); diff --git a/src/extensions/default/JavaScriptCodeHints/ScopeManager.js b/src/extensions/default/JavaScriptCodeHints/ScopeManager.js index b6c3e44fb7b..a9da0f8a4df 100644 --- a/src/extensions/default/JavaScriptCodeHints/ScopeManager.js +++ b/src/extensions/default/JavaScriptCodeHints/ScopeManager.js @@ -425,33 +425,37 @@ define(function (require, exports, module) { var path = document.file.fullPath, split = HintUtils.splitPath(path), dir = split.dir, - file = split.file, - dirEntry = new NativeFileSystem.DirectoryEntry(dir), - reader = dirEntry.createReader(); - - markFileDirty(dir, file); - - reader.readEntries(function (entries) { - entries.slice(0, MAX_FILES_IN_DIR).forEach(function (entry) { - if (entry.isFile) { - var path = entry.fullPath, - split = HintUtils.splitPath(path), - dir = split.dir, - file = split.file; - - if (file.indexOf(".") > 1) { // ignore /.dotfiles - var languageID = LanguageManager.getLanguageForPath(entry.fullPath).getId(); - if (languageID === HintUtils.LANGUAGE_ID) { - DocumentManager.getDocumentForPath(path).done(function (document) { - refreshOuterScope(dir, file, document.getText()); - }); + file = split.file; + + NativeFileSystem.resolveNativeFileSystemPath(dir, function (dirEntry) { + var reader = dirEntry.createReader(); + + markFileDirty(dir, file); + + reader.readEntries(function (entries) { + entries.slice(0, MAX_FILES_IN_DIR).forEach(function (entry) { + if (entry.isFile) { + var path = entry.fullPath, + split = HintUtils.splitPath(path), + dir = split.dir, + file = split.file; + + if (file.indexOf(".") > 1) { // ignore /.dotfiles + var languageID = LanguageManager.getLanguageForPath(entry.fullPath).getId(); + if (languageID === HintUtils.LANGUAGE_ID) { + DocumentManager.getDocumentForPath(path).done(function (document) { + refreshOuterScope(dir, file, document.getText()); + }); + } } } - } + }); + }, function (err) { + console.log("Unable to refresh directory: " + err); + refreshOuterScope(dir, file, document.getText()); }); }, function (err) { - console.log("Unable to refresh directory: " + err); - refreshOuterScope(dir, file, document.getText()); + console.log("Directory \"%s\" does not exist", dir); }); } diff --git a/src/file/NativeFileSystem.js b/src/file/NativeFileSystem.js index c377be79f58..52de327013a 100644 --- a/src/file/NativeFileSystem.js +++ b/src/file/NativeFileSystem.js @@ -946,6 +946,11 @@ define(function (require, exports, module) { * @param {function(DOMError)=} errorCallback Callback function for error operations */ NativeFileSystem.DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) { + if (!this._directory.fullPath) { + errorCallback(new NativeFileError(NativeFileError.PATH_EXISTS_ERR)); + return; + } + var rootPath = this._directory.fullPath, filesystem = this.filesystem, timeout = NativeFileSystem.ASYNC_TIMEOUT, diff --git a/tasks/test.js b/tasks/test.js index 1fa6a28f39e..30b02ba1714 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -37,10 +37,11 @@ module.exports = function (grunt) { opts = { cwd: process.cwd() }, cmd = common.resolve(grunt.option("shell") || grunt.config("shell." + platform)), spec = grunt.option("spec") || "all", + suite = grunt.option("suite") || "all", results = grunt.option("results") || process.cwd() + "/results.json", resultsPath = common.resolve(results), specRunnerPath = common.resolve("test/SpecRunner.html"), - args = " --startup-path=\"" + specRunnerPath + "?suite=all&spec=" + encodeURIComponent(spec) + "&resultsPath=" + encodeURIComponent(resultsPath) + "\""; + args = " --startup-path=\"" + specRunnerPath + "?suite=" + encodeURIComponent(suite) + "&spec=" + encodeURIComponent(spec) + "&resultsPath=" + encodeURIComponent(resultsPath) + "\""; if (platform === "win") { cmd += args; diff --git a/test/SpecRunner.html b/test/SpecRunner.html index 2f29489b1e7..0724014d8c2 100644 --- a/test/SpecRunner.html +++ b/test/SpecRunner.html @@ -64,10 +64,10 @@