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
Go to the "Sources" tab. At the top right hand side, toggle the button that looks like the pause symbol surrounded by a hexagon (button on the far right) until the color of the circle turns black to turn it off. If the pause symbol isn't blue it may be that you've accidentally marked a line for debugging inspection.
To end a debugging session in Microsoft Visual Studio, from the Debug menu, choose Stop Debugging.
It is a simple matter to bypass the default pauses when starting a project for debugging. Simply open the debug configuration window by clicking on the gear icon as shown below. Select the "Startup" tab. Simply uncheck the "Set Breakpoint at" box and check the "Resume" box, then click OK.
Open the Sources panel in Developer Tools ( Ctrl + Shift + I **). Click the Pause button to Pause script execution.
The issue doesn't happen anymore. It seems like it was a bug in chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With