I'm using WebStorm (8.0.4) in a Mac (Mavericks last version). I'm trying to debug this simple loop for script:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<10; i++)
{
console.log('hola!');
}
</script>
</body>
</html>
I am using Chrome with JB Extension with this configuration:
Host: 127.0.0.1 Port: 63342
In the settings of the Project, in Javascript, Debugger I have this configuration:
Built-in server port: 63342
The code STOP in the breakpoint (in the loop for), but after one second, I have a message that says:
Disconnected (browser disconnected)
and I lost the debug mode...
I'm very lost and I don't know what happens... any help please?
Regards
I had the same problem. Debugging stopped after 1 second
Two things I changed:
Downloaded the latest version of WebStorm (8.05)
Before the debug opened the configuration and looked at all pages and save it.
After this, it just worked again.
The issue is caused by Chrome update.
Chrome API changes in versions 37+ have made it incompatible with WebStorm debugger. WEB-12418 is fixed in WebStorm 8.0.5 and WebStorm 9 EAP.
Related
The following code shows an <iframe sandbox... pointing to a page that opens a test websocket with a message on successful open. It works correctly on Chrome and Edge printing the It worked! message immediately.
On Firefox it fails with Uncaught DOMException: The operation is insecure. and no further reasoning.
<!DOCTYPE html>
<html lang="en">
<body>
<iframe
sandbox="allow-scripts"
src="https://firefox-wss-example.tiiny.site/"></iframe>
</body>
</html>
The linked websocket page source code is simply as follows:
<!DOCTYPE html>
<html lang="en">
<body>
<script>
const ws = new WebSocket('wss://demo.piesocket.com/v3/channel_1?notify_self');
ws.addEventListener('open', () => {
console.log('It worked!');
});
</script>
</body>
</html>
I have tried a mixture of wss:// and ws://, as well as permissive CORS headers, but none of my attempts fix the issue on Firefox despite having an appropriate setup. I am starting to think this is a Firefox 97 bug but am unsure of how to verify.
Why does this snippet work on most browsers but fails on Firefox?
I've been through this before, spend weeks on investigations, what I found is: Firefox runs sandboxed JavaScript under the blob:// protocol, and you're only allowed to upgrade to WebSocket from http:// and https:// connections. blob:// isn't either.
Although it's not very clear in their documentation, you may take a look into the websocket upgrade implementation as well as in this issue about CSP inheritance to understand it better, but it's basically the way Firefox have chosen to implement Sandboxing.
We never found a workaround for this, the only way was to drop the Sandboxing, or drop Firefox support for this specific feature.
On the other hand, Chromium based browsers saves the script file locally (I cannot say with 100% of confidence if it is stored in a temporary directory or virtual file system), and still uses the http:// protocol to access them, this way you can upgrade to ws:// or wss://. Those browsers may also inherit CSP, since they keeps the opener instance.
Edit: This problem is not tied to an specific Firefox version, it has been implemented this way for a long time. I has been 5 or 6 releases from the time I went into this problem, it still this way, and will probably stay this way, it's not considered a bug and it's not close to a highly requested feature.
The CHM viewer on Windows 10 does not allow me to use the 'window' object in JavaScript, although on Windows 7 it works perfectly with the same version of Internet Explorer.
To reproduce this problem:
Copy this code into a file 'index.htm'
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Inner width: " + window.innerWidth + "<br>");
try
{
window.addEventListener('scroll', function(e)
{
document.write("Scroll<br>");
} );
document.write("All right.<br>");
}
catch (ex)
{
document.write("Exception: " + ex.message + "<br>");
}
</script>
</body>
</html>
Then copy this code into a file 'Test.hhp'
[OPTIONS]
Binary Index=No
Compatibility=1.0
Compiled file=Test.chm
Default Window=>MainHelp
Default topic=index.htm
Display compile progress=Yes
Language=0x409 Englisch (USA)
Title=Testing
[WINDOWS]
>MainHelp="Testing",,,"index.htm",,,,,,0x40000,,0x0,[50,50,900,750],,,,,,,0
Copy both files into the same directory and compile them with the Html Help Workshop.
On Windows 7 it works as expected:
On Windows 10 it works in Internet Explorer, but not in the CHM file:
There seems to be a security restriction in Windows 10 which is not in Windows 7.
Is there any registry key or any Internet Explorer setting which I can modify to give the CHM viewer the permission to access the 'window' object ?
Edit: After reading the answer from Dai I found why it worked on Windows 7 and not on Windows 10. It has nothing to do with the Windows version. The reason is that on my Windows 7 another software already had set the registry key
[HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
hh.exe = 9000
I could reproduce this behavior on my German Windows10 PC.
Add the following statement to the <head> section of the index.htm file.
This works for me even if the HTML topic file is compiled into a .chm help file.
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/>
e.g.:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/>
</head>
is resulting in following help viewer window:
Edit: A comprehensive answer related to x-ua-compatible was given on SO for following question:
What does <meta http-equiv="X-UA-Compatible" content="IE=edge"> do?
Quoted from Microsoft docs Use Enterprise Mode to improve compatibility:
If you don't have IE11 installed anymore, you can download it from the Internet Explorer 11 download page. Also, if you use an earlier version of Internet Explorer, upgrade to IE11. Windows 7, Windows 8, and Windows 10 support IE11 so that you can continue using legacy apps even as you migrate to Windows 10 and Microsoft Edge.
Consider this simple HTML file:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
alert('1');
</script>
</body>
</html>
When I enable Firefox JavaScript Debugger (via Ctrl+Shift+S), the panel shows me the following error message instead of the source code:
Error loading from source:
loadSourceError
What am I doing wrong?
My bet is that it comes from some server setting, since it works fine from another server (as well as locally), but I cannot identify any noticeable difference between both configurations (apache.conf are identical, /etc/apache2/sites-enabled/ configuration is similar, enabled modules are the same. I had the hope that installing the javascript-common debian package would help, but it does not…).
JavaScript itself is served correctly, though (even the embedded JS), and there is no loading problem for JS files.
Got it!
It seems that the debugger has issues with internationalized domain names (IDN).
I'd like to explain what does "Javascript not working" mean, but the only thing I can do is tell that the code is never executing, and don't know how to debug.
Let's start: I'm developing a Phonegap application - in that sense, I don't have a console object to check on.
This is my index.html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>1001Carros</title>
</head>
<body>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
adaptandose a dispositivo ...
</body>
</html>
And this is my javascript:
var app = {
// Application Constructor
initialize: function() {
switch(device.platform) {
case "iPhone":
location.href = "index-iphone.html"; break;
case "Android":
case "BlackBerry":
case "BlackBerry WebWorks":
location.href = "index-android.html"; break;
default:
location.href = "index-android.html";
}
}
};
My intention is: when the document is loaded, initialize() is called. Such method would verify the platform and redirect to the appropiate screen.
When I run my app in the emulator (which finally appends ?enableripple=cordova to my url), I get that "phonegap.js" does not exist. If that's the problem, it seems easy to explain why I'm not being redirected.
However, when I compile the application via local tools (i.e. phonegap run android) such file seems to be created in the assets directory (in android platform).
Question: How can I debug this issue? I'm using the emulator and, alternatively, a Samsung Galaxy Tab 3. I would like to debug the device and see if the problem is with the file (as it is shown in the emulator/ripple) or is it elsewhere.
It'd be great if someone with more experience could help me if they had a similar problem since it's my first phonegap application.
To answer your question about debugging, since your devices most likely don't have a console, you'll have to use alerts. I like to use alerts to test if a function is firing, if the appropriate data is being stored/passed, etc.
As for why your javascript is not working, I'm not positive but I think it has to do with you using "app". I believe that is reserved for native phonegap things, as seen in "navigator.app.exit()". I would suggest you rename the variable and try that.
I don't understand your question clearly. But i see your code has issue. In phonegap, all API device(provided by phonegap) must be call when event deviceready fired:
document.addEventListener('deviceready', function(){
// Code here
}, false);
In phonegap, support many tools to debug app now: phonegap debug, weinre is power
You can use console.log('...'), it support any device, see log in your IDE: Xcode, Eclipse,..
There are plenty of ways to debug your phonegap code on android:
logcat
Weinre: http://people.apache.org/~pmuellr/weinre/docs/latest/Home.html
Chrome Remote Debugging (only Android 4.4+): https://developer.chrome.com/devtools/docs/remote-debugging
..
i am using requires.js 2.0. I have the following simplified use case:
my HTML file:
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<script type="text/javascript" data-main="apptest.js" src="../_js/libs/require/require.js"></script>
</head>
<body>
</body>
</html>
And then in apptest.js:
requirejs.config({
paths: {
'text': '../_js/libs/require/text'
}
});
requirejs(
['text!boxes.html'],
function (Boxes) {
alert("done");
}
);
Ok, so it doesn't really do much, but enough to make my point. Only in Firefox (14.0.1) i get an exception "uncaught exception: java.security.AccessControlException: access denied (java.io.FilePermission .\boxes.html read)".
So, require.js successfully loaded the text plugin, but fails loading my html file, which i want to use as a template later on. In Google Chrome and even IE9 it works just fine. I am on Windows 7.
I am running this on a local webserver, so no file://... requests here.
I have checked, if i have any special permissions set on the html file, but have not found anything suspicious.
Anyone have an idea?
Update: Running the test in Firefox 13.0.1 does actually work for me without errors. So could it be, that this is a bug, that has been introduced in firefox 14?
I was having the same problem a minute ago. I've fixed it by doing the following in the main.js file (where you setup the config)
Before the
require.config({.....
add the following code:
Packages = undefined;
This should do the trick.
You should have something like this:
Packages = undefined;
require.config({
baseUrl: theAppBaseUrl,
paths: {
Basically the explanation is that it is trying to use Java to get the file instead of an ajax request (for whatever reason). This forces it to use an XHR object to fetch it.
Cheers!