Loading text files with requires.js fails in Firefox: “AccessControlException” #13

Closed
ghost23 opened this Issue Aug 9, 2012 · 10 comments

Projects

None yet

3 participants

@ghost23

Hello,

i have also have a question on stackoverflow running regarding my issue:
http://stackoverflow.com/questions/11881411/loading-text-files-with-requires-js-fails-in-firefox-accesscontrolexception

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?

@jrburke
requirejs member

Can you confirm what version of text.js you are using? The version should be in the file.

At first read, it looks like it may be trying to use the java route, maybe mistaking the env for rhino. I did a change related to that in text.js 2.0.2. If the version you are using is 2.0.2, do you mind trying it with text.js 2.0.1?

https://raw.github.com/requirejs/text/2.0.1/text.js

If the error only happens with 2.0.2, then it sounds like the java/rhino detection is messing things up.

@ghost23

I am using 2.0.2. Will check again with 2.0.1, just a sec.

@ghost23

Indeed, switching to 2.0.1 fixes the issue.

@hoatle

I've got the same problem with text 2.0.2 under Firefox 14.0.1 on Mac. The same version on Windows is ok, every other browsers are ok, too.

I debugged this line with firebug:

  } else if (typeof Packages !== 'undefined' && typeof java !== 'undefined') {
    //Why Java, why is this so awkward?

console: Packages and java => return undefined.

However, console: typeof Packages and typeof java => return "function".

This is weird. And finally, this is the error on the console:

uncaught exception: java.security.AccessControlException: access denied (java.io.FilePermission

Sticking with text 2.0.1 is ok.

@jrburke
requirejs member

I do not see this problem on Firefox Beta channel (version 15) or Aurora, on Mac, so it is a bit hard for me to test at the moment, and I'm on a limited connection, cannot download 14.

@hoatle can you confirm if the following check would return false for 14, and if so, then I'll update the check to this:

typeof Packages !== 'undefined' && typeof java !== 'undefined' && Packages && java
@hoatle

@jrburke I applied this new check, however, it still returns true and the problem remains.

@jrburke jrburke added a commit that referenced this issue Aug 12, 2012
@jrburke jrburke Relates to #13, roll back the change to #11, but introduce a config.e…
…nv override to help address #11.
6485a2c
@jrburke
requirejs member

I just rolled back the change for #11, you can try the latest master:

https://raw.github.com/requirejs/text/master/text.js

I also introduced a "env" config override to try to help the case for #11:

https://github.com/requirejs/text#forcing-the-environment-implemention

If one of you can confirm this new one works now, then I'll push out a 2.0.3 change with this fix.

@hoatle

Hi @jrburke, I confirm that it works now. Thanks!

@jrburke
requirejs member

OK, just pushed a 2.0.3 release with this change:

https://github.com/requirejs/text/blob/latest/text.js

@jrburke jrburke closed this Aug 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment