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

Browser issue #12946

Merged
merged 7 commits into from
Dec 6, 2016
Merged

Browser issue #12946

merged 7 commits into from
Dec 6, 2016

Conversation

jamran7
Copy link
Contributor

@jamran7 jamran7 commented Nov 26, 2016

The solution code is in the commit: Browser issue fix

This is a bug fix for issue:(Brackets turns into a web browser #12441).

Description: Filters out drag/drop events from text strings being dropped into Brackets that will actually change the DOM structure of the Brackets layout. It looks for a “text/url-list” type in the types list and stops the event propagation if there are any.

All unit tests and smoke tests were performed and passed.

Here is a test that verifies that the solution works:
Settings should be as they are in a smoke test

  1. Create an empty folder externally.

  2. Open the folder with Brackets.

  3. Enable "dragDropText" in Brackets preferences.

  4. Drag a text or HTML file into Brackets.

  5. The file should be open and focused in the workspace.

  6. Open up a browser.

  7. Type in any valid URL (a webpage with text) and go there in the browser.

  8. Add a few lines to the test file that was opened in Brackets.

  9. Highlight some text from the webpage and copy it to a line in the test file.

  10. Verify that the text in Brackets can be highlighted and dragged to any other line.

  11. Drag the URL from the Browser’s URL field into Brackets. Do this several times over all areas of the Brackets editor.

  12. Verify that the URL did not drop into Brackets, or Brackets refuses the URL, and that Brackets remains an editor and not a browsable webpage. Failed test: If Brackets does become a webpage restart Brackets and perform steps 1 through 5.

  13. Set the view to Vertical Split.

  14. Open another test file and verify steps 1 through 5 in the other non-used split view.

  15. There should be two test files open, one in each view. Perform steps 6 through 12 for both split editors.

  16. Perform steps 13 through 15 for a Horizontal Split view

My repo: https://github.com/jamran7/brackets

This is on behalf of ChainsawFist

These two sections check for Urls being dragged in to the browser.
So for some reason this changed which I did not perform showed up in my
master it seemed that one did not have access and the new one did. In
the health status test under extension tests, the connection would
timeout.
JSLint want’s this instead of “==“. I had actually done a check with an
online checker and I forgot to make the change.
Copy link
Collaborator

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

Reviewed, nice work ChainsawFist and @jamran7!

If ChainsawFist is the original author as the PR comment points out, I think s/he should also sign the CLA.

@@ -20,7 +20,7 @@
"extension_url": "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
"linting.enabled_by_default": true,
"build_timestamp": "",
"healthDataServerURL": "https://healthdev.brackets.io/healthDataLog"
"healthDataServerURL": "https://health.brackets.io/healthDataLog"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unneeded change here, there's a fix coming for this file getting changed automatically hopefully soon but needs to be removed from this PR. 😕

@@ -156,6 +156,18 @@ define(function (require, exports, module) {
event = event.originalEvent || event;

var files = event.dataTransfer.files;

var types = event.dataTransfer.types;
if(!files.length){// stop default behavior if a url is dragged in so the browser does not takeove
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can files also be null? The file handler below seems to suggest that, so it might be worth guarding against it (if(!files || !files.length).


var types = event.dataTransfer.types;
if(!files.length){// stop default behavior if a url is dragged in so the browser does not takeove
types.forEach(function (value){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can types be null?

@@ -174,6 +186,18 @@ define(function (require, exports, module) {
event = event.originalEvent || event;

var files = event.dataTransfer.files;

var types = event.dataTransfer.types;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be worth it to move these blocks into a function call such as stopURIListPropagation() or similar instead of repeating the blocks of code.

@jamran7
Copy link
Contributor Author

jamran7 commented Nov 27, 2016

ChainsawFist is the organization that I am representing in this PR; it was created as part of a college course project. We have a repo of Brackets and we have been using it to test our bug fixes. I have a cleaner repo of the latest commit, while the one with ChainsawFist is far behind and has multiple changes; we are using the later repo as "show-and-tell" so our professor can keep track of our progress. Right now I'm incorporating fixes that have not been closed by adobe/brackets as part of our assignment. I suppose I could create another repo in ChainsawFist that way there's no confusion and I don't have to keep mentioning the organization. I will make the changes as you suggested. Thank you.

@petetnt
Copy link
Collaborator

petetnt commented Nov 27, 2016

Thanks for the clarification @jamran7!

These are the changes as requested by @petetnt. The behavior was packed
into a function. Generally `types` is not null but was protected on the
case it is. Files must be null or the length must be 0 now.
@jamran7
Copy link
Contributor Author

jamran7 commented Nov 28, 2016

Can you rerun that build. api.github.com gave Travis a 403.

Fixed extra indentation and spacing issues
Cleaned up the comments, some were redundant to the functions
description. I gave the different cases of `types` values when files
and text is dragged/dropped into Brackets.
@jamran7
Copy link
Contributor Author

jamran7 commented Nov 30, 2016

I've fixed the indent in the function as well as cleaned up some of the comments.

@petetnt
Copy link
Collaborator

petetnt commented Dec 1, 2016

This looks great, I'll do another round of testing and then merge this in if all is good 👍

@petetnt
Copy link
Collaborator

petetnt commented Dec 2, 2016

Does this PR fix #12961 too? If it doesn't yet, I think it could be trivially added too, right?

@jamran7
Copy link
Contributor Author

jamran7 commented Dec 5, 2016

Yes that issue seems to be fixed by this.

@petetnt
Copy link
Collaborator

petetnt commented Dec 6, 2016

Thanks for this great PR @jamran7 & ChainsawFist 👍

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.

2 participants