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

Fixed leak in menu.js file. Fixes #12765 #12767

Merged
merged 5 commits into from
Sep 10, 2016
Merged

Fixed leak in menu.js file. Fixes #12765 #12767

merged 5 commits into from
Sep 10, 2016

Conversation

daytonjallen
Copy link
Contributor

@daytonjallen daytonjallen commented Sep 9, 2016

Fixes #12765

@ficristo
Copy link
Collaborator

ficristo commented Sep 9, 2016

I know it is a bit confusing, but please, revert the changes to src/config.json.

@daytonjallen
Copy link
Contributor Author

I don't remember touching that file but I've reverted the changes. Sorry about that. Now the test is failing, looking into that now.

@daytonjallen
Copy link
Contributor Author

Checking the CI logs, I think the reason for the build failure isn't anything on my end. Right?

@marcelgerber
Copy link
Contributor

Yes, the build failure was on our side. It passed now 👍

cc @zaggino for review

@zaggino
Copy link
Contributor

zaggino commented Sep 9, 2016

@daytonallen the code is great, but is missing a test and that should be done in this case as test for this is easy to write, please add it somewhere here: https://github.com/adobe/brackets/blob/master/test/spec/Menu-test.js#L660-L737

You should write it in a way that it fails when you comment out the removeMenuItemEventListeners(commandObj); call you added and passes when you uncomment it.

You'll need to compare contents of ._eventHandlers[eventName].length before and after calling removeMenuItem in the test.

@zaggino zaggino added this to the Release 1.9 milestone Sep 9, 2016
@zaggino zaggino self-assigned this Sep 9, 2016
@daytonjallen
Copy link
Contributor Author

daytonjallen commented Sep 9, 2016

How do I run the tests locally to check if it's done correctly? I tried the debug's menu run tests option but it doesn't seem to be detecting a new test case. @zaggino

@zaggino
Copy link
Contributor

zaggino commented Sep 9, 2016

@daytonallen did you setup your installed Brackets with your cloned Brackets folder like in here https://github.com/adobe/brackets/wiki/How-to-Hack-on-Brackets ? See the setup_for_hacking thingy.

@zaggino
Copy link
Contributor

zaggino commented Sep 9, 2016

If you did, please push the testcase here, maybe something else is wrong with it, you can still correct it with additional commits.

@zaggino
Copy link
Contributor

zaggino commented Sep 10, 2016

@daytonallen you need to look for it here, it runs for me:
image
image

@daytonjallen
Copy link
Contributor Author

Turns out I was testing under the wrong grouping.

expect(typeof (command)).toBe("object");

// Test event
command.on("nameChange", menuItem._nameChanged);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't add event manually with .on, you should just do expect for events that are added by addMenuItem

@zaggino
Copy link
Contributor

zaggino commented Sep 10, 2016

@daytonallen
You can remove stuff copied from other tests, it should be somthing simple like

menu.addMenuItem(commandId);
expect(command._eventHandlers....);
menu.removeMenuItem(commandId);
expect(command._eventHandlers....);

everything else doesn't need to be there

*/
function removeMenuItemEventListeners(command) {
command
.off("enabledStateChange", command._enabledChanged)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the code now, _enabledChanged and other methods live on MenuItem not on command ... are you sure that you're not calling .off("enabledStateChange", undefined) ???

@zaggino zaggino merged commit 7bce131 into adobe:master Sep 10, 2016
@zaggino
Copy link
Contributor

zaggino commented Sep 10, 2016

Thanks @daytonallen merged to master! 👍

@daytonjallen
Copy link
Contributor Author

My pleasure. Thanks for all the guidance also.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants