GWT 2.0 + chrome = Unsafe JavaScript attempt to access frame with URL …

Problem description

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 URL file:///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.

Why there is an error

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;] ).

Workaround solution    for testing your application on local enviroment

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 Launch your project in development mode ( Ctrl+ F11 in Eclipse). ( The point is just to launch the server)

1)  add folder In war directory of your application create folder “chrome-test

2) gwt icon Compile your GWT project . ( all static output should be created )

3) copy 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:war directory

4) go to web site go to

What you will see, will be compiled static gwt-page.  You can see difference between compiled page and page hosted by server by calling


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:


3 Responses to GWT 2.0 + chrome = Unsafe JavaScript attempt to access frame with URL …

  1. Rohan says:

    Nice workaround.
    But is there any workaround to run local copy without starting the server in development mode. My application is running fine on Mozilla and IE without starting the server. (just open the .html file).

  2. fuckoff says:

    Yeah this is so rediculous – Chrome allows me to send XHR requests to any domain from extension code, yet disallows my extension to access iframe content from another domain. IMHO these “security rules” are made by complete idiots

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: