GWT Packaged App errors

1,017 views
Skip to first unread message

Vishal Singh

unread,
Jul 11, 2012, 3:57:14 PM7/11/12
to chromi...@chromium.org
I am trying to create a GWT packaged app. I created a simple GWT application, which shows a button.
On running the application as a packaged app I am getting the following errors which I can see by inspecting

Uncaught document.write() is not available in packaged apps.
Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:".

What am I doing wrong ?




manifest.json
------------------------
{
  "name": "Hello World!",
  "description": "My first packaged app.",
  "manifest_version": 2,
  "version": "0.1",
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "permissions": ["experimental", "appWindow"],
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

------------------

chrome.experimental.app.onLaunched.addListener(function() {
  chrome.appWindow.create('LocalWebApp.html', {
    'width': 400,
    'height': 500
  });
});





Paul Kinlan

unread,
Jul 11, 2012, 4:06:42 PM7/11/12
to Vishal Singh, chromi...@chromium.org
New Packaged apps, specifically those with manifest_version:2 are not able to use document.write directly or load scripts in between script elements.

You can use the sandbox where all these features are enabled, so check out http://developer.chrome.com/trunk/apps/app_external.html#external

P


--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-apps/-/7VnXPHoeRGsJ.
To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.



--
Paul Kinlan
Developer Advocate @ Google for Chrome and HTML5
Skype: paul.kinlan

Vishal Singh

unread,
Jul 12, 2012, 8:37:42 AM7/12/12
to chromi...@chromium.org
Thanks for the help Paul. I have sandboxed all the GWT generated files.

 "sandbox": {
  "pages": ["LocalWebApp.html",
  "localwebapp/1BB99A3D08C87C45637BBB49C33972DD.cache.html",
  "localwebapp/224DB061DE2E651F5E214936A979AAF1.cache.html",
  "localwebapp/76F2766D4527FFDD118CC749CEFB9C73.cache.html",
  "localwebapp/EB53C46D3172A1A03E5343FBAFCC31F5.cache.html",
  "localwebapp/F835CA016A98AA5A6E4A7BE26497B885.cache.html",
  "localwebapp/FA0F6F702D3923A937014A27583C7536.cache.html",
  "localwebapp/localwebapp.nocache.js"
 
  ]

I am still getting errors. These are different from what I was getting. As I understand this has to do with XSS but all my files are local and I am not accessing any external site.




Uncaught document.write() is not available in packaged apps. platformApp:12
Message has been deleted

Julien Alary

unread,
Sep 24, 2012, 2:02:38 PM9/24/12
to chromi...@chromium.org
Did you find any solution for this problem as I have exactly the same error message?

Thks a lot guys.

Unsafe JavaScript attempt to access frame with URL chrome-extension://elddkhppippclbfjbfljndcjpckgljco/module/background/sandboxed.html from frame with URL chrome-extension://elddkhppippclbfjbfljndcjpckgljco/module/background/DCE24DB153A80B735442BF97F168AE6C.cache.html. Domains, protocols and ports must match. 

Paul Kinlan

unread,
Sep 24, 2012, 5:48:43 PM9/24/12
to Julien Alary, Chromium Apps
Hi,

Can you send me your zip file with the assets and I will check first thing tomorrow.

P


--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.

To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.

Michael Prentice

unread,
May 12, 2013, 9:59:00 AM5/12/13
to chromi...@chromium.org, Julien Alary
Where do you learn how to even get started creating packaged apps (manifest version 2) with GWT?

Michael Prentice

unread,
May 13, 2013, 1:23:29 AM5/13/13
to chromi...@chromium.org, Julien Alary
I spent quite a while trying to get this to work tonight, but I'm getting the same errors that others posted here:

Uncaught document.write() is not available in packaged apps. platformApp:14

In trying to adjust the permissions, I'm getting the following errors from the Chrome Extensions page:

There were warnings when trying to install this extension:
  • 'content_security_policy' is only allowed for extensions and legacy packaged apps, and this is a packaged app.
  • 'background' is only allowed for extensions, hosted apps and legacy packaged apps, and this is a packaged app.
  • 'declarativeWebRequest' is only allowed for extensions and legacy packaged apps, and this is a packaged app.
  • 'history' is only allowed for extensions and legacy packaged apps, and this is a packaged app.
  • 'webRequest' is only allowed for extensions and legacy packaged apps, and this is a packaged app.

Here is my manifest.json:

{
  "name": "Gwt Offline Chrome App",
  "version": "1.0",
  "manifest_version": 2,
  "description": "An offline Chrome App created by GWT.",
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" },
   "offline_enabled": true,
   "permissions": ["experimental", 
    "webRequest",
   "declarativeWebRequest",
   "<all_urls>",
   "history",
   "background",
   "storage",
   "clipboardWrite"],
   "sandbox": {
     "pages": ["GwtWebApp.html",
    "gwtwebapp/gwtwebapp.nocache.js"  
           ]
   },
   "content_security_policy": "script-src 'unsafe-eval' chrome-extension:// chrome-extension-resource:// https://*.google.com https://splaktar-gwtwebapp.appspot.com https://ssl.google-analytics.com https://*.googleapis.com https://*.googleusercontent.com 'self'; object-src chrome-extension:// chrome-extension-resource:// 'self'; frame-src https://apis.google.com https://www.google.com https://docs.google.com https://www.googleapis.com https://accounts.google.com chrome-extension:// chrome-extension-resource:// https://plusone.google.com https://*.googleusercontent.com 'self'"
}

I've taken some of this from the following references:



I did previous tests with a lot less permissions and the default CSP, but got the same results.

Michael Prentice

unread,
May 13, 2013, 11:28:54 PM5/13/13
to chromi...@chromium.org, Julien Alary
The following:

  "app": {
    "launch": {
      "local_path" : "GwtChromeApp.html"
    }
  },

Instead of :

"app": {
    "background": {
      "scripts": ["background.js"]
    }
  },

Gets my app to install and run JavaScript fine in Chrome. Is this still a v2 Packaged App or is it an Extension when I do this?!


Changing to the following manifest, gets Chrome to load my app without any errors except that my JavaScript does not run due to the same old error:

Uncaught document.write() is not available in packaged apps. platformApp:14

{
  "name": "Gwt Chrome App",
  "version": "1.0",
  "manifest_version": 2,
  "description": "An Chrome App created by GWT.",
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" },
   "offline_enabled": true,
   "permissions": [ "experimental", 
   "<all_urls>",
   "storage",
   "clipboardWrite"],
   "sandbox": {
     "pages": [ "gwtchromeapp/gwtchromeapp.nocache.js" ]
   }
}

The REST client example that I was given is listed in the Chrome Web Store as an App and not an Extension. So perhaps app launch is the way to go rather than app background.

Renato Mangini

unread,
May 14, 2013, 5:46:00 PM5/14/13
to Michael Prentice, Chromium Apps, Julien Alary

app.launch.local_path describes the old, now deprecated packaged apps. Please, don't use it. You should use the app.background.scripts.

document.write() is not allowed in the new packaged apps. If GWT is generating code that uses that, it won't work unless you run this CSP-offending code in a sandboxed iframe.


Please, report your findings back here. We should add a GWT sample to the samples repo.


Renato Mangini | Chrome Developer Programs Engineer | man...@google.com | +55 11 2395-8608


To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.

To post to this group, send email to chromi...@chromium.org.

Michael Prentice

unread,
May 15, 2013, 4:33:22 PM5/15/13
to chromi...@chromium.org, Michael Prentice, Julien Alary
OK, here are the results when I do that:

Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback. about:blank:1
Uncaught document.open() is not available in packaged apps. platformApp:14


This is with using the DirectInstallLinker in GWT.

  <define-linker name="dil" class="com.google.gwt.core.linker.DirectInstallLinker"/>
  <set-property name="user.agent" value="safari"/>
  <add-linker name="dil"/>

Here is my manifest.json:

{
  "name": "Gwt Chrome App",
  "version": "1.0",
  "manifest_version": 2,
  "description": "A Chrome App created by GWT.",
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" },
   "offline_enabled": true,
   "<all_urls>",
   "storage",
   "clipboardWrite"],
   "sandbox": {
     "pages": [ "gwtchromeapp/gwtchromeapp.nocache.js" ]
   }
}

If I do the following to sandbox my main app page, I get a lot more errors:

"sandbox": {
     "pages": [ "GwtChromeApp.html",
     "gwtchromeapp/gwtchromeapp.nocache.js" ]
   }

Sandbox access violation: Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL chrome-extension://ajejpmngddoppjjecgdcggmljcfjpaep/GwtChromeApp.html. Both frames are sandboxed into unique origins.
Uncaught TypeError: Cannot call method 'open' of undefined gwtchromeapp.nocache.js:5

From the background page:

Uncaught TypeError: Cannot call method 'initializeAppWindow' of undefined app.window:43

Please let me know if I am doing something wrong here. All of the GWT examples that I have been given are for v1 packaged apps, legacy packaged apps, or extensions.

Thank you!
Reply all
Reply to author
Forward
0 new messages