Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
CB-12193 cordova.js crashes windows app if there is no CoreWindow
Browse files Browse the repository at this point in the history
Also made confighelper to load after WinJS as it depends on it
  • Loading branch information
daserge committed Dec 9, 2016
1 parent 623ff18 commit 707bf96
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
23 changes: 16 additions & 7 deletions cordova-js-src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = {
channel = cordova.require('cordova/channel'),
platform = require('cordova/platform'),
modulemapper = require('cordova/modulemapper'),
configHelper = require('cordova/confighelper'),
utils = require('cordova/utils');

modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
Expand All @@ -41,7 +40,8 @@ module.exports = {

var onWinJSReady = function () {
var app = WinJS.Application,
splashscreen = require('cordova/splashscreen');
splashscreen = require('cordova/splashscreen'),
configHelper = require('cordova/confighelper');

modulemapper.clobbers('cordova/splashscreen', 'navigator.splashscreen');

Expand Down Expand Up @@ -94,13 +94,22 @@ module.exports = {
}));
};

app.addEventListener("checkpoint", checkpointHandler);
app.addEventListener("activated", activationHandler, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
// CB-12193 CoreWindow and some WinRT APIs are not available in webview
var isCoreWindowAvailable = false;
try {
Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
isCoreWindowAvailable = true;
} catch (e) { }

if (isCoreWindowAvailable) {
app.addEventListener("checkpoint", checkpointHandler);
app.addEventListener("activated", activationHandler, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);

injectBackButtonHandler();
injectBackButtonHandler();

app.start();
app.start();
}
};

function appendScript(scriptElem, loadedCb) {
Expand Down
23 changes: 16 additions & 7 deletions template/www/cordova.js
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,6 @@ module.exports = {
channel = cordova.require('cordova/channel'),
platform = require('cordova/platform'),
modulemapper = require('cordova/modulemapper'),
configHelper = require('cordova/confighelper'),
utils = require('cordova/utils');

modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
Expand All @@ -1572,7 +1571,8 @@ module.exports = {

var onWinJSReady = function () {
var app = WinJS.Application,
splashscreen = require('cordova/splashscreen');
splashscreen = require('cordova/splashscreen'),
configHelper = require('cordova/confighelper');

modulemapper.clobbers('cordova/splashscreen', 'navigator.splashscreen');

Expand Down Expand Up @@ -1625,13 +1625,22 @@ module.exports = {
}));
};

app.addEventListener("checkpoint", checkpointHandler);
app.addEventListener("activated", activationHandler, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
// CB-12193 CoreWindow and some WinRT APIs are not available in webview
var isCoreWindowAvailable = false;
try {
Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
isCoreWindowAvailable = true;
} catch (e) { }

if (isCoreWindowAvailable) {
app.addEventListener("checkpoint", checkpointHandler);
app.addEventListener("activated", activationHandler, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);

injectBackButtonHandler();
injectBackButtonHandler();

app.start();
app.start();
}
};

function appendScript(scriptElem, loadedCb) {
Expand Down

0 comments on commit 707bf96

Please sign in to comment.