What does view-response.js in Chrome do? - javascript

When loading a page (200 OK response header), I received an error in the HTTP response add-on for Firefox:
[Exception... "File error: Not found" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: chrome://view-response/content/view-response.js :: sendRequest :: line 186" data: no]
What does that file do? (Contents pasted into JSBin here, notice how semicolons are missing.)
I was able to open it in Firefox and not just Chrome (but not Opera and IE).

That's an error with the plugin internal code, nothing to do with your code. The chrome:// is a little misleading, it's nothing to do with Google Chrome, Mozilla refers to elements of their UI engine as the "chrome".
The error is specifically around the line:
xhr.send(valueOfElement("body-textarea"))
Which is an ajax request initiated on this line:
xhr.open(valueOfElement("method-select"), valueOfElement("uri-input"), true)
...and since you are getting NS_ERROR_FILE_NOT_FOUND I presume the that URL return by the function call valueOfElement("uri-input") is returning a 404 or may be an invalid URL.
The lack of semi-colons in the JS file is (IMO) bad practice, but nothing to do with the error.
Long story short: ignore the error, there's nothing you can do about it except for add some error handling and rebuild the plugin package, which you probably can't do in a meaningful way unless you wrote the plugin.
It has nothing to do with your site code.

Related

Javascript - "Cannot read property 'closingEls' of undefined" and "Script error."

I get the following errors in the JavaScript console with no file source hint:
Uncaught TypeError: Cannot read property 'closingEls' of undefined
and
Script error
These errors prevent my page from running scripts and I don't understand what kind of errors they are.
I tried searching what 'closingEls' is, but no luck. I don't know what type of tags I need to put in this question due to the vague nature of these errors.
Edit 1: Please, before you say show us the code, read the question! my scripts do not run in the first place. And this errors does not come out of the site's scripts, it comes from the user's agent trying to load the page.
Edit 2: Please, advice a way to deal with the users having this errors and can not load the page successfully. I would consider this very helpful, constructive and question-related.
The "Script error." happens in Firefox, Safari, and Chrome when an exception violates the browser's same-origin policy - i.e. when the error occurs in a script that's hosted on a domain other than the domain of the current page.
Can read more over here:
http://blog.errorception.com/2012/04/script-error-on-line-0.html
https://blog.sentry.io/2016/05/17/what-is-script-error.html
Regarding "Uncaught TypeError: Cannot read property 'closingEls' of undefined" Even I'm getting them in my Sentry log, and I don't know how to fix them. I think these errors are from Browser Extensions trying to add their own script. In case of the "Script Error" the extension (or browser) has not allowed you to access the debugging information, while the other extension (or browser) has allowed you to see it.
Most Client JS error tracking ignore "Script Error.". Read here
https://docs.sentry.io/clients/javascript/tips/
http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
Let's hope that this question finds popularity and we find the developer of the extension.

Firefox Javascript console and network tab not showing important errors?

While casually debugging some javascript on a web page, I noticed that Firefox (33.0 - Windows 7) Javascript console would not tell me if some .js files failed to load, so I decided to give this a closer look.
What I found is that if I have an HTML with a script tag pointing to a wrong local url, as the page loads the console shows no errors at all. Instead it shows the full path and file name for the wrong .js script as if there was nothing wrong with it.
I also tried with a button element issuing a xmlhttprequest to a non existing remote url, and same thing, no errors at all in the console when clicking.
$("#button").click(function(){
console.log("clicked me")
$.getJSON("demo_ajax_json.js",function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});
});
while "clicked me" will show as expected.
Also I verified that every possible log setting in developer tools is checked.
After reading that someone had luck with complete settings reset I went through that using Menu > Help > Troubleshooting > Reset Firefox settings. But... no. The errors still don't show up.
So, end of the story, given I just recently decided to look into this, and I can't exactly remember how long I've not been seeing errors exactly, I am questioning myself whether those kind of errors do not shown up at all in Firefox by design and if it's just a prerogative of Chrome... which, it goes by itself, shows all the errors (like for example "net::ERR_FILE_NOT_FOUND").
Anyone for a quick test on their console?
UPDATE, attaching screenshots of both Firefox and Chrome.
As you can see the situation is totally different.
Code:
Firefox Console Tab:
Also no errors on the missing files, whose name is just printed out normally in the console as if nothing was wrong with them.
Firefox Network Tab:
AS OPPOSED TO
Chrome Console Tab:
Chrome Network Tab:
After looking at the screenshots you added, I noticed that you were references resources on your local file system, so I decided to do some tests. I found that Firefox indeed does not report network errors for files on the local filesystem, reporting nothing on the console or the network tab, however it does report them properly for network resources. Unfortunately I could not reproduce the errors in chrome exactly, as my local filesystem is locked down rather tightly (I'm on an enterprise-owned system) and chrome simply reports that it doesn't have permission to access the local filesystem, regardless of whether the file exists or not (Firefox says nothing). Meanwhile, I imagine if you pointed your script/link tags to a network address such as a CDN, or if you are testing on a local test server something like:
http://localhost/[script-address]
it should report the error in both consoles.
Here's my test code:
And the firefox net panel
And the chrome console
Preserving my original answer below this point, as the JQuery API notes may be helpful for others who find themselves here
As mentioned in Ian's comment, and the JQuery API document at http://api.jquery.com/jQuery.getJSON/ JQuery's getJSON method will simply fail silently if you have a syntax error, the URL doesn't exist, or if it doesn't return a response. You can force it to do so by adding a .fail() method call to the end like so:
$("#button").click(function(){
console.log("clicked me")
$.getJSON("demo_ajax_json.js",function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
}).fail(function() {
console.log("AJAX request failed");
});
});
You can also bind a function to the error event by using the .ajaxError method documented here: http://api.jquery.com/ajaxError/
$.ajaxError(function() {
console.log("AJAX request failed.");
});
Note that when you do it this way, JQuery will pass the function several useful parameters if you create variables to hold them, including the error event itself, the ajax object that triggered it, the settings that were used, and the error string, which you can then use to output whatever information you need to the console in order to debug what was causing your error. Good luck!

