You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Jerroyd Moore (JIRA)" <ji...@apache.org> on 2016/10/05 00:17:20 UTC

[jira] [Commented] (CB-11606) Cordova.js not including the WinJS Base.js file correctly

    [ https://issues.apache.org/jira/browse/CB-11606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15547151#comment-15547151 ] 

Jerroyd Moore commented on CB-11606:
------------------------------------

Microsoft contacted our team about our Cordova app was crashing due to the WinJS UI library not being added correctly. Upon further testing, we discovered only Windows 10 Anniversary Update (v1607) was affected. Running the application on Windows 10 RTM (v1511) was unaffected.

Our fix was to refactor code sitting in a ___ into an event listener that waited for WinJS UI library to be added.

{code}
(function () {
    var onWinJSReady = function() {
        // add initialization code here...
    };
    // **************************************************************************
    // Add ui.js & ui.css for AppBar support in WinJS.
    if (!window.WinJS || !WinJS.UI.AppBarCommand) {
        var style = document.createElement('link');
        style.type = "text/css";
        style.rel = "stylesheet";
        var scriptElem = document.createElement("script");
        if (navigator.appVersion.indexOf("Windows Phone 10") !== -1) {
            // windows phone 10 + Mobile IE 11
            scriptElem.src = "/plugins/com.intel.app-preview.preview/WinJS/js/ui.js";
            style.href = "/plugins/com.intel.app-preview.preview/WinJS/css/ui-dark.css";
        } else if (navigator.appVersion.indexOf('MSAppHost/3.0') !== -1) {
            // Windows 10 UWP
            scriptElem.src = "/plugins/com.intel.app-preview.preview/WinJS/js/ui.js";
            style.href = "/plugins/com.intel.app-preview.preview/WinJS/css/ui-dark.css";
        } else if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
            // windows phone 8.1 + Mobile IE 11
            scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/ui.js";
            style.href = "//Microsoft.Phone.WinJS.2.1/css/ui-dark.css";
        } else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
            // windows 8.1 + IE 11
            scriptElem.src = "//Microsoft.WinJS.2.0/js/ui.js";
            style.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";
        } else {
            // windows 8.0 + IE 10
            scriptElem.src = "//Microsoft.WinJS.1.0/js/ui.js";
            style.href = "//Microsoft.WinJS.1.0/css/ui-dark.css";
        }
        scriptElem.addEventListener("load", onWinJSReady);
        document.head.appendChild(scriptElem);
        document.head.appendChild(style);
    }
    // **************************************************************************
})();
{code}

> Cordova.js not including the WinJS Base.js file correctly
> ---------------------------------------------------------
>
>                 Key: CB-11606
>                 URL: https://issues.apache.org/jira/browse/CB-11606
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, Windows
>            Reporter: linda zhong
>            Priority: Minor
>
> If I remote debug to x64 the app side loads through the debugger. I can click around, do everything, no problem.
> BUT once I disconnect the debug process, and then start the app on the surface, it flashes open, then closes... the error from that closing seems to be related to Windows not being defined( i assume from the base) and then creating DB connections off of that.
> I thought maybe it was a change in the debugging setup, so I went through the whole process of side loading it, and the same thing happens. 
> I traced it down to Cordova not including the Base.js file correctly, there seem to be pathing issues, but only when i run it on the surface, without the debugger... so I'm confused.
> Of course, since i side loaded it onto the x64 surface, I thought, I could sideload the app onto the Surface RT, which i did, and guess what, it works fine there. 
> So why would the same app, side loaded on RT work, but not on x64.
> Is there something different in the Base file its trying to use, maybe it exists for one but not the other?
> If I run the index.html in chrome, i can see more errors, so debugging with that I see a few more things.
> Here is the code in the cordova.js file thats messing up the include (line 1449 in the cordova js i have)
> {noformat}
>     if (!window.WinJS) {
>             var scriptElem = document.createElement("script");
>             if (navigator.appVersion.indexOf('MSAppHost/3.0') !== -1) {
>                 // Windows 10 UWP
>                 scriptElem.src = '/www/WinJS/js/base.js';
>             } else if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
>                 // windows phone 8.1 + Mobile IE 11
>                 scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
>             } else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
>                 // windows 8.1 + IE 11
>                 scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
>             } else {
>                 // windows 8.0 + IE 10
>                 scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
>             }
>             scriptElem.addEventListener("load", onWinJSReady);
>             document.head.appendChild(scriptElem);
>         }
> {noformat}
> The x64 is firing this include - the else
>   scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
> When I inspect it loading locally on my machine, its using
> <script src="//Microsoft.WinJS.2.0/js/base.js"></script>
> If i hard code a script tag to the WinJS/js/base.js that error goes away from the console, but then i am still seeing the error for Windows. is not defined.
> Now, with the base.js fixed, its not showing errors in the windows events log, but its still crashing on start up.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org