chore(lint): update eslint config and apply fixes (#1032)
This commit is contained in:
parent
4b3c0f126d
commit
51959ec268
3974
package-lock.json
generated
3974
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -50,6 +50,6 @@
|
|||||||
"author": "Apache Software Foundation",
|
"author": "Apache Software Foundation",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cordova/eslint-config": "^3.0.0"
|
"@cordova/eslint-config": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,35 +19,35 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var modulemapper = require('cordova/modulemapper');
|
const modulemapper = require('cordova/modulemapper');
|
||||||
|
|
||||||
var browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
let browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
||||||
|
|
||||||
function attachNavigationEvents (element, callback) {
|
function attachNavigationEvents (element, callback) {
|
||||||
var onError = function () {
|
const onError = function () {
|
||||||
try {
|
try {
|
||||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// blocked by CORS :\
|
// blocked by CORS :\
|
||||||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
element.addEventListener('pageshow', function () {
|
element.addEventListener('pageshow', function () {
|
||||||
try {
|
try {
|
||||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// blocked by CORS :\
|
// blocked by CORS :\
|
||||||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
element.addEventListener('load', function () {
|
element.addEventListener('load', function () {
|
||||||
try {
|
try {
|
||||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// blocked by CORS :\
|
// blocked by CORS :\
|
||||||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ function attachNavigationEvents (element, callback) {
|
|||||||
element.addEventListener('abort', onError);
|
element.addEventListener('abort', onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
var IAB = {
|
const IAB = {
|
||||||
close: function (win, lose) {
|
close: function (win, lose) {
|
||||||
if (browserWrap) {
|
if (browserWrap) {
|
||||||
// use the "open" function callback so that the exit event is fired properly
|
// use the "open" function callback so that the exit event is fired properly
|
||||||
@ -74,9 +74,9 @@ var IAB = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
open: function (win, lose, args) {
|
open: function (win, lose, args) {
|
||||||
var strUrl = args[0];
|
const strUrl = args[0];
|
||||||
var target = args[1];
|
const target = args[1];
|
||||||
var features = args[2];
|
const features = args[2];
|
||||||
|
|
||||||
IAB._win = win;
|
IAB._win = win;
|
||||||
|
|
||||||
@ -200,8 +200,8 @@ var IAB = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
injectScriptCode: function (win, fail, args) {
|
injectScriptCode: function (win, fail, args) {
|
||||||
var code = args[0];
|
const code = args[0];
|
||||||
var hasCallback = args[1];
|
const hasCallback = args[1];
|
||||||
|
|
||||||
if (browserWrap && popup) {
|
if (browserWrap && popup) {
|
||||||
try {
|
try {
|
||||||
@ -216,7 +216,7 @@ var IAB = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
injectScriptFile: function (win, fail, args) {
|
injectScriptFile: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
const msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
fail(msg);
|
fail(msg);
|
||||||
@ -224,7 +224,7 @@ var IAB = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
injectStyleCode: function (win, fail, args) {
|
injectStyleCode: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
const msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
fail(msg);
|
fail(msg);
|
||||||
@ -232,7 +232,7 @@ var IAB = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
injectStyleFile: function (win, fail, args) {
|
injectStyleFile: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
const msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
fail(msg);
|
fail(msg);
|
||||||
|
@ -17,5 +17,5 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var d = document.getElementById('header');
|
const d = document.getElementById('header');
|
||||||
d.innerHTML = 'Script file successfully injected';
|
d.innerHTML = 'Script file successfully injected';
|
||||||
|
110
tests/tests.js
110
tests/tests.js
@ -19,15 +19,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var cordova = require('cordova');
|
const cordova = require('cordova');
|
||||||
var isIos = cordova.platformId === 'ios';
|
const isIos = cordova.platformId === 'ios';
|
||||||
var isAndroid = cordova.platformId === 'android';
|
const isAndroid = cordova.platformId === 'android';
|
||||||
var isBrowser = cordova.platformId === 'browser';
|
const isBrowser = cordova.platformId === 'browser';
|
||||||
|
|
||||||
window.alert = window.alert || navigator.notification.alert;
|
window.alert = window.alert || navigator.notification.alert;
|
||||||
|
|
||||||
exports.defineAutoTests = function () {
|
exports.defineAutoTests = function () {
|
||||||
var createTests = function (platformOpts) {
|
const createTests = function (platformOpts) {
|
||||||
platformOpts = platformOpts || '';
|
platformOpts = platformOpts || '';
|
||||||
|
|
||||||
describe('cordova.InAppBrowser', function () {
|
describe('cordova.InAppBrowser', function () {
|
||||||
@ -47,10 +47,10 @@ exports.defineAutoTests = function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iabInstance;
|
let iabInstance;
|
||||||
var originalTimeout;
|
let originalTimeout;
|
||||||
var url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
const url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||||
var badUrl = 'http://bad-uri/';
|
const badUrl = 'http://bad-uri/';
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// increase timeout to ensure test url could be loaded within test time
|
// increase timeout to ensure test url could be loaded within test time
|
||||||
@ -104,7 +104,7 @@ exports.defineAutoTests = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('inappbrowser.spec.4 should support loadstart and loadstop events', function (done) {
|
it('inappbrowser.spec.4 should support loadstart and loadstop events', function (done) {
|
||||||
var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
const onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
||||||
verifyEvent(evt, 'loadstart');
|
verifyEvent(evt, 'loadstart');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -150,8 +150,8 @@ exports.defineAutoTests = function () {
|
|||||||
if (!isAndroid && !isIos) {
|
if (!isAndroid && !isIos) {
|
||||||
return pending(cordova.platformId + " platform doesn't support message event");
|
return pending(cordova.platformId + " platform doesn't support message event");
|
||||||
}
|
}
|
||||||
var messageKey = 'my_message';
|
const messageKey = 'my_message';
|
||||||
var messageValue = 'is_this';
|
const messageValue = 'is_this';
|
||||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||||
iabInstance.addEventListener('message', function (evt) {
|
iabInstance.addEventListener('message', function (evt) {
|
||||||
// Verify message event
|
// Verify message event
|
||||||
@ -163,7 +163,7 @@ exports.defineAutoTests = function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
iabInstance.addEventListener('loadstop', function (evt) {
|
iabInstance.addEventListener('loadstop', function (evt) {
|
||||||
var code =
|
const code =
|
||||||
'(function(){\n' +
|
'(function(){\n' +
|
||||||
' var message = {' +
|
' var message = {' +
|
||||||
messageKey +
|
messageKey +
|
||||||
@ -172,7 +172,7 @@ exports.defineAutoTests = function () {
|
|||||||
'"};\n' +
|
'"};\n' +
|
||||||
' webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));\n' +
|
' webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));\n' +
|
||||||
'})()';
|
'})()';
|
||||||
iabInstance.executeScript({ code: code });
|
iabInstance.executeScript({ code });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -181,17 +181,17 @@ exports.defineAutoTests = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||||
var platformOpts = '';
|
const platformOpts = '';
|
||||||
var platform_info = '';
|
const platform_info = '';
|
||||||
|
|
||||||
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;
|
||||||
console.log('Opening ' + url);
|
console.log('Opening ' + url);
|
||||||
|
|
||||||
var counts;
|
let counts;
|
||||||
var lastLoadStartURL;
|
let lastLoadStartURL;
|
||||||
var wasReset = false;
|
let wasReset = false;
|
||||||
function reset () {
|
function reset () {
|
||||||
counts = {
|
counts = {
|
||||||
loaderror: 0,
|
loaderror: 0,
|
||||||
@ -203,8 +203,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
var iab;
|
let iab;
|
||||||
var callbacks = {
|
const callbacks = {
|
||||||
loaderror: logEvent,
|
loaderror: logEvent,
|
||||||
loadstart: logEvent,
|
loadstart: logEvent,
|
||||||
loadstop: logEvent,
|
loadstop: logEvent,
|
||||||
@ -258,7 +258,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
// Verify that loadend / loaderror was called.
|
// Verify that loadend / loaderror was called.
|
||||||
if (e.type === 'exit') {
|
if (e.type === 'exit') {
|
||||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
const numStopEvents = counts.loadstop + counts.loaderror;
|
||||||
if (numStopEvents === 0 && !wasReset) {
|
if (numStopEvents === 0 && !wasReset) {
|
||||||
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
|
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
|
||||||
} else if (numStopEvents > 1) {
|
} else if (numStopEvents > 1) {
|
||||||
@ -271,8 +271,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||||
var originalFunc = window.open;
|
const originalFunc = window.open;
|
||||||
var wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
const wasClobbered = Object.prototype.hasOwnProperty.call(window, 'open');
|
||||||
window.open = cordova.InAppBrowser.open;
|
window.open = cordova.InAppBrowser.open;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -288,8 +288,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openWithStyle (url, cssUrl, useCallback) {
|
function openWithStyle (url, cssUrl, useCallback) {
|
||||||
var iab = doOpen(url, '_blank', 'location=yes');
|
const iab = doOpen(url, '_blank', 'location=yes');
|
||||||
var callback = function (results) {
|
const callback = function (results) {
|
||||||
if (results && results.length === 0) {
|
if (results && results.length === 0) {
|
||||||
alert('Results verified'); // eslint-disable-line no-undef
|
alert('Results verified'); // eslint-disable-line no-undef
|
||||||
} else {
|
} else {
|
||||||
@ -309,7 +309,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openWithScript (url, jsUrl, useCallback) {
|
function openWithScript (url, jsUrl, useCallback) {
|
||||||
var iab = doOpen(url, '_blank', 'location=yes');
|
const iab = doOpen(url, '_blank', 'location=yes');
|
||||||
if (jsUrl) {
|
if (jsUrl) {
|
||||||
iab.addEventListener('loadstop', function (event) {
|
iab.addEventListener('loadstop', function (event) {
|
||||||
iab.executeScript(
|
iab.executeScript(
|
||||||
@ -327,14 +327,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
iab.addEventListener('loadstop', function (event) {
|
iab.addEventListener('loadstop', function (event) {
|
||||||
var code =
|
const code =
|
||||||
'(function(){\n' +
|
'(function(){\n' +
|
||||||
' var header = document.getElementById("header");\n' +
|
' var header = document.getElementById("header");\n' +
|
||||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||||
' return "abc";\n' +
|
' return "abc";\n' +
|
||||||
'})()';
|
'})()';
|
||||||
iab.executeScript(
|
iab.executeScript(
|
||||||
{ code: code },
|
{ code },
|
||||||
useCallback &&
|
useCallback &&
|
||||||
function (results) {
|
function (results) {
|
||||||
if (results && results.length === 1 && results[0] === 'abc') {
|
if (results && results.length === 1 && results[0] === 'abc') {
|
||||||
@ -348,12 +348,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var hiddenwnd = null;
|
let hiddenwnd = null;
|
||||||
var loadlistener = function (event) {
|
const loadlistener = function (event) {
|
||||||
alert('background window loaded ');
|
alert('background window loaded ');
|
||||||
}; // eslint-disable-line no-undef
|
}; // eslint-disable-line no-undef
|
||||||
function openHidden (url, startHidden) {
|
function openHidden (url, startHidden) {
|
||||||
var shopt = startHidden ? 'hidden=yes' : '';
|
let shopt = startHidden ? 'hidden=yes' : '';
|
||||||
if (platformOpts) {
|
if (platformOpts) {
|
||||||
shopt += (shopt ? ',' : '') + platformOpts;
|
shopt += (shopt ? ',' : '') + platformOpts;
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var info_div =
|
const info_div =
|
||||||
'<h1>InAppBrowser</h1>' +
|
'<h1>InAppBrowser</h1>' +
|
||||||
'<div id="info">' +
|
'<div id="info">' +
|
||||||
'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
|
'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
|
||||||
@ -386,7 +386,7 @@ 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 local_tests =
|
const local_tests =
|
||||||
'<h1>Local URL</h1>' +
|
'<h1>Local URL</h1>' +
|
||||||
'<div id="openLocal"></div>' +
|
'<div id="openLocal"></div>' +
|
||||||
'Expected result: opens successfully in CordovaWebView.' +
|
'Expected result: opens successfully in CordovaWebView.' +
|
||||||
@ -407,7 +407,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
|
'<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser with no locationBar. On iOS the toolbar is at the top.';
|
'Expected result: open successfully in InAppBrowser with no locationBar. On iOS the toolbar is at the top.';
|
||||||
|
|
||||||
var white_listed_tests =
|
const white_listed_tests =
|
||||||
'<h1>White Listed URL</h1>' +
|
'<h1>White Listed URL</h1>' +
|
||||||
'<div id="openWhiteListed"></div>' +
|
'<div id="openWhiteListed"></div>' +
|
||||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
||||||
@ -424,7 +424,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
|
'<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org with no location bar.';
|
'Expected result: open successfully in InAppBrowser to cordova.apache.org with no location bar.';
|
||||||
|
|
||||||
var non_white_listed_tests =
|
const non_white_listed_tests =
|
||||||
'<h1>Non White Listed URL</h1>' +
|
'<h1>Non White Listed URL</h1>' +
|
||||||
'<div id="openNonWhiteListed"></div>' +
|
'<div id="openNonWhiteListed"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||||
@ -441,21 +441,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
|
'<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to apple.com without locationBar.';
|
'Expected result: open successfully in InAppBrowser to apple.com without locationBar.';
|
||||||
|
|
||||||
var page_with_redirects_tests =
|
const page_with_redirects_tests =
|
||||||
'<h1>Page with redirect</h1>' +
|
'<h1>Page with redirect</h1>' +
|
||||||
'<div id="openRedirect301"></div>' +
|
'<div id="openRedirect301"></div>' +
|
||||||
'Expected result: should 301 and open successfully in InAppBrowser to https://www.google.co.uk.' +
|
'Expected result: should 301 and open successfully in InAppBrowser to https://www.google.co.uk.' +
|
||||||
'<p/> <div id="openRedirect302"></div>' +
|
'<p/> <div id="openRedirect302"></div>' +
|
||||||
'Expected result: should 302 and open successfully in InAppBrowser to www.zhihu.com/answer/16714076.';
|
'Expected result: should 302 and open successfully in InAppBrowser to www.zhihu.com/answer/16714076.';
|
||||||
|
|
||||||
var pdf_url_tests =
|
const pdf_url_tests =
|
||||||
'<h1>PDF URL</h1>' +
|
'<h1>PDF URL</h1>' +
|
||||||
'<div id="openPDF"></div>' +
|
'<div id="openPDF"></div>' +
|
||||||
'Expected result: InAppBrowser opens. PDF should render on iOS.' +
|
'Expected result: InAppBrowser opens. PDF should render on iOS.' +
|
||||||
'<p/> <div id="openPDFBlank"></div>' +
|
'<p/> <div id="openPDFBlank"></div>' +
|
||||||
'Expected result: InAppBrowser opens. PDF should render on iOS.';
|
'Expected result: InAppBrowser opens. PDF should render on iOS.';
|
||||||
|
|
||||||
var invalid_url_tests =
|
const invalid_url_tests =
|
||||||
'<h1>Invalid URL</h1>' +
|
'<h1>Invalid URL</h1>' +
|
||||||
'<div id="openInvalidScheme"></div>' +
|
'<div id="openInvalidScheme"></div>' +
|
||||||
'Expected result: fail to load in InAppBrowser.' +
|
'Expected result: fail to load in InAppBrowser.' +
|
||||||
@ -464,7 +464,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/> <div id="openInvalidMissing"></div>' +
|
'<p/> <div id="openInvalidMissing"></div>' +
|
||||||
'Expected result: fail to load in InAppBrowser (404).';
|
'Expected result: fail to load in InAppBrowser (404).';
|
||||||
|
|
||||||
var css_js_injection_tests =
|
const css_js_injection_tests =
|
||||||
'<h1>CSS / JS Injection</h1>' +
|
'<h1>CSS / JS Injection</h1>' +
|
||||||
'<div id="openOriginalDocument"></div>' +
|
'<div id="openOriginalDocument"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser without text "Style updated from..."' +
|
'Expected result: open successfully in InAppBrowser without text "Style updated from..."' +
|
||||||
@ -485,7 +485,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
|
'<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
|
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
|
||||||
|
|
||||||
var open_hidden_tests =
|
const open_hidden_tests =
|
||||||
'<h1>Open Hidden </h1>' +
|
'<h1>Open Hidden </h1>' +
|
||||||
'<div id="openHidden"></div>' +
|
'<div id="openHidden"></div>' +
|
||||||
'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
|
'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
|
||||||
@ -498,14 +498,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<p/> <div id="openVisibleAndHide"></div>' +
|
'<p/> <div id="openVisibleAndHide"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';
|
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';
|
||||||
|
|
||||||
var clearing_cache_tests =
|
const clearing_cache_tests =
|
||||||
'<h1>Clearing Cache</h1>' +
|
'<h1>Clearing Cache</h1>' +
|
||||||
'<div id="openClearCache"></div>' +
|
'<div id="openClearCache"></div>' +
|
||||||
'Expected result: ?' +
|
'Expected result: ?' +
|
||||||
'<p/> <div id="openClearSessionCache"></div>' +
|
'<p/> <div id="openClearSessionCache"></div>' +
|
||||||
'Expected result: ?';
|
'Expected result: ?';
|
||||||
|
|
||||||
var video_tag_tests =
|
const video_tag_tests =
|
||||||
'<h1>Video tag</h1>' +
|
'<h1>Video tag</h1>' +
|
||||||
'<div id="openRemoteVideo"></div>' +
|
'<div id="openRemoteVideo"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||||
@ -514,14 +514,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||||
|
|
||||||
var local_with_anchor_tag_tests =
|
const local_with_anchor_tag_tests =
|
||||||
'<h1>Local with anchor tag</h1>' +
|
'<h1>Local with anchor tag</h1>' +
|
||||||
'<div id="openAnchor1"></div>' +
|
'<div id="openAnchor1"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the top as normal.' +
|
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the top as normal.' +
|
||||||
'<p/> <div id="openAnchor2"></div>' +
|
'<p/> <div id="openAnchor2"></div>' +
|
||||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.';
|
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.';
|
||||||
|
|
||||||
var hardwareback_tests =
|
const hardwareback_tests =
|
||||||
'<h1>HardwareBack</h1>' +
|
'<h1>HardwareBack</h1>' +
|
||||||
'<p/> <div id="openHardwareBackDefault"></div>' +
|
'<p/> <div id="openHardwareBackDefault"></div>' +
|
||||||
'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' +
|
'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||||
@ -551,13 +551,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||||
|
|
||||||
// we are already in cdvtests directory
|
// we are already in cdvtests directory
|
||||||
var basePath = 'iab-resources/';
|
const basePath = 'iab-resources/';
|
||||||
var localhtml = basePath + 'local.html';
|
const localhtml = basePath + 'local.html';
|
||||||
var localpdf = basePath + 'local.pdf';
|
const localpdf = basePath + 'local.pdf';
|
||||||
var injecthtml = basePath + 'inject.html';
|
const injecthtml = basePath + 'inject.html';
|
||||||
var injectjs = 'inject.js';
|
const injectjs = 'inject.js';
|
||||||
var injectcss = 'inject.css';
|
const injectcss = 'inject.css';
|
||||||
var videohtml = basePath + 'video.html';
|
const videohtml = basePath + 'video.html';
|
||||||
|
|
||||||
// Local
|
// Local
|
||||||
createActionButton(
|
createActionButton(
|
||||||
@ -878,7 +878,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
createActionButton(
|
createActionButton(
|
||||||
'google.co.uk shown for 2 seconds than hidden',
|
'google.co.uk shown for 2 seconds than hidden',
|
||||||
function () {
|
function () {
|
||||||
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
const iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
iab.hide();
|
iab.hide();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@ -966,12 +966,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
createActionButton(
|
createActionButton(
|
||||||
'no hardwareback -> hardwareback=no -> no hardwareback',
|
'no hardwareback -> hardwareback=no -> no hardwareback',
|
||||||
function () {
|
function () {
|
||||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
const ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||||
ref.addEventListener('loadstop', function () {
|
ref.addEventListener('loadstop', function () {
|
||||||
ref.close();
|
ref.close();
|
||||||
});
|
});
|
||||||
ref.addEventListener('exit', function () {
|
ref.addEventListener('exit', function () {
|
||||||
var ref2 = cordova.InAppBrowser.open(
|
const ref2 = cordova.InAppBrowser.open(
|
||||||
'https://google.com',
|
'https://google.com',
|
||||||
'_blank',
|
'_blank',
|
||||||
'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : '')
|
'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : '')
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var exec = require('cordova/exec');
|
const exec = require('cordova/exec');
|
||||||
var channel = require('cordova/channel');
|
const channel = require('cordova/channel');
|
||||||
var modulemapper = require('cordova/modulemapper');
|
const modulemapper = require('cordova/modulemapper');
|
||||||
var urlutil = require('cordova/urlutil');
|
const urlutil = require('cordova/urlutil');
|
||||||
|
|
||||||
function InAppBrowser () {
|
function InAppBrowser () {
|
||||||
this.channels = {
|
this.channels = {
|
||||||
@ -100,19 +100,19 @@
|
|||||||
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
|
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||||
if (window.frames && window.frames[strWindowName]) {
|
if (window.frames && window.frames[strWindowName]) {
|
||||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
const origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||||
return origOpenFunc.apply(window, arguments);
|
return origOpenFunc.apply(window, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
strUrl = urlutil.makeAbsolute(strUrl);
|
strUrl = urlutil.makeAbsolute(strUrl);
|
||||||
var iab = new InAppBrowser();
|
const iab = new InAppBrowser();
|
||||||
|
|
||||||
callbacks = callbacks || {};
|
callbacks = callbacks || {};
|
||||||
for (var callbackName in callbacks) {
|
for (const callbackName in callbacks) {
|
||||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cb = function (eventname) {
|
const cb = function (eventname) {
|
||||||
iab._eventHandler(eventname);
|
iab._eventHandler(eventname);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user