Fix tests so they auto-start when run via cordova-paramedic

This commit is contained in:
Dave Alden 2018-10-05 21:23:56 +01:00
parent cbfa195f7d
commit 86cc778c4a

View File

@ -19,7 +19,7 @@
* *
*/ */
/* global MSApp, alert */ /* global MSApp */
var cordova = require('cordova'); var cordova = require('cordova');
var isWindows = cordova.platformId === 'windows'; var isWindows = cordova.platformId === 'windows';
@ -33,7 +33,6 @@ if (isWindows && navigator && navigator.notification && navigator.notification.a
} }
exports.defineAutoTests = function () { exports.defineAutoTests = function () {
var createTests = function (platformOpts) { var createTests = function (platformOpts) {
platformOpts = platformOpts || ''; platformOpts = platformOpts || '';
@ -154,7 +153,6 @@ exports.defineAutoTests = function () {
}); });
}); });
}; };
if (isIos) { if (isIos) {
createTests('usewkwebview=no'); createTests('usewkwebview=no');
createTests('usewkwebview=yes'); createTests('usewkwebview=yes');
@ -165,6 +163,15 @@ exports.defineAutoTests = function () {
exports.defineManualTests = function (contentEl, createActionButton) { exports.defineManualTests = function (contentEl, createActionButton) {
var platformOpts = '';
var platform_info = '';
if (isIos) {
platformOpts = 'usewkwebview=no';
platform_info = '<h1>Webview</h1>' +
'<p>Use this button to toggle the Webview implementation.</p>' +
'<div id="webviewToggle"></div>';
}
function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) { function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) {
numExpectedRedirects = numExpectedRedirects || 0; numExpectedRedirects = numExpectedRedirects || 0;
useWindowOpen = useWindowOpen || false; useWindowOpen = useWindowOpen || false;
@ -173,7 +180,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var counts; var counts;
var lastLoadStartURL; var lastLoadStartURL;
var wasReset = false; var wasReset = false;
function reset () { function reset () {
counts = { counts = {
'loaderror': 0, 'loaderror': 0,
@ -183,7 +189,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
}; };
lastLoadStartURL = ''; lastLoadStartURL = '';
} }
reset(); reset();
var iab; var iab;
@ -318,11 +323,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
}); });
} }
} }
var hiddenwnd = null; var hiddenwnd = null;
var loadlistener = function (event) { var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef
alert('background window loaded ');
}; // eslint-disable-line no-undef
function openHidden (url, startHidden) { function openHidden (url, startHidden) {
var shopt = (startHidden) ? 'hidden=yes' : ''; var shopt = (startHidden) ? 'hidden=yes' : '';
if (platformOpts) { if (platformOpts) {
@ -335,13 +337,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
} }
if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener); if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
} }
function showHidden () { function showHidden () {
if (hiddenwnd) { if (hiddenwnd) {
hiddenwnd.show(); hiddenwnd.show();
} }
} }
function closeHidden () { function closeHidden () {
if (hiddenwnd) { if (hiddenwnd) {
hiddenwnd.removeEventListener('loadstop', loadlistener); hiddenwnd.removeEventListener('loadstop', loadlistener);
@ -358,15 +358,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'<h4>User-Agent: <span id="user-agent"> </span></hr>' + '<h4>User-Agent: <span id="user-agent"> </span></hr>' +
'</div>'; '</div>';
var platformOpts = '';
var platform_info = '';
if (isIos) {
platformOpts = 'usewkwebview=no';
platform_info = '<h1>Webview</h1>' +
'<p>Use this button to toggle the Webview implementation.</p>' +
'<div id="webviewToggle"></div>';
}
var local_tests = '<h1>Local URL</h1>' + var local_tests = '<h1>Local URL</h1>' +
'<div id="openLocal"></div>' + '<div id="openLocal"></div>' +
'Expected result: opens successfully in CordovaWebView.' + 'Expected result: opens successfully in CordovaWebView.' +
@ -523,13 +514,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js'; var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js';
var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css'; var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css';
var videohtml = basePath + 'video.html'; var videohtml = basePath + 'video.html';
if (isIos) { if (isIos) {
createActionButton('Webview=UIWebView', function () { createActionButton('Webview=UIWebView', function () {
var webviewOption = 'usewkwebview='; var webviewOption = 'usewkwebview=';
var webviewToggle = document.getElementById('webviewToggle'); var webviewToggle = document.getElementById('webviewToggle');
var button = webviewToggle.getElementsByClassName('topcoat-button')[0]; var button = webviewToggle.getElementsByClassName('topcoat-button')[0];
if (platformOpts === webviewOption + 'yes') { if (platformOpts === webviewOption + 'yes') {
platformOpts = webviewOption + 'no'; platformOpts = webviewOption + 'no';
button.textContent = 'Webview=UIWebView'; button.textContent = 'Webview=UIWebView';