分类:
2010-09-28 11:05:04
Some time ago I have made some application in GWT 2.0, then I have compiled it and wanted to test it under Chrome browser. The effect was suprising.. google product does not work with another google product. … I have got an error message from Chrome Console:
Unsafe JavaScript attempt to access frame with URL file:///C:/workspace/war/Blog_Demonstrations.html from frame with URLfile:///C:/workspace/war/blog_demonstrations/3AA8DD86E4E2DF30F0E5F461485CF698.cache.html. Domains, protocols and ports must match.
followed by:
Uncaught TypeError: Property ‘gwtOnLoad’ of object [object DOMWindow] is not a function
Anyway I have uploaded my application on a web-server and it appeared to work.
Today I had the same problem so I’ve investigated it a little bit more.. What I have found out is : this is Chrome problem (calling it bug may be to harsh). It happens because Chrome has stricter Same-Origin-Policy than another browsers. This policy doesn’t allow web-applications to open (via JavaScirpt) files from the file-system (they apparently are not from the same origin;] ).
Solution for this problem may be sending your static HTML page files to web server. You can even use your local Server (like Jetty).
I am using temporary solution to test my compiled GWT applications under Chrome browser:
0) Launch your project in development mode ( Ctrl+ F11 in Eclipse). ( The point is just to launch the server)
1) In war directory of your application create folder “chrome-test“
2) Compile your GWT project . ( all static output should be created )
3) Copy all output to chrome-test directory. But remember NOT TO copy WEB-INF directory. My war folder after doing this operation looks like this:
What you will see, will be compiled static gwt-page. You can see difference between compiled page and page hosted by server by calling
GWT.isScript()
Method. If it will return true it means that page you are viewing was generated by JavaScript, otherwise what you are looking at was generated by bytecode (so it is hosted java code).
bug trace from chrome dev site: