Skip to content

Commit

Permalink
more memory fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
redmunds committed Jun 21, 2013
1 parent 23a38fd commit 48ad413
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 19 deletions.
6 changes: 6 additions & 0 deletions test/perf/Performance-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ define(function (require, exports, module) {
});

afterEach(function () {
testWindow = null;
CommandManager = null;
Commands = null;
DocumentCommandHandlers = null;
DocumentManager = null;
PerfUtils = null;
SpecRunnerUtils.closeTestWindow();
});

Expand Down
6 changes: 5 additions & 1 deletion test/spec/EditorCommandHandlers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ define(function (require, exports, module) {
if ($dlg.length) {
SpecRunnerUtils.clickDialogButton("dontsave");
}
$dlg = null;
});
}

Expand All @@ -146,7 +147,10 @@ define(function (require, exports, module) {
runs(function () {
this.after(function () {
SpecRunnerUtils.closeTestWindow();
testWindow = null;
testWindow = null;
CommandManager = null;
Commands = null;
EditorManager = null;
});
});
}
Expand Down
9 changes: 8 additions & 1 deletion test/spec/EditorOptionHandlers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,16 @@ define(function (require, exports, module) {
checkCloseBraces(editor, {line: 1, ch: 7}, null, SINGLE_QUOTE, "// Yes, it is!");
});

// This must be in the last spec in the suite.
// This must be in the last spec in the suite. Note that it's possible to
// run a single test from suite, so this only works when running entire suite.
runs(function () {
this.after(function () {
testWindow = null;
CommandManager = null;
Commands = null;
EditorManager = null;
DocumentManager = null;
FileViewController = null;
SpecRunnerUtils.closeTestWindow();
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/spec/ExtensionUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ define(function (require, exports, module) {
});

afterEach(function () {
testWindow = null;
ExtensionUtils = null;
SpecRunnerUtils.closeTestWindow();
});

Expand Down
7 changes: 3 additions & 4 deletions test/spec/FileIndexManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ define(function (require, exports, module) {
// Load module instances from brackets.test
FileIndexManager = testWindow.brackets.test.FileIndexManager;
ProjectManager = testWindow.brackets.test.ProjectManager;


});
});


});

afterEach(function () {
brackets = null;
FileIndexManager = null;
ProjectManager = null;
SpecRunnerUtils.closeTestWindow();
});

Expand Down
19 changes: 11 additions & 8 deletions test/spec/InlineEditorProviders-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,11 @@ define(function (require, exports, module) {
});

afterEach(function () {
fullEditor = hostEditor = inlineEditor = null;
fullEditor = null;
hostEditor = null;
inlineEditor = null;
});


it("should insert new line at start of range, and stay open on undo", function () {
// insert new line at start of inline range--the new line should be included in
// the inline
Expand Down Expand Up @@ -1157,12 +1158,12 @@ define(function (require, exports, module) {
inlineEditor = hostEditor.getInlineWidgets()[0].editors[0];
});
});

afterEach(function () {
hostEditor = inlineEditor = null;
hostEditor = null;
inlineEditor = null;
});


it("should keep range consistent after undo/redo (bug #1031)", function () {
var secondInlineOpen = false, secondInlineEditor;

Expand Down Expand Up @@ -1218,11 +1219,13 @@ define(function (require, exports, module) {
fullEditor = EditorManager.getCurrentFullEditor();
});
});

afterEach(function () {
fullEditor = hostEditor = inlineEditor = null;
fullEditor = null;
hostEditor = null;
inlineEditor = null;
});

it("should delete line at bottom and not close on undo", function () {
expect(inlineEditor).toHaveInlineEditorRange(toRange(0, 2));

Expand Down
3 changes: 2 additions & 1 deletion test/spec/InstallExtensionDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define(function (require, exports, module) {
Strings = require("strings");

describe("Install Extension Dialog", function () {
var testWindow, dialog, fields, goodInstaller, badInstaller, InstallExtensionDialog, closed,
var testWindow, dialog, fields, goodInstaller, badInstaller, closed,
url = "http://brackets.io/extensions/myextension.zip";

beforeEach(function () {
Expand Down Expand Up @@ -717,6 +717,7 @@ define(function (require, exports, module) {

// THIS MUST BE THE LAST SPEC IN THE SUITE
it("should close the test window", function () {
testWindow = null;
SpecRunnerUtils.closeTestWindow();
});
});
Expand Down
50 changes: 48 additions & 2 deletions test/spec/JSUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ define(function (require, exports, module) {
var eof2JsFileEntry = new NativeFileSystem.FileEntry(testPath + "/eof2.js");

function init(spec, fileEntry) {
spec.fileJsContent = null;

if (fileEntry) {
spec.addMatchers({toMatchFunctionName: toMatchFunctionName});

Expand All @@ -74,13 +72,21 @@ define(function (require, exports, module) {
}
}

function cleanup(spec) {
spec.fileJsContent = null;
}


describe("JSUtils", function () {

beforeEach(function () {
init(this);
});

afterEach(function () {
cleanup(this);
});

describe("basics", function () {

it("should parse an empty string", function () {
Expand Down Expand Up @@ -121,6 +127,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "simple1", [ {start: 0, end: 2} ]);
expectFunctionRanges(this, this.fileJsContent, "simple2", [ {start: 7, end: 9} ]);
expectFunctionRanges(this, this.fileJsContent, "simple3", [ {start: 11, end: 13} ]);

cleanup(this);
});
});

Expand All @@ -133,6 +141,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "param1", [ {start: 18, end: 19} ]);
expectFunctionRanges(this, this.fileJsContent, "param2", [ {start: 24, end: 26} ]);
expectFunctionRanges(this, this.fileJsContent, "param3", [ {start: 28, end: 32} ]);

cleanup(this);
});
});

Expand All @@ -145,6 +155,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "single1", [ {start: 35, end: 35} ]);
expectFunctionRanges(this, this.fileJsContent, "single2", [ {start: 36, end: 36} ]);
expectFunctionRanges(this, this.fileJsContent, "single3", [ {start: 37, end: 37} ]);

cleanup(this);
});
});

Expand All @@ -157,6 +169,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "nested1", [ {start: 42, end: 50} ]);
expectFunctionRanges(this, this.fileJsContent, "nested2", [ {start: 44, end: 49} ]);
expectFunctionRanges(this, this.fileJsContent, "nested3", [ {start: 47, end: 48} ]);

cleanup(this);
});
});

