Closed
Bug 1218134
Opened 11 years ago
Closed 11 years ago
Accessing undefined doesn't throw
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: ZeroUnderscoreOu, Unassigned)
Details
Attachments
(1 file)
|
783.17 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0
Build ID: 20151014143721
Steps to reproduce:
I'm not sure it's an FF's bug, but I think it is, since JS is interpreted by browser and browser should return all errors.
Usually FF reports all improper access attempts, like of undefined variable or method. But sometimes, if it's buried deep enough, FF just swallows an error and it becomes hard enough to figure out where exactly it aborted.
In the example I used AJAX, because it was easiest for me to reproduce:
new Ajax.Request("https://bugzilla.mozilla.org",{
method: "get",
onSuccess: function(Data) {
console.log("Before");
undefined.AbsentProperty;
console.log("After");
}
});
Actual results:
Execution aborts after first log, without any error messages.
Expected results:
After first log, standart "TypeError: undefined has no properties" should be returned.
| Reporter | ||
Comment 1•11 years ago
|
||
Opera & Chrome don't throw either, so it might actually be related to AJAX's architecture, but I'm mot sure, so it's probably better to report then not.
Comment 2•11 years ago
|
||
onSuccess doesn't run for that snippet in comment 0 because the resource is protected by same-origin policy (your code likely is cross-origin). To enable the access, the server does have to enable it using CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
For an url which is allowed to access, e.g. function reqListener () {
console.log("Before");
undefined.AbsentProperty;
console.log("After");
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://bugzilla.mozilla.org//rest/bug/1157897/history?new_since=2015-09-29");
oReq.send();
I see the first log and
TypeError: undefined has no properties
in the console.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Resolution: --- → WORKSFORME
Summary: Accessing undefined doen't throw → Accessing undefined doesn't throw
| Reporter | ||
Comment 3•11 years ago
|
||
| Reporter | ||
Comment 4•11 years ago
|
||
OK, I probably should've checked it again before posting instead of simply changing the link.
Originally I checked it on SteamCommunity.com.
I attached a screenshot of how it runs for me, on http://steamcommunity.com/ itself to prevent CORS problems. The page already has AJAX, so you don't need to load it from elsewhere. No error message.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Comment 5•11 years ago
|
||
That page's prototype-1.7.js has the following code:
> try {
> this._complete = true;
> (this.options['on' + response.status]
> || this.options['on' + (this.success() ? 'Success' : 'Failure')]
> || Prototype.emptyFunction)(response, response.headerJSON);
> } catch (e) {
> this.dispatchException(e);
> }
So the exception gets managed and not thrown.
Please provide a reduced test case without external dependencies and which can reproduce the issue. Thank you.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago → 11 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•