Mobile Safari 5.0 sending me to about:blank on login/logout

When I log in, log out, or do a post I am getting a "Refused to execute a JavaScript script. Source code of script found within request on a dirt old iPad with mobile safari 5.0. This error is followed by an error from jQuery, "Result of expression 'a' [undefined] is not an object." Upon returning to the original url the page loads as normal.
I found the solution here >> http://bugs.jquery.com/ticket/13546
Looks like it is throwing a xss error incorrectly.

Why do I get no source for error in Firefox

The Firebug console gives me:
------------------------------------------
(X) 0
no source for No element with id 'inline_gallery_image_false' found)
------------------------------------------
When I click this error I get a blank source view window. The 'Stack' pane in the Script tab turns up blank as well.
Firefox 3.5.5 + Firebug 1.4.5. All other extensions are disabled.
I've turned on 'Stop on All Errors' and 'Show Javascript Errors' and 'Show Stack Trace on Errors' but all I get is the error shown above. Strangely a Google search turned up nothing helpful.
Basically I know the error is due to a bad argument passed to a function in an external JS file but I want to know what function called it and how it came to send the wrong argument. I also want to know why it won't show the source or even tell me which file the error is in.
If you know what you do to repeat the error, then just put a breakpoint in that section, and just start to step through. At some point you will be jumped completely out of your code, or it will just exit, but you will begin to figure out what happened to cause the error.
It appears that you are trying to access an element that doesn't exist, or is not in the DOM, yet. You may have tried to create an element with setting innerHTML but you haven't given the browser to make the DOM change yet.
Can you explain what is going on when this happened? What are you trying to do, what do you expect to happen?
I noticed the standard Firefox console gives the same error so this issue is not an issue with Firebug after all. When I click the error to view source I get:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebNavigation.loadURI]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/viewSource.js :: viewSource :: line 221" data: no]
UPDATE: After searching around I found another site with a JS error. Upon opening source view I get a blank page and:
Error: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIRequest.name]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: file:///D:/Apps/Firefox3.5/components/nsLoginManager.js :: anonymous :: line 328" data: no]
Source File: file:///D:/Apps/Firefox3.5/components/nsLoginManager.js
Line: 328
Seems pretty clear some extension or plugin has screwed up my FF source view. I'm going to reinstall from scratch. Since it's clear this isn't a programming issue any more feel free to close.
UPDATE: Turned out it WAS a programming error. The offender was this line of code:
if (isStrict && !o) throw new Error(0,"No element with id '" + ref + "' found");
WTF is that 0 in there? No idea. I must have followed a dodgy tutorial because when I looked into the Error constructor the first argument is supposed to be the message string. The second argument is supposed to be the URL of the offending file (optional) so FF rightly thought there was an error called '0' in the file "No element with ...".