Expand All @@ -169,6 +183,8 @@ define(function (require, exports, module) {
//expectFunctionRanges(this, this.fileJsContent, "functionX", [ {start: 53, end: 55} ]);
expectFunctionRanges(this, this.fileJsContent, "my_function", [ {start: 56, end: 57} ]);
expectFunctionRanges(this, this.fileJsContent, "function3", [ {start: 58, end: 60} ]);

cleanup(this);
});
});

Expand All @@ -186,6 +202,8 @@ define(function (require, exports, module) {
result = JSUtils.findAllMatchingFunctionsInText(content, name);
expect(result.length).toBe(0);
});

cleanup(this);
});
});

Expand All @@ -196,6 +214,8 @@ define(function (require, exports, module) {

runs(function () {
expectFunctionRanges(this, this.fileJsContent, "myMethod", [ {start: 66, end: 68} ]);

cleanup(this);
});
});

Expand All @@ -212,6 +232,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "noSpaceAfterFunction", [ {start: 86, end: 88} ]);
expectFunctionRanges(this, this.fileJsContent, "noSpaceAfterFunction2", [ {start: 90, end: 92} ]);
expectFunctionRanges(this, this.fileJsContent, "findMe", [ {start: 93, end: 93} ]);

cleanup(this);
});
});

Expand All @@ -224,6 +246,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "highAscÍÍChars", [ {start: 95, end: 97} ]);
expectFunctionRanges(this, this.fileJsContent, "moreHighAscÍÍChars", [ {start: 99, end: 101} ]);
expectFunctionRanges(this, this.fileJsContent, "ÅsciiExtendedIdentifierStart", [ {start: 103, end: 104} ]);

cleanup(this);
});
});

Expand All @@ -235,6 +259,8 @@ define(function (require, exports, module) {
runs(function () {
expectFunctionRanges(this, this.fileJsContent, "ʸUnicodeModifierLettervalidIdentifierStart", [ {start: 106, end: 107} ]);
expectFunctionRanges(this, this.fileJsContent, "unicodeModifierLettervalidIdentifierPartʸ", [ {start: 112, end: 113} ]);

cleanup(this);
});
});

