Chinaunix首页 | 论坛 | 博客
  • 博客访问: 133521
  • 博文数量: 69
  • 博客积分: 2895
  • 博客等级: 少校
  • 技术积分: 710
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-03 18:05
文章分类

全部博文(69)

文章存档

2010年(69)

我的朋友

分类:

2010-09-28 11:05:04

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 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.

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

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

Links

bug trace from chrome dev site: 

阅读(1694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~