Firefox 'Error loading script' loading Google Analytics in FF2

The project I'm working on uses a window.onerror event handler to report user problems. I've noticed a single user that just cannot seem to load the Google Analytics script. Our site doesn't see a lot of traffic so I'm not sure how widespread this is, but so far it seems to just effect one user.
His user agent is: "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17".
The error message Firefox gives is: "Error loading script".
Additional note: The site references several other javascript files. However, the analytics reference is the only one to an external domain and the only script reference at the bottom of the page, just before the closing body tag.
Has anybody else run across this, or have any idea what could be the issue? Thanks!
This problem occurs when leaving a page in Firefox before all scripts have finished loading. So I assume that it is safe to ignore the error.
You don't see this error in the Firefox error console, but you can make it visible by binding an alert to the window.onerror event. Then you will be able to see the alert box for a small amount of time and get the following error in the error console:
[11:35:57.428] uncaught exception: [Exception... "prompt aborted by user" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource:///components/nsPrompter.js :: openTabPrompt :: line 462" data: no]
I'm using the following check to ignore this error in my onerror handler:
if (navigator.userAgent.search('Firefox') != -1 && message === 'Error loading script') {
// Firefox generates this error when leaving a page before all scripts have finished loading
return;
}
This is a rather random guess, but I wonder if the user is using an add-on like NoScript to control script execution and is not allowing scripts from Google Analytics to run. I know this is possible because it's what I do :) I don't know if that would show up as the error you're seeing.
I have a site with over 80 pages, all that employ JavaScript error trapping. My site serves well over 2000 pages a day and I get about ten "Error loading script" scripting errors each day from Firefox browsers. It is beginning to really annoy me and I am becoming convinced that it is a problem in Firefox.
I can discount the NOSCRIPT suggestion because the script loads in the head of my pages where there are no NOSCRIPT tags.
I can discount the 'external domain' suggestion because I have two sites that suffer this problem and in both cases the JS library files are located on the sites own server.
I have carefully checked every library file and web page using JavaScript Lint and I have discovered scripting errors and questionable scripting techniques. All these problems have been corrected but this has not provided any sort of cure to the "Error loading script" problem.
My pages do load several JavaScript library files that do not have this problem and the only difference is the size of the files. Most of the files are under 5KB but the problem file is 17KB.
Could the size of the library file be the problem?
Aagh!
We had the same issue and after examining our CDN logs, we discovered that Firefox triggers the onerror event when a script returns with HTTP status "304 Not Modified", so a cache hit. In fact, Firefox (tested with Firefox 12 at time of this writing), seems to trigger onerror event for all HTTP statuses except '200 Ok'. Other browsers behaved differently in our experiment: Chrome (19) triggered onerror only on '407 Proxy Authentication Required' and Opera (12) on 100, 101, 204, 4xx and 5xx.
I'm sure this is long resolved.. but to anyone who stumbles across this page: this error is triggered by firefox when an external script fails to load (it's easy to find the code that triggers this in the source code). We were catching these errors on our site and it turned out that we were returning 404s for the script, so I suggest looking at your logs as one possibly source of this error.

Categories