Opened 8 years ago

Closed 4 years ago

#14440 closed defect (fixed)

[regression] "use strict" issue with FireFox and ASP.NET

Reported by: jbest Owned by: Kris Zyp
Priority: blocker Milestone: 1.11
Component: Loader Version: 1.7.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Ticket #12441 talks about adding in "use strict".

A few modules started including this (starting in 1.7?) __doPostBack for ASP.NET throws this error if "use strict" is set:

''"TypeError: access to strict mode caller function is censored"''
(function() {
    "use strict";
    __doPostBack('', '');
})();

Change History (15)

comment:1 Changed 8 years ago by bill

Description: modified (diff)
Summary: "use strict" issue with FireFox and ASP.NET[regression] "use strict" issue with FireFox and ASP.NET

Hmm, that's strange. Most of us don't have ASP.NET, and I don't know what _doPostBack() is or where this error is coming from. Are you saying that something about "use strict" in dojo modules affects the behavior of the client __doPostBack() method which causes the server to throw an error? Even though the "use strict" directives are in dojo code, but the dojo code itself doesn't call __doPostBack()? Can you attach a test case?

comment:2 Changed 8 years ago by jbest

It is part of the ASP.NET ajax script.

Paste of the offending function taken from MicrosoftAjaxWebForms?.js: http://pastebin.com/6kL2Vz2T

comment:3 Changed 8 years ago by bill

OK.

Are you saying that something about "use strict" in dojo modules affects the behavior of the client __doPostBack() method which causes the server to throw an error?

Even though the "use strict" directives are in dojo code, but the dojo code itself doesn't call __doPostBack()?

Can you attach a test case?

comment:4 Changed 8 years ago by jbest

Anything wrapped in the dojo loader:

require([], function() {
    __doPostBack('', '');
});

comment:5 Changed 8 years ago by bill

OK, you'll need to attach a test case using the attach file button, hopefully something that runs without us needing to setup an ASP.NET server.

comment:6 Changed 8 years ago by bill

Milestone: tbd

comment:7 Changed 8 years ago by bill

Owner: set to Kris Zyp

As Colin points out, the issue is that that __doPostBack() function traces up the stack:

while (d.arguments.callee.caller && --j) d = d.arguments.callee.caller;

which is not compatible w/strict mode files.

I think Kris is the one that added those "use strict" directives so assigning to him, although not sure if we want to fix this on dojo's end or not.

comment:8 Changed 8 years ago by Kris Zyp

It seems like if ASP.NET won't work with one of the central new features of ES5, that that is significant issue that ASP.NET needs to address, not us. What is the purpose of doPostBack? Does it do stack traces? Doesn't FF already have good stack traces?

That being said, we certainly could remove them, it certainly shouldn't break anything.

As another possibility, maybe we could optionally strip "use strict" when in sync mode (don't think we could do it in async mode), which would at least give better back-compat?

comment:9 Changed 8 years ago by yousir

I just want to point out that inherited and a few other functions in declare.js also try to access a callee property of an Arguments object:

http://bugs.dojotoolkit.org/browser/dojo/dojo/trunk/_base/declare.js#L100

Strict mode causes this to break as well, of course. Point being, it's not safe to assume foreign code will work properly in strict mode.

comment:10 Changed 8 years ago by Colin Snover

Priority: highblocker

Bulk update of open ticket priorities.

comment:12 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [28769]:

Add a config option to strip strict mode directives, fixes #14440 !strict

comment:13 Changed 7 years ago by Kenneth G. Franqueiro

Resolution: fixed
Status: closedreopened

I get the impression that the code path that was altered in that commit will only apply to the legacy loader? Also, I hope nobody ever writes "use strict" anywhere in actual module code anywhere because I imagine this would end up stripping that just as well...

(To be clear, I'm not sure there'd be any way to perform this stripping in async or cross-domain modes. Seems to me the only clear winner if we want to eliminate barriers to adoption is to eliminate our usage of "use strict".)

Last edited 7 years ago by Kenneth G. Franqueiro (previous) (diff)

comment:14 Changed 7 years ago by Kris Zyp

I had thought this ticket was dealing with regression. I specified in the Dojo config documentation (http://livedocs.dojotoolkit.org/loader/amd#configuration-variables) that this setting only applies to legacy loading.

comment:15 Changed 4 years ago by dylan

Component: GeneralLoader
Milestone: tbd1.11
Resolution: fixed
Status: reopenedclosed

I think this was solved a while ago, if not, please re-open.

Note: See TracTickets for help on using tickets.