I have inherited an application that download a js code from another place and with the help of the
IWebBrowser2 interface in Windows it runs this js in that browser inside a hWindow.
While i run the app on the machines with IE9 and IE10 no popups with script errors. When i run the app in a machine with IE8 i can see a script error message appears. I tried to disable the script errors inside the Internet options advanced tab and also cleared the Enable 3-party browser extensions.
Those didn't help to suppress the script Error. Perhaps, someone knows how i can get rid of the script error in IE8.
Related
I have a webpage that I want to show in a WebView embedded in a mobile application (for Android as well as iPhone). That webpage is for testing javascript scripts. The page calls a certain set of JS scripts (tests) and these tests give their output into the console (this is where I can diagnose what happened during the tests). Using console.log. Plus exceptions are shown in the console.
When the tests fail, the JS error handler will notify me about and I can show that fact on my webpage so that I can see it on the phone. But I also need to look at the JS console to understand what went wrong.
How do I access the JS console on the phone when the test result tells me it failed?
One option that I was thinking about was to output the content of the console somehow into the webpage content (DOM) so that I can look at it in the app (in the embedded webview since it would be the content of the page shown). But I don't know whether it is possible in Javascript to output the console into HTML somehow.
I do not develop the mobile application, just deliver the content that the application shows in the WebView. Therefore I would need a solution that does not depend on the application itself, just have something I can see in the WebView ideally. Something like when you debug your javascripts in Chrome, you open the DevTools window and work with it. If there was no DevTools on Chrome, would there be a way to see the contents of the console?
Sure I can use various simulators or do the test on other browsers without real phones but this is specifically for tests that fail only on the mobile and I need to find out why.
For Android:
Maybe this link should help you : https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
Using the Chrome dev mode on your computer, you should be able to debug your webview
About IPhone, I don't know but Xcode or something like should help
Would like to share this issue I recently debugged.
I was getting this error in Chrome console for a particular page.
Debugged the script - No error, actually the script is working correctly in some other modules and components.
"officeUtilities" script is not loading due to this error.
Although I couldn't fix it in the active session of browser, following worked for me.
- Opening page in Chrome incognito mode and other browsers (Firefox, Edge, IE).
I think it is caching issue. I deleted all browser cached images and files , but that didn't work. I didn't tried to delete all history, that will end up logging out of multiple sites.
Since I found a alternative way to test the page, I'm Okay with it.
I get the following error in Chrome when loading a trivially simple html file with a jQuery Mobile reference. The error is not present with just the jQuery reference.
Uncaught SecurityError: Failed to execute 'replaceState' on 'History':
A history state object with URL 'http://stacksnippets.net/js' cannot
be created in a document with origin 'null'.
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
</head>
<body></body>
</html>
You can also "Run code snippet" and see the error in the console.
This error did not happen before today. I have not changed my code or method of loading the html file in the browser. It used to work perfectly - I use the same code for all my PhoneGap apps.
Does anyone know if there was a Chrome security update that causes this SecurityError or whether I'm missing something? How would you go about debugging this? Thank you.
UPDATE
This discussion I think points out what is going on, which I suspected, since the error does not appear when running with a web server: Origin null is not allowed by Access-Control-Allow-Origin .
But I am still wondering why this changed in the past day, whether Chrome has had a change in their security policy, or why it was working before, and whether any of my PhoneGap apps will be affected.
This error is same as the origin is null error. This error occurs because of the security feature of Chrome.
A simple solution to test the application is to bypass this security on chrome.
Steps:
create a chrome browser shortcut on desktop.
Close all the instances of chrome on your machine.
Right click on the desktop shortcut of chrome and click on Properties.
in Target field, append " -allow-file-access-from-files" at the end.
Save and close properties.
Open chrome via this shortcut only.
Hurry, the error has gone. App works perfectly.
NOTE: This is just a work-around I use to test my cordova apps on desktop browser for UI testing.
Temporary solution: I've commented out all history.replaceState calls in jquery mobile, didn't need to manipulate browser history in my app anyways.
I wonder if it's chrome security bug or model and future behavior.
On a Mac I was able to fix this by running a webserver instead of loading it from a "file://" url:
http://lifehacker.com/start-a-simple-web-server-from-any-directory-on-your-ma-496425450?utm_expid=66866090-49.VYy4WCNHSyuP6EmjnM93MQ.0&utm_referrer=https%3A%2F%2Fwww.google.com%2F
python -m SimpleHTTPServer 8000
In the directory should make it available from Chrome via 0.0.0.0
I don't seem to have the same problem, not on the stable version of Chrome (45) or the Dev version (47).
However, I have personally seen issues with the CORS header, too. If you can cause the problem to happen reliably, I suggest filing a bug at crbug.com and a Chrome developer will have a look at it.
I'm having a real problem trying to attach the JavaScript debugger in VS2008 to a web project. The web app is an ASP.NET MVC project but I don't think that should matter.
I'm using jQuery and have a .js file loaded when the page loads and in this .js file I call $(document).ready(function() { ... } and do some stuff and this "works." When I set a breakpoint it becomes disabled when I run the project through Cassini with the message "The breakpoint will not currently be hit. No symbols have been loaded for this document."
This error message is somewhat confusing because this is a javascript file so I would expect it to have a symbols file that could be loaded. i.e. a .pdb file that you would need to debug server side code. Or am I missing something here?
I found this post here:
Using breakpoints to debug Javascript in IE and VS2008
but that didn't help.
I've also tried a few other recommendations which involved attaching the browser from the debug menu after starting the debug session and I've tried doing this on IE x86, IE x64, and Firefox. If I add "debugger;" to my code then it will break in Firefox and let me step through the code in the Firefox debugger but I can't get it to do this in VS2008.
I'm running Win7 x64 Ultimate with VS2008 and the project is ASP.NET MVC with jQuery.
Any ideas?
have you tried debug the js file alone(put a debugger in code) by adding it to a blank html page?? and check whether it ll throw a script breakpoint exception and allow you to attach to VS 2008??
Have you checked the "enable script debugging" option under tools (not sure what it's called, on a Mac right now) in IE?
I'm having a really annoying problem with debugging javascript with VS2008.
If I simply press F5 (or choose 'start Debugging' from the Debug menu), the iexplore process is attached, but no breakpoints break in the scripts. The Script Documents tree doesn't even appear in the solution explorer.
I already know:
I can set a breakpoint in Javascript just fine. It does NOT show the "This point will not be hit" message.
Calling the debugger through using the 'debugger' keyword works fine, but attaching to the iexplore process doesn't since it gives a "process already attached to a debugger" message.
Using the manual 'Attach to process...' works just fine. The Script Documents appears as well.
The project has recently been converted to a Web Application from a WebSite.
I already tried:
Clearing the IE cache.
Shutting down VS2008, Stopping the IIS and deleting the temporary asp.NET files restarting both IIS and VS2008 afterwards.
Setting IE7 as the default browser both for windows and for VS2008.
Resetting my user settings for VS2008.
Checking that IE script debugging is enabled.
Nothing has worked so far. While Attaching to process isn't too taxing, it is very annoying when I'm used to just hitting F5.
If anyone can think of a solution, please please please (I'm begging here!) let me know!
Is silverlight debugging enabled on the website project properties? This will disable Javascript debugging.