Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Restriction Error - Cordova - Windows Phone #825

Closed
DeanB2015 opened this issue Oct 6, 2015 · 2 comments
Closed

Security Restriction Error - Cordova - Windows Phone #825

DeanB2015 opened this issue Oct 6, 2015 · 2 comments
Labels

Comments

@DeanB2015
Copy link

Using SystemJS v0.19.3 for TypeScript + Cordova project. When I run my builds against windows phone 8.1 or windows phone 10 (physical or emulator) I get a JavaScript runtime error: Unable to load dynamic content

Windows security model appears to prevent SystemJS from running. Specifically, the problem is with document.write('<script type="text/javascript" src="'+o+'system-polyfills.js"></script>')

There is a shim created to resolve this problem, but it doesn't fix it.: https://github.com/MsopenTech/winstore-jscompat

@guybedford
Copy link
Member

@DeanB2015 this is the automatic loading SystemJS does when it needs to load the Promise and URL polyfills file at - https://github.com/systemjs/systemjs/blob/master/dist/system-polyfills.js. This is always needed in IE environments including Edge.

If you just include that file with a script tag manually before loading SystemJS it won't make that dynamic request anymore.

@DeanB2015
Copy link
Author

@guybedford Adding <script src="system-polyfills.js"> before <script src="system.js"> fixes the problem. Tested on emulators and Windows 8 & Windows 10 devices.

Thanks for the help!

Added system-polyfills to platformOverrides.js works well too.

(function () {
// Append the safeHTML polyfill
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js');
var scriptElem2 = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/system-polyfills.js');
if (document.body) {
    document.body.appendChild(scriptElem);
    document.body.appendChild(scriptElem2);
} else {
    document.head.appendChild(scriptElem);
    document.head.appendChild(scriptElem2);
}
}());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants