Skip to content

Commit

Permalink
Use window.alert instead of disabling eslint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Oct 1, 2018
1 parent dc57264 commit 238693b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
iab = cordova.InAppBrowser.open(url, target, params, callbacks);
}
if (!iab) {
alert('open returned ' + iab); // eslint-disable-line no-undef
window.alert('open returned ' + iab);
return;
}

Expand All @@ -196,22 +196,22 @@ exports.defineManualTests = function (contentEl, createActionButton) {
// Verify that event.url gets updated on redirects.
if (e.type === 'loadstart') {
if (e.url === lastLoadStartURL) {
alert('Unexpected: loadstart fired multiple times for the same URL.'); // eslint-disable-line no-undef
window.alert('Unexpected: loadstart fired multiple times for the same URL.');
}
lastLoadStartURL = e.url;
}
// Verify the right number of loadstart events were fired.
if (e.type === 'loadstop' || e.type === 'loaderror') {
if (e.url !== lastLoadStartURL) {
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); // eslint-disable-line no-undef
window.alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
}
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
if (!(e.type === 'loaderror' && counts.loadstart === 0)) {
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); // eslint-disable-line no-undef
window.alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')');
}
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); // eslint-disable-line no-undef
window.alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart);
}
wasReset = true;
numExpectedRedirects = 0;
Expand All @@ -221,9 +221,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
if (e.type === 'exit') {
var numStopEvents = counts.loadstop + counts.loaderror;
if (numStopEvents === 0 && !wasReset) {
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
window.alert('Unexpected: browser closed without a loadstop or loaderror.');
} else if (numStopEvents > 1) {
alert('Unexpected: got multiple loadstop/loaderror events.'); // eslint-disable-line no-undef
window.alert('Unexpected: got multiple loadstop/loaderror events.');
}
}
}
Expand Down Expand Up @@ -252,10 +252,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var iab = doOpen(url, '_blank', 'location=yes');
var callback = function (results) {
if (results && results.length === 0) {
alert('Results verified'); // eslint-disable-line no-undef
window.alert('Results verified');
} else {
console.log(results);
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
window.alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
}
};
if (cssUrl) {
Expand All @@ -276,10 +276,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
iab.addEventListener('loadstop', function (event) {
iab.executeScript({ file: jsUrl }, useCallback && function (results) {
if (results && results.length === 0) {
alert('Results verified'); // eslint-disable-line no-undef
window.alert('Results verified');
} else {
console.log(results);
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
window.alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
}
});
});
Expand All @@ -292,22 +292,22 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'})()';
iab.executeScript({ code: code }, useCallback && function (results) {
if (results && results.length === 1 && results[0] === 'abc') {
alert('Results verified'); // eslint-disable-line no-undef
window.alert('Results verified');
} else {
console.log(results);
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
window.alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results));
}
});
});
}
}
var hiddenwnd = null;
var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef
var loadlistener = function (event) { window.alert('background window loaded '); };
function openHidden (url, startHidden) {
var shopt = (startHidden) ? 'hidden=yes' : '';
hiddenwnd = cordova.InAppBrowser.open(url, 'random_string', shopt);
if (!hiddenwnd) {
alert('cordova.InAppBrowser.open returned ' + hiddenwnd); // eslint-disable-line no-undef
window.alert('cordova.InAppBrowser.open returned ' + hiddenwnd);
return;
}
if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
Expand Down Expand Up @@ -712,14 +712,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
});
ref.addEventListener('customscheme', function (e) {
if (e && e.url === 'custom://test') {
alert('Results verified'); // eslint-disable-line no-undef
window.alert('Results verified');
} else {
alert('Got: ' + e.url); // eslint-disable-line no-undef
window.alert('Got: ' + e.url);
}
ref.close();
});
ref.addEventListener('loaderror', function (e) {
alert('Load error: ' + e.message + '\nYou may need to set the AllowedSchemes preference'); // eslint-disable-line no-undef
window.alert('Load error: ' + e.message + '\nYou may need to set the AllowedSchemes preference');
ref.close();
});
}, 'openCustomscheme');
Expand Down

0 comments on commit 238693b

Please sign in to comment.