polymer-dart
polymer-dart copied to clipboard
Polymer.dart chrome packages app empty inline-script csp issue
<img src="https://avatars.githubusercontent.com/u/6412650?v=3" align="left" width="96" height="96"hspace="10"> Issue by bergold Originally opened as dart-lang/sdk#21213
What steps will reproduce the problem?
1. Create a new project and add chrome and polymer as dependencies. 2. Create a custom element and import 'package/polymer/polymer.html'. 3. Use this element somewhere. 4. Build the app with 'pub build' and the chrome, polymer and dart2js transformer with csp=true set.
What is the expected output? What do you see instead?
Refused to execute inline script because it violates the following Content Security Policy directive... This error is thrown because of an empty script tag in 'package/polymer/polymer.html'
12. <link rel="import" href="src/js/polymer/polymer.html"> 13. <script> 14. // TODO(sigmund): remove this script tag (dartbug.com/19650). This empty 15. // script tag is necessary to work around a bug in Chrome 36. 16. </script>
- Dart SDK version: 1.6.0
- polymer package version: 0.15.0
- Operating system: Windows 7
- Browser (if any): Chrome Canary 40.0.2175.0
<img src="https://avatars.githubusercontent.com/u/2049220?v=3" align="left" width="48" height="48"hspace="10"> Comment by sigmundch
When you say "with csp=true set" did you mean just dart2js or also the polymer transformer? What does your pubspec look like?
I just tried this locally and wasn't able to reproduce it. For me, the polymer transformer moves the inline script code to a separate file when I write:
transformers:
-
polymer: entry_point: web/index.html csp: true
-
$dart2js: csp: true
Added NeedsInfo label.
This comment was originally written by [email protected]
I have the same problem with chrome dev editor. I have set all the transformers. Any help will be appreciated.
This comment was originally written by [email protected]
I solved the issue with chrome dev editor. There is a menu option to refactor code for CSP.
This comment was originally written by [email protected]
The Chrome Dev Editor has other problems. Its not recognizing files in folders and not compiling them. So, there is still an issue. Meanwhile, Dart editor does not even compile to a CSP safe file.