Reputation: 1750
I have added a breakpoint to the following code in line 44 debugger;
. I expected chrome to stop there every time before console.log("...")
is executed. But to my surprise it stops only one time.
To test the example:
At this point chrome stops at the breakpoint. But if you look in the console you should see that the console.log
statement was executed two more times.
I would like to know why this happens. (Threading issue??)
And how I can solve this if I want to debug the code at this line.
$(document).ready(function() {
$('#drop-area').on("dragover", function(event) {
event.preventDefault();
event.stopPropagation();
$(this).addClass('dragging');
});
$('#drop-area').on("dragleave", function(event) {
event.preventDefault();
event.stopPropagation();
$(this).removeClass('dragging');
});
$('#drop-area').on("drop", function(event) {
event.preventDefault();
event.stopPropagation();
var count = 1;
var dropObj = event.originalEvent.dataTransfer;
for (var i = 0; i < dropObj.items.length; i++) {
var aDropItm = dropObj.items[i];
if (aDropItm.kind == "file") {
//ignore
} else {
aDropItm.getAsString(function(_str) {
debugger; //The debugger should stop here every time before the string is printed to the console
console.log("This was called [" + count++ + "] times");
});
}
}
});
});
#drop-area {
background-color: red;
width: 400px;
height: 400px;
}
<div id="drop-area">Drop files here...</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
EDIT
I reported this as a bug here:
https://bugs.chromium.org/p/chromium/issues/detail?id=748923
Upvotes: 8
Views: 1553
Reputation: 1750
The issue doesn't happen anymore. It seems like it was a bug in chrome.
Upvotes: 1