I have a piece of code* that should run properly, but it seems that it only runs in:
- JSFiddle
- StackSnippet if you are using Edge
It doesn't run in (only tested in my Win 11 machine):
- StackSnippet in Firefox (95.0.2 64-bit)
- In Edge, which is opened by VSCode
- In my website
There is simply nothing in the log. I learn about Edge's debugger but I don't know what event listener breakpoint should be used, since this should load without user interaction. The other types of breakpoint are empty (except CSP violation breakpoints), which I don't think relevant here.
I try to add debugger
in various places in the function, before and after the loop (see in the code), but it only stops at the breakpoints outside the function. Of those, I don't see anything pop up in the Variables or Watch panels.
User @charlietfl in the meta question about this issue says:
I get "operation is insecure" error thrown in FF on win 10. That is possibly due to some of the features that snippets disable. For example they disable access to API's like localStorage and postMessage
The fact that the same code run perfectly fine in some engines indicates that there is nothing wrong with the code, but in the engines. Is that correct?
Is there a way to debug this?
function myfunction(context, id, func, str) {
context[id] = undefined;
debugger;
return context[func] = function() {
var config = {
containerId: id,
initialCypher: str,
neo4j: {
serverUrl: 'bolt://b95e1176.databases.neo4j.io',
serverUser: 'neo4j',
serverPassword: 'jgqHo9s6c2fCRv_mT2l1S693dSQ0GKYYC0LZ5Rn7XI8',
driverConfig: {
encrypted: "ENCRYPTION_ON",
trust: "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"
},
},
labels: {
note: {
label: "wrappedname",
group: "group",
value: "degree_und",
},
}
}
debugger;
context[id] = new NeoVis.default(config);
debugger;
context[id].render();
debugger;
console.log(`function ${func} was called and ${id} is the id`);
};
}
debugger;
for (let item of document.querySelectorAll("#foo, #lorem, #dolor")) {
myfunction(window, item.id, item.getAttribute("data-function"), item.innerText)();
}
debugger;
<script src="https://unpkg.com/neovis.js@2.0.0-alpha.9"></script>
<div id="foo" data-function="bar">match (n)-[r]-(m) return n,r,m</div>
<div id="lorem" data-function="ipsum">match (n)-[r]-(m) where n.gid='Cx' and m.gid='Cx' return n,r,m</div>
<div id="dolor" data-function="es">match (n)-[r]-(m) where n.gid='Kt' and m.gid='Kt' return n,r,m</div>
Here is the expected result:
*Suggested from A piece of JS code is needed to use multiple times with different values and function names. How to do it efficiently?