Expand All @@ -249,6 +275,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "unicodeEscapedIdentifierPart\u02b8", [ {start: 115, end: 116} ]);
expectFunctionRanges(this, this.fileJsContent, "unicodeTabBefore", [ {start: 118, end: 119} ]);
expectFunctionRanges(this, this.fileJsContent, "unicodeTabAfter", [ {start: 121, end: 122} ]);

cleanup(this);
});
});

Expand All @@ -261,6 +289,8 @@ define(function (require, exports, module) {
expectFunctionRanges(this, this.fileJsContent, "toString", [ {start: 1, end: 3} ]);
expectFunctionRanges(this, this.fileJsContent, "length", [ {start: 6, end: 8} ]);
expectFunctionRanges(this, this.fileJsContent, "hasOwnProperty", [ {start: 11, end: 13} ]);

cleanup(this);
});
});

Expand All @@ -273,6 +303,8 @@ define(function (require, exports, module) {
expectNoFunction(this.fileJsContent, "0digitIdentifierStart");
expectNoFunction(this.fileJsContent, ".punctuationIdentifierStart");
expectNoFunction(this.fileJsContent, "punctuation.IdentifierPart");

cleanup(this);
});
});
});
Expand All @@ -282,6 +314,10 @@ define(function (require, exports, module) {
init(this, braceEndJsFileEntry);
});

afterEach(function () {
cleanup(this);
});

function expectEndBrace(spec, funcName) {
var startPos = spec.fileJsContent.indexOf("function " + funcName);
expect(startPos).toNotBe(-1);
Expand Down Expand Up @@ -334,6 +370,7 @@ define(function (require, exports, module) {
init(this, eofJsFileEntry);
runs(function () {
expect(JSUtils._getFunctionEndOffset(this.fileJsContent, 0)).toBe(this.fileJsContent.length);
cleanup(this);
});
});
});
Expand All @@ -343,6 +380,7 @@ define(function (require, exports, module) {
init(this, eof2JsFileEntry);
runs(function () {
expect(JSUtils._getFunctionEndOffset(this.fileJsContent, 0)).toBe(this.fileJsContent.length);
cleanup(this);
});
});
});
Expand All @@ -353,6 +391,10 @@ define(function (require, exports, module) {
init(this, jQueryJsFileEntry);
});

afterEach(function () {
cleanup(this);
});

it("should find the first instance of the pushStack function", function () {
var funcNames = JSUtils.findAllMatchingFunctionsInText(this.fileJsContent, "pushStack");
expect(funcNames).not.toBe(null);
Expand Down Expand Up @@ -405,6 +447,10 @@ define(function (require, exports, module) {
});

afterEach(function () {
DocumentManager = null;
FileIndexManager = null;
FileViewController = null;
JSUtils = null;
SpecRunnerUtils.closeTestWindow();
});

Expand Down
16 changes: 14 additions & 2 deletions test/spec/LiveDevelopment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,18 @@ define(function (require, exports, module) {
return (LiveDevelopment.status === LiveDevelopment.STATUS_INACTIVE);
}, "Waiting for browser to become inactive", 10000);

SpecRunnerUtils.closeTestWindow();
runs(function () {
testWindow = null;
LiveDevelopment = null;
LiveDevServerManager = null;
DOMAgent = null;
DocumentManager = null;
CommandManager = null;
Commands = null;
NativeApp = null;
ProjectManager = null;
SpecRunnerUtils.closeTestWindow();
});
});

it("should establish a browser connection for an opened html file", function () {
Expand Down Expand Up @@ -559,6 +570,7 @@ define(function (require, exports, module) {
SpecRunnerUtils.destroyMockEditor(testDocument);
testDocument = null;
testEditor = null;
testCSSDoc = null;
});

it("should toggle the highlight via a command", function () {
Expand Down Expand Up @@ -689,7 +701,7 @@ define(function (require, exports, module) {
SpecRunnerUtils.destroyMockEditor(testDocument);
testDocument = null;
testEditor = null;

testHTMLDoc = null;
instrumentedHtml = "";
elementIds = {};
});
Expand Down

0 comments on commit 48ad413

Please sign in to comment.