Canīt execute MonkeyGame.html

Monkey Targets Forums/HTML5/Canīt execute MonkeyGame.html

Suco-X(Posted 2011) [#1]
Hi,

if I want to execute MonkeyGame.html without monkey, I got this message:

FF:
[Exception... "Security error"  code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)"...


Chrome:
SECURITY_ERR: DOM Exception 18
D:/monkey/modules/mojo/graphics.monkey<448>
....


It appears everytime if I use SetColor.

Mfg Suco


marksibly(Posted 2011) [#2]
Hi,

OK, little crash course on this...

You can't run html5 apps from 'file://' URLs anymore - they MUST be served up by a server of some kind, such as the new built-in mserver. You can use mserver to run the app for you - eg: mserver blah.html - but either way html5 apps now need to run from a 'domain'.

This is because some operations have security restrictions placed on what they're allowed to do. These restrictions are enforced by the browser and differ from browser to browser to a degree, but they are beyond the control of the html5 app.

The most common such security restriction is that a file can only access another file if they both come from the same 'domain' (effectively meaning 'website'). In the case of SetColor, the javascript code must read the image file in order to 'colorize' it, so the 2 files must come from the same domain.

But files served from file:// don't even HAVE a domain (this actually differs a bit from browser to browser, but in general...), so such files aren't allowed to read other files at all. This even includes text files, which is why text files are currently embedded into the main app file.

This is a bit of a hot topic on the web - many people claim it makes html5 unsuitable for shipping standalone apps, and I tend to agree.

But the point of html5 apps is that they are meant to be hosted, and if all these security restrictions make them safer to host (and I don't really know enough to confirm or deny that!) then I think it's for the best.

In summary, I don't recommend 'shipping' HTML5 apps - stick them on a website instead and all these problems go away. MServer is there for debugging/testing apps - and I guess if you *really* need to ship an html5 app, you could ship it with mserver too.


Suco-X(Posted 2011) [#3]
Hi Mark,

thanks for your explanation. Dont wanted to be rude, just forgot this thread.
May you could tell me anything if it possible to use an Apache Server (Local) as HTML_PLAYER. Would be nice to test some php Ajax things easily before going online.

Mfg Suco


muddy_shoes(Posted 2011) [#4]
Aren't you talking about something that is rather specific to your set-up here? I presume you're saying that you have an Apache instance serving a website and you want the Monkey game to be part of that site. If so, this sounds like you either need to get your Apache server to serve the Monkey files from their build directory or you need to copy those files to wherever your site files are.

About the only part of this that seems applicable to a Monkey feature request would be an option to have a post-build step in the IDE in order to script the copy.