Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1284 from adobe/jason-sanjose/issue-1275
Browse files Browse the repository at this point in the history
Prevent extensions from loading in test windows
  • Loading branch information
redmunds committed Jul 20, 2012
2 parents de3dbfc + 8c501a8 commit 03d2b45
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 115 deletions.
18 changes: 13 additions & 5 deletions src/brackets.js
Expand Up @@ -78,12 +78,17 @@ define(function (require, exports, module) {
Dialogs = require("widgets/Dialogs"), Dialogs = require("widgets/Dialogs"),
ExtensionLoader = require("utils/ExtensionLoader"), ExtensionLoader = require("utils/ExtensionLoader"),
SidebarView = require("project/SidebarView"), SidebarView = require("project/SidebarView"),
Async = require("utils/Async"); Async = require("utils/Async"),
UrlParams = require("utils/UrlParams").UrlParams;


// Local variables // Local variables
var bracketsReady = false, var bracketsReady = false,
bracketsReadyHandlers = []; bracketsReadyHandlers = [],

params = new UrlParams();

// read URL params
params.parse();

//Load modules that self-register and just need to get included in the main project //Load modules that self-register and just need to get included in the main project
require("document/ChangedDocumentTracker"); require("document/ChangedDocumentTracker");
require("editor/EditorCommandHandlers"); require("editor/EditorCommandHandlers");
Expand Down Expand Up @@ -175,7 +180,10 @@ define(function (require, exports, module) {
// TODO: (issue 1029) Add timeout to main extension loading promise, so that we always call this function // TODO: (issue 1029) Add timeout to main extension loading promise, so that we always call this function
// Making this fix will fix a warning (search for issue 1029) related to the brackets 'ready' event. // Making this fix will fix a warning (search for issue 1029) related to the brackets 'ready' event.
function _initExtensions() { function _initExtensions() {
return Async.doInParallel(["default", "user"], function (item) { // allow unit tests to override which plugin folder(s) to load
var paths = params.get("extensions") || "default,user";

return Async.doInParallel(paths.split(","), function (item) {
return ExtensionLoader.loadAllExtensionsInNativeDirectory( return ExtensionLoader.loadAllExtensionsInNativeDirectory(
FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item, FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item,
"extensions/" + item "extensions/" + item
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptQuickEdit/unittests.js
Expand Up @@ -279,7 +279,7 @@ define(function (require, exports, module) {


describe("Performance suite", function () { describe("Performance suite", function () {


this.performance = true; this.category = "performance";


var testPath = SpecRunnerUtils.getTestPath("/../../../brackets-scenario/jquery-ui/"); var testPath = SpecRunnerUtils.getTestPath("/../../../brackets-scenario/jquery-ui/");


Expand Down
15 changes: 15 additions & 0 deletions src/utils/PerfUtils.js
Expand Up @@ -316,6 +316,20 @@ define(function (require, exports, module) {
return perfData[toMeasurementId(name)]; return perfData[toMeasurementId(name)];
} }


function searchData(regExp) {
var keys = Object.keys(perfData).filter(function (key) {
return regExp.test(key);
});

var datas = [];

keys.forEach(function (key) {
datas.push(perfData[key]);
});

return datas;
}

/** /**
* Clear all logs including metric data and active tests. * Clear all logs including metric data and active tests.
*/ */
Expand All @@ -336,6 +350,7 @@ define(function (require, exports, module) {
exports.isActive = isActive; exports.isActive = isActive;
exports.markStart = markStart; exports.markStart = markStart;
exports.getData = getData; exports.getData = getData;
exports.searchData = searchData;
exports.updateMeasurement = updateMeasurement; exports.updateMeasurement = updateMeasurement;
exports.getDelimitedPerfData = getDelimitedPerfData; exports.getDelimitedPerfData = getDelimitedPerfData;
exports.createPerfMeasurement = createPerfMeasurement; exports.createPerfMeasurement = createPerfMeasurement;
Expand Down
92 changes: 92 additions & 0 deletions src/utils/UrlParams.js
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, window */

define(function (require, exports, module) {
"use strict";

/**
* Convert between URL querystring and name/value pairs. Decodes and encodes URL parameters.
*/
function UrlParams() {
this._store = {};
}

/**
* Parse the window location by default. Optionally specify a URL to parse.
* @param {string} url
*/
UrlParams.prototype.parse = function (url) {
if (url) {
url = url.substring(indexOf("?") + 1);
} else {
url = window.document.location.search.substring(1);
}

var urlParams = url.split("&"),
p,
self = this;

urlParams.forEach(function (param) {
p = param.split("=");
self._store[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
});
};

/**
* Store a name/value string pair
* @param {!string} name
* @param {!string} value
*/
UrlParams.prototype.put = function (name, value) {
this._store[name] = value;
};

/**
* Retreive a value by name
* @param {!string} name
*/
UrlParams.prototype.get = function (name) {
return this._store[name];
};

/**
* Encode name/value pairs as URI components.
*/
UrlParams.prototype.toString = function () {
var strs = [],
self = this;

Object.keys(self._store).forEach(function (key) {
strs.push(encodeURIComponent(key) + "=" + encodeURIComponent(self._store[key]));
});

return strs.join("&");
};

// Define public API
exports.UrlParams = UrlParams;
});
25 changes: 11 additions & 14 deletions test/BootstrapReporter.js
@@ -1,32 +1,29 @@
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50, forin: true */ /*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50, forin: true */
/*global jasmine, document */ /*global jasmine, $, define, document, require */
(function ($) { define(function (require, exports, module) {
'use strict'; 'use strict';

var UrlParams = require("utils/UrlParams").UrlParams;


jasmine.BootstrapReporter = function (doc, filter) { jasmine.BootstrapReporter = function (doc, filter) {
this._paramMap = {};
this.document = doc || document; this.document = doc || document;
this._env = jasmine.getEnv(); this._env = jasmine.getEnv();
this.params = new UrlParams();
this.params.parse();


// parse querystring // parse querystring
var self = this, var self = this,
params = this.document.location.search.substring(1).split('&'),
i, i,
p; p;


for (i = 0; i < params.length; i++) { this._runAll = this.params.get("spec") === "All";
p = params[i].split('=');
this._paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}

this._runAll = this._paramMap.spec === "All";


// _topLevelFilter is applied first - selects Performance vs. Unit test suites // _topLevelFilter is applied first - selects Performance vs. Unit test suites
this._topLevelFilter = filter; this._topLevelFilter = filter;


// Jasmine's runner uses the specFilter to choose which tests to run. // Jasmine's runner uses the specFilter to choose which tests to run.
// If you selected an option other than "All" this will be a subset of all tests loaded. // If you selected an option other than "All" this will be a subset of all tests loaded.
this._env.specFilter = this.createSpecFilter(this._paramMap.spec); this._env.specFilter = this.createSpecFilter(this.params.get("spec"));
this._runner = this._env.currentRunner(); this._runner = this._env.currentRunner();


// build DOM immediately // build DOM immediately
Expand Down Expand Up @@ -187,7 +184,7 @@
this._createSuiteList(); this._createSuiteList();


// highlight the current suite // highlight the current suite
topLevelData = (this._paramMap.spec) ? this._topLevelSuiteMap[this._paramMap.spec] : null; topLevelData = (this.params.get("spec")) ? this._topLevelSuiteMap[this.params.get("spec")] : null;


if (topLevelData) { if (topLevelData) {
topLevelData.$listItem.toggleClass("active", true); topLevelData.$listItem.toggleClass("active", true);
Expand Down Expand Up @@ -229,7 +226,7 @@
passed, passed,
data = this._topLevelSuiteMap[suite.getFullName()]; data = this._topLevelSuiteMap[suite.getFullName()];


if ((suite.getFullName() === this._paramMap.spec) && data) { if ((suite.getFullName() === this.params.get("spec")) && data) {
passed = results.passed(); passed = results.passed();


data.$badgeAll.hide(); data.$badgeAll.hide();
Expand Down Expand Up @@ -354,4 +351,4 @@


jasmine.BootstrapReporter.prototype.log = function (str) { jasmine.BootstrapReporter.prototype.log = function (str) {
}; };
}(window.jQuery)); });
2 changes: 1 addition & 1 deletion test/PerformanceTestSuite.js
Expand Up @@ -26,6 +26,6 @@
define(function (require, exports, module) { define(function (require, exports, module) {
'use strict'; 'use strict';


// Each suite or spec must have this.performance = true to be filtered properly // Each suite or spec must have this.category === "performance" to be filtered properly
require("perf/Performance-test"); require("perf/Performance-test");
}); });
4 changes: 1 addition & 3 deletions test/SpecRunner.html
Expand Up @@ -32,14 +32,11 @@
<link href="BootstrapReporter.css" rel="stylesheet"> <link href="BootstrapReporter.css" rel="stylesheet">


<script src="thirdparty/jasmine-core/jasmine.js"></script> <script src="thirdparty/jasmine-core/jasmine.js"></script>
<script src="thirdparty/jasmine-core/jasmine-html.js"></script>
<script src="thirdparty/jasmine-jquery-1.3.1.js"></script>


<!-- Pre-load third party scripts that cannot be async loaded. --> <!-- Pre-load third party scripts that cannot be async loaded. -->
<script src="../src/thirdparty/jquery-1.7.min.js"></script> <script src="../src/thirdparty/jquery-1.7.min.js"></script>
<script src="../src/thirdparty/CodeMirror2/lib/codemirror.js"></script> <script src="../src/thirdparty/CodeMirror2/lib/codemirror.js"></script>
<script src="thirdparty/bootstrap2/js/bootstrap.min.js"></script> <script src="thirdparty/bootstrap2/js/bootstrap.min.js"></script>
<script src="BootstrapReporter.js"></script>


<!-- All other scripts are loaded through require. --> <!-- All other scripts are loaded through require. -->
<script src="../src/thirdparty/require.js" data-main="SpecRunner"></script> <script src="../src/thirdparty/require.js" data-main="SpecRunner"></script>
Expand All @@ -61,6 +58,7 @@
<ul class="nav"> <ul class="nav">
<li><a id="UnitTestSuite" href="?suite=UnitTestSuite">Unit</a></li> <li><a id="UnitTestSuite" href="?suite=UnitTestSuite">Unit</a></li>
<li><a id="PerformanceTestSuite" href="?suite=PerformanceTestSuite">Performance</a></li> <li><a id="PerformanceTestSuite" href="?suite=PerformanceTestSuite">Performance</a></li>
<li><a id="ExtensionSuite" href="?suite=ExtensionTestSuite">Extensions</a></li>
<li><a id="reload" href="#">Reload</a></li> <li><a id="reload" href="#">Reload</a></li>
<li><a id="show-dev-tools" href="#">Show Developer Tools</a></li> <li><a id="show-dev-tools" href="#">Show Developer Tools</a></li>
</ul> </ul>
Expand Down

0 comments on commit 03d2b45

Please sign in to comment.