CB-10636 Add JSHint for plugins
This commit is contained in:
parent
555d55ac8a
commit
ea1253963b
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@ Thumbs.db
|
|||||||
*.swp
|
*.swp
|
||||||
*.user
|
*.user
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
16
.jshintrc
Normal file
16
.jshintrc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"browser": true
|
||||||
|
, "devel": true
|
||||||
|
, "bitwise": true
|
||||||
|
, "undef": true
|
||||||
|
, "trailing": true
|
||||||
|
, "quotmark": false
|
||||||
|
, "indent": 4
|
||||||
|
, "unused": "vars"
|
||||||
|
, "latedef": "nofunc"
|
||||||
|
, "globals": {
|
||||||
|
"module": false,
|
||||||
|
"exports": false,
|
||||||
|
"require": false
|
||||||
|
}
|
||||||
|
}
|
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
language: node_js
|
||||||
|
sudo: false
|
||||||
|
node_js:
|
||||||
|
- "4.2"
|
@ -17,6 +17,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)
|
||||||
|
|
||||||
# cordova-plugin-inappbrowser
|
# cordova-plugin-inappbrowser
|
||||||
|
|
||||||
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
||||||
|
@ -37,6 +37,10 @@
|
|||||||
"cordova-windows",
|
"cordova-windows",
|
||||||
"cordova-firefoxos"
|
"cordova-firefoxos"
|
||||||
],
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "npm run jshint",
|
||||||
|
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
|
||||||
|
},
|
||||||
"engines": [
|
"engines": [
|
||||||
{
|
{
|
||||||
"name": "cordova",
|
"name": "cordova",
|
||||||
@ -44,5 +48,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"author": "Apache Software Foundation",
|
"author": "Apache Software Foundation",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"jshint": "^2.6.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
var modulemapper = require('cordova/modulemapper');
|
||||||
channel = require('cordova/channel'),
|
|
||||||
modulemapper = require('cordova/modulemapper'),
|
|
||||||
urlutil = require('cordova/urlutil');
|
|
||||||
|
|
||||||
var browserWrap,
|
var browserWrap,
|
||||||
popup,
|
popup,
|
||||||
@ -69,8 +66,7 @@ var IAB = {
|
|||||||
open: function (win, lose, args) {
|
open: function (win, lose, args) {
|
||||||
var strUrl = args[0],
|
var strUrl = args[0],
|
||||||
target = args[1],
|
target = args[1],
|
||||||
features = args[2],
|
features = args[2];
|
||||||
url;
|
|
||||||
|
|
||||||
if (target === "_self" || !target) {
|
if (target === "_self" || !target) {
|
||||||
window.location = strUrl;
|
window.location = strUrl;
|
||||||
@ -193,7 +189,9 @@ var IAB = {
|
|||||||
if (browserWrap && popup) {
|
if (browserWrap && popup) {
|
||||||
try {
|
try {
|
||||||
popup.contentWindow.eval(code);
|
popup.contentWindow.eval(code);
|
||||||
hasCallback && win([]);
|
if (hasCallback) {
|
||||||
|
win([]);
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||||
}
|
}
|
||||||
@ -203,19 +201,25 @@ var IAB = {
|
|||||||
injectScriptFile: function (win, fail, args) {
|
injectScriptFile: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
fail && fail(msg);
|
if (fail) {
|
||||||
|
fail(msg);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
injectStyleCode: function (win, fail, args) {
|
injectStyleCode: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
fail && fail(msg);
|
if (fail) {
|
||||||
|
fail(msg);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
injectStyleFile: function (win, fail, args) {
|
injectStyleFile: function (win, fail, args) {
|
||||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
fail && fail(msg);
|
if (fail) {
|
||||||
|
fail(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/WebAPI/Browser
|
// https://developer.mozilla.org/en-US/docs/WebAPI/Browser
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
var modulemapper = require('cordova/modulemapper');
|
||||||
channel = require('cordova/channel'),
|
|
||||||
modulemapper = require('cordova/modulemapper');
|
|
||||||
|
|
||||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
|
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
|
||||||
var browserWrap;
|
var browserWrap;
|
||||||
@ -49,9 +47,7 @@ var IABExecs = {
|
|||||||
var strUrl = args[0],
|
var strUrl = args[0],
|
||||||
target = args[1],
|
target = args[1],
|
||||||
features_string = args[2] || "location=yes", //location=yes is default
|
features_string = args[2] || "location=yes", //location=yes is default
|
||||||
features = {},
|
features = {};
|
||||||
url,
|
|
||||||
elem;
|
|
||||||
|
|
||||||
var features_list = features_string.split(',');
|
var features_list = features_string.split(',');
|
||||||
features_list.forEach(function(feature) {
|
features_list.forEach(function(feature) {
|
||||||
@ -115,7 +111,7 @@ var IABExecs = {
|
|||||||
back.classList.add('inAppBrowserBack');
|
back.classList.add('inAppBrowserBack');
|
||||||
forward.classList.add('inAppBrowserForward');
|
forward.classList.add('inAppBrowserForward');
|
||||||
|
|
||||||
function checkForwardBackward() {
|
var checkForwardBackward = function () {
|
||||||
var backReq = browserElem.getCanGoBack();
|
var backReq = browserElem.getCanGoBack();
|
||||||
backReq.onsuccess = function() {
|
backReq.onsuccess = function() {
|
||||||
if (this.result) {
|
if (this.result) {
|
||||||
@ -123,7 +119,7 @@ var IABExecs = {
|
|||||||
} else {
|
} else {
|
||||||
back.classList.add('disabled');
|
back.classList.add('disabled');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
var forwardReq = browserElem.getCanGoForward();
|
var forwardReq = browserElem.getCanGoForward();
|
||||||
forwardReq.onsuccess = function() {
|
forwardReq.onsuccess = function() {
|
||||||
if (this.result) {
|
if (this.result) {
|
||||||
@ -131,7 +127,7 @@ var IABExecs = {
|
|||||||
} else {
|
} else {
|
||||||
forward.classList.add('disabled');
|
forward.classList.add('disabled');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
|
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
|
||||||
@ -163,16 +159,16 @@ var IABExecs = {
|
|||||||
win({
|
win({
|
||||||
type:'loadstart',
|
type:'loadstart',
|
||||||
url : e.detail
|
url : e.detail
|
||||||
})
|
});
|
||||||
}, false);
|
}, false);
|
||||||
browserElem.addEventListener('mozbrowserloadend', function(e){
|
browserElem.addEventListener('mozbrowserloadend', function(e){
|
||||||
win({type:'loadstop'})
|
win({type:'loadstop'});
|
||||||
}, false);
|
}, false);
|
||||||
browserElem.addEventListener('mozbrowsererror', function(e){
|
browserElem.addEventListener('mozbrowsererror', function(e){
|
||||||
win({type:'loaderror'})
|
win({type:'loaderror'});
|
||||||
}, false);
|
}, false);
|
||||||
browserElem.addEventListener('mozbrowserclose', function(e){
|
browserElem.addEventListener('mozbrowserclose', function(e){
|
||||||
win({type:'exit'})
|
win({type:'exit'});
|
||||||
}, false);
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
window.location = strUrl;
|
window.location = strUrl;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* jshint -W061 */
|
||||||
|
/* global oxide */
|
||||||
|
|
||||||
oxide.addMessageHandler("EXECUTE", function(msg) {
|
oxide.addMessageHandler("EXECUTE", function(msg) {
|
||||||
var code = msg.args.code;
|
var code = msg.args.code;
|
||||||
try {
|
try {
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jslint sloppy:true */
|
/* jslint sloppy:true */
|
||||||
/*global Windows:true, require, document, setTimeout, window, module */
|
/* global Windows:true, setImmediate */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
var cordova = require('cordova'),
|
||||||
urlutil = require('cordova/urlutil');
|
urlutil = require('cordova/urlutil');
|
||||||
@ -188,7 +186,7 @@ var IAB = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
navigationButtonsDivInner = document.createElement("div");
|
navigationButtonsDivInner = document.createElement("div");
|
||||||
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner"
|
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner";
|
||||||
navigationButtonsDivInner.onclick = function (e) {
|
navigationButtonsDivInner.onclick = function (e) {
|
||||||
e.cancelBubble = true;
|
e.cancelBubble = true;
|
||||||
};
|
};
|
||||||
@ -253,9 +251,11 @@ var IAB = {
|
|||||||
if (isWebViewAvailable && browserWrap && popup) {
|
if (isWebViewAvailable && browserWrap && popup) {
|
||||||
var op = popup.invokeScriptAsync("eval", code);
|
var op = popup.invokeScriptAsync("eval", code);
|
||||||
op.oncomplete = function (e) {
|
op.oncomplete = function (e) {
|
||||||
|
if (hasCallback) {
|
||||||
// return null if event target is unavailable by some reason
|
// return null if event target is unavailable by some reason
|
||||||
var result = (e && e.target) ? [e.target.result] : [null];
|
var result = (e && e.target) ? [e.target.result] : [null];
|
||||||
hasCallback && win(result);
|
win(result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
op.onerror = function () { };
|
op.onerror = function () { };
|
||||||
op.start();
|
op.start();
|
||||||
@ -278,8 +278,10 @@ var IAB = {
|
|||||||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
||||||
var op = popup.invokeScriptAsync("eval", code);
|
var op = popup.invokeScriptAsync("eval", code);
|
||||||
op.oncomplete = function(e) {
|
op.oncomplete = function(e) {
|
||||||
|
if (hasCallback) {
|
||||||
var result = [e.target.result];
|
var result = [e.target.result];
|
||||||
hasCallback && win(result);
|
win(result);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
op.onerror = function () { };
|
op.onerror = function () { };
|
||||||
op.start();
|
op.start();
|
||||||
@ -329,7 +331,9 @@ function injectCSS (webView, cssCode, callback) {
|
|||||||
|
|
||||||
var op = webView.invokeScriptAsync("eval", evalWrapper);
|
var op = webView.invokeScriptAsync("eval", evalWrapper);
|
||||||
op.oncomplete = function() {
|
op.oncomplete = function() {
|
||||||
callback && callback([]);
|
if (callback) {
|
||||||
|
callback([]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
op.onerror = function () { };
|
op.onerror = function () { };
|
||||||
op.start();
|
op.start();
|
||||||
|
@ -16,5 +16,5 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
var d = document.getElementById("header")
|
var d = document.getElementById("header");
|
||||||
d.innerHTML = "Script file successfully injected";
|
d.innerHTML = "Script file successfully injected";
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* jshint jasmine: true */
|
||||||
|
/* global MSApp */
|
||||||
|
|
||||||
var cordova = require('cordova');
|
var cordova = require('cordova');
|
||||||
var isWindows = cordova.platformId == 'windows';
|
var isWindows = cordova.platformId == 'windows';
|
||||||
|
|
||||||
@ -183,13 +186,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
if (e.url != lastLoadStartURL) {
|
if (e.url != lastLoadStartURL) {
|
||||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
||||||
}
|
}
|
||||||
if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) {
|
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
|
||||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||||
if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) {
|
if (!(e.type == 'loaderror' && counts.loadstart === 0)) {
|
||||||
alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')');
|
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')');
|
||||||
}
|
}
|
||||||
} else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) {
|
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']);
|
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart);
|
||||||
}
|
}
|
||||||
wasReset = true;
|
wasReset = true;
|
||||||
numExpectedRedirects = 0;
|
numExpectedRedirects = 0;
|
||||||
@ -197,7 +200,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'];
|
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||||
if (numStopEvents === 0 && !wasReset) {
|
if (numStopEvents === 0 && !wasReset) {
|
||||||
alert('Unexpected: browser closed without a loadstop or loaderror.');
|
alert('Unexpected: browser closed without a loadstop or loaderror.');
|
||||||
} else if (numStopEvents > 1) {
|
} else if (numStopEvents > 1) {
|
||||||
|
@ -22,10 +22,6 @@
|
|||||||
/*jslint sloppy:true */
|
/*jslint sloppy:true */
|
||||||
/*global Windows:true, require, document, setTimeout, window, module */
|
/*global Windows:true, require, document, setTimeout, window, module */
|
||||||
|
|
||||||
|
|
||||||
var cordova = require('cordova'),
|
|
||||||
channel = require('cordova/channel');
|
|
||||||
|
|
||||||
var browserWrap;
|
var browserWrap;
|
||||||
|
|
||||||
var IAB = {
|
var IAB = {
|
||||||
@ -45,7 +41,6 @@ var IAB = {
|
|||||||
open: function (win, lose, args) {
|
open: function (win, lose, args) {
|
||||||
var strUrl = args[0],
|
var strUrl = args[0],
|
||||||
target = args[1],
|
target = args[1],
|
||||||
features = args[2],
|
|
||||||
url,
|
url,
|
||||||
elem;
|
elem;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user