cordova-plugin-inappbrowser
Advanced tools
Comparing version 1.7.1 to 1.7.2
{ | ||
"name": "cordova-plugin-inappbrowser", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "Cordova InAppBrowser Plugin", | ||
@@ -25,2 +25,5 @@ "types": "./types/index.d.ts", | ||
}, | ||
"bugs": { | ||
"url": "https://issues.apache.org/jira/browse/CB" | ||
}, | ||
"keywords": [ | ||
@@ -45,4 +48,4 @@ "cordova", | ||
"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" | ||
"test": "npm run eslint", | ||
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests" | ||
}, | ||
@@ -62,4 +65,10 @@ "engines": { | ||
"devDependencies": { | ||
"jshint": "^2.6.0" | ||
"eslint": "^4.0.0", | ||
"eslint-config-semistandard": "^11.0.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-node": "^5.0.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1" | ||
} | ||
} |
@@ -24,5 +24,5 @@ --- | ||
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| | ||
|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | ||
|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)| | ||
|AppVeyor|Travis CI| | ||
|:-:|:-:| | ||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-inappbrowser?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)| | ||
@@ -61,3 +61,3 @@ # cordova-plugin-inappbrowser | ||
delete window.open // Reverts the call back to it's prototype's default | ||
delete window.open // Reverts the call back to its prototype's default | ||
@@ -71,3 +71,3 @@ Although `window.open` is in the global scope, InAppBrowser is not available until after the `deviceready` event. | ||
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) | ||
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22cordova-plugin-inappbrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) | ||
@@ -107,7 +107,9 @@ | ||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. All platforms support the value below: | ||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. | ||
All platforms support: | ||
- __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off. | ||
Android only: | ||
Android supports these additional options: | ||
@@ -117,4 +119,4 @@ - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. | ||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened | ||
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. | ||
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. | ||
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. | ||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). | ||
@@ -124,9 +126,9 @@ - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). | ||
iOS only: | ||
iOS supports these additional options: | ||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. | ||
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened | ||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened | ||
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. | ||
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. | ||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. | ||
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened | ||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened | ||
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) | ||
@@ -142,8 +144,9 @@ - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). | ||
Windows only: | ||
Windows supports these additional options: | ||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. | ||
- __hardwareback__: works the same way as on Android platform. | ||
- __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window. | ||
- __hardwareback__: works the same way as on Android platform. | ||
### Supported Platforms | ||
@@ -154,2 +157,3 @@ | ||
- BlackBerry 10 | ||
- Browser | ||
- Firefox OS | ||
@@ -160,3 +164,2 @@ - iOS | ||
- Windows Phone 7 and 8 | ||
- Browser | ||
@@ -335,6 +338,6 @@ ### Example | ||
- Android | ||
- Browser | ||
- iOS | ||
- Windows 8 and 8.1 | ||
- Windows Phone 7 and 8 | ||
- Browser | ||
@@ -372,6 +375,6 @@ ### Browser Quirks | ||
- Android | ||
- Browser | ||
- iOS | ||
- Windows 8 and 8.1 | ||
- Windows Phone 7 and 8 | ||
- Browser | ||
@@ -397,2 +400,3 @@ ### Quick Example | ||
- Android | ||
- Browser | ||
- Firefox OS | ||
@@ -402,3 +406,2 @@ - iOS | ||
- Windows Phone 7 and 8 | ||
- Browser | ||
@@ -422,5 +425,5 @@ ### Quick Example | ||
- Android | ||
- Browser | ||
- iOS | ||
- Windows 8 and 8.1 | ||
- Browser | ||
@@ -477,5 +480,5 @@ ### Quick Example | ||
- Android | ||
- Browser | ||
- iOS | ||
- Windows 8 and 8.1 | ||
- Browser | ||
@@ -482,0 +485,0 @@ ### Quick Example |
@@ -23,2 +23,11 @@ <!-- | ||
### 1.7.2 (Nov 06, 2017) | ||
* [CB-13473](https://issues.apache.org/jira/browse/CB-13473) (CI) Removed **Browser** builds from AppVeyor | ||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again | ||
* [CB-13347](https://issues.apache.org/jira/browse/CB-13347) Enable thirdparty cookies on `>=Android 5.0` device | ||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint` | ||
* [CB-12975](https://issues.apache.org/jira/browse/CB-12975) (docs) Resort and reword `cordova.InAppBrowser.open` `options` lists | ||
* [CB-12586](https://issues.apache.org/jira/browse/CB-12586) (iOS) fix method `hide` doesn't work | ||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`. | ||
### 1.7.1 (Apr 27, 2017) | ||
@@ -25,0 +34,0 @@ * [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badges to `README` |
@@ -32,17 +32,32 @@ /* | ||
function attachNavigationEvents(element, callback) { | ||
function attachNavigationEvents (element, callback) { | ||
var onError = function () { | ||
callback({ type: "loaderror", url: this.contentWindow.location.href}, {keepCallback: true}); | ||
try { | ||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} | ||
}; | ||
element.addEventListener("pageshow", function () { | ||
callback({ type: "loadstart", url: this.contentWindow.location.href}, {keepCallback: true}); | ||
element.addEventListener('pageshow', function () { | ||
try { | ||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} | ||
}); | ||
element.addEventListener("load", function () { | ||
callback({ type: "loadstop", url: this.contentWindow.location.href}, {keepCallback: true}); | ||
element.addEventListener('load', function () { | ||
try { | ||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal | ||
} | ||
}); | ||
element.addEventListener("error", onError); | ||
element.addEventListener("abort", onError); | ||
element.addEventListener('error', onError); | ||
element.addEventListener('abort', onError); | ||
} | ||
@@ -53,3 +68,4 @@ | ||
if (browserWrap) { | ||
if (win) win({ type: "exit" }); | ||
// use the "open" function callback so that the exit event is fired properly | ||
if (IAB._win) IAB._win({ type: 'exit' }); | ||
@@ -64,3 +80,3 @@ browserWrap.parentNode.removeChild(browserWrap); | ||
if (browserWrap) { | ||
browserWrap.style.display = "block"; | ||
browserWrap.style.display = 'block'; | ||
} | ||
@@ -70,27 +86,29 @@ }, | ||
open: function (win, lose, args) { | ||
var strUrl = args[0], | ||
target = args[1], | ||
features = args[2]; | ||
var strUrl = args[0]; | ||
var target = args[1]; | ||
var features = args[2]; | ||
if (target === "_self" || !target) { | ||
IAB._win = win; | ||
if (target === '_self' || !target) { | ||
window.location = strUrl; | ||
} else if (target === "_system") { | ||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank"); | ||
} else if (target === '_system') { | ||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank'); | ||
} else { | ||
// "_blank" or anything else | ||
if (!browserWrap) { | ||
browserWrap = document.createElement("div"); | ||
browserWrap.style.position = "absolute"; | ||
browserWrap.style.top = "0"; | ||
browserWrap.style.left = "0"; | ||
browserWrap.style.boxSizing = "border-box"; | ||
browserWrap.style.borderWidth = "40px"; | ||
browserWrap.style.width = "100vw"; | ||
browserWrap.style.height = "100vh"; | ||
browserWrap.style.borderStyle = "solid"; | ||
browserWrap.style.borderColor = "rgba(0,0,0,0.25)"; | ||
browserWrap = document.createElement('div'); | ||
browserWrap.style.position = 'absolute'; | ||
browserWrap.style.top = '0'; | ||
browserWrap.style.left = '0'; | ||
browserWrap.style.boxSizing = 'border-box'; | ||
browserWrap.style.borderWidth = '40px'; | ||
browserWrap.style.width = '100vw'; | ||
browserWrap.style.height = '100vh'; | ||
browserWrap.style.borderStyle = 'solid'; | ||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)'; | ||
browserWrap.onclick = function () { | ||
setTimeout(function () { | ||
IAB.close(win); | ||
IAB.close(); | ||
}, 0); | ||
@@ -102,20 +120,20 @@ }; | ||
if (features.indexOf("hidden=yes") !== -1) { | ||
browserWrap.style.display = "none"; | ||
if (features.indexOf('hidden=yes') !== -1) { | ||
browserWrap.style.display = 'none'; | ||
} | ||
popup = document.createElement("iframe"); | ||
popup.style.borderWidth = "0px"; | ||
popup.style.width = "100%"; | ||
popup = document.createElement('iframe'); | ||
popup.style.borderWidth = '0px'; | ||
popup.style.width = '100%'; | ||
browserWrap.appendChild(popup); | ||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { | ||
popup.style.height = "calc(100% - 60px)"; | ||
popup.style.marginBottom = "-4px"; | ||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) { | ||
popup.style.height = 'calc(100% - 60px)'; | ||
popup.style.marginBottom = '-4px'; | ||
navigationButtonsDiv = document.createElement("div"); | ||
navigationButtonsDiv.style.height = "60px"; | ||
navigationButtonsDiv.style.backgroundColor = "#404040"; | ||
navigationButtonsDiv.style.zIndex = "999"; | ||
navigationButtonsDiv = document.createElement('div'); | ||
navigationButtonsDiv.style.height = '60px'; | ||
navigationButtonsDiv.style.backgroundColor = '#404040'; | ||
navigationButtonsDiv.style.zIndex = '999'; | ||
navigationButtonsDiv.onclick = function (e) { | ||
@@ -125,9 +143,9 @@ e.cancelBubble = true; | ||
navigationButtonsDivInner = document.createElement("div"); | ||
navigationButtonsDivInner.style.paddingTop = "10px"; | ||
navigationButtonsDivInner.style.height = "50px"; | ||
navigationButtonsDivInner.style.width = "160px"; | ||
navigationButtonsDivInner.style.margin = "0 auto"; | ||
navigationButtonsDivInner.style.backgroundColor = "#404040"; | ||
navigationButtonsDivInner.style.zIndex = "999"; | ||
navigationButtonsDivInner = document.createElement('div'); | ||
navigationButtonsDivInner.style.paddingTop = '10px'; | ||
navigationButtonsDivInner.style.height = '50px'; | ||
navigationButtonsDivInner.style.width = '160px'; | ||
navigationButtonsDivInner.style.margin = '0 auto'; | ||
navigationButtonsDivInner.style.backgroundColor = '#404040'; | ||
navigationButtonsDivInner.style.zIndex = '999'; | ||
navigationButtonsDivInner.onclick = function (e) { | ||
@@ -137,36 +155,33 @@ e.cancelBubble = true; | ||
backButton = document.createElement('button'); | ||
backButton.style.width = '40px'; | ||
backButton.style.height = '40px'; | ||
backButton.style.borderRadius = '40px'; | ||
backButton = document.createElement("button"); | ||
backButton.style.width = "40px"; | ||
backButton.style.height = "40px"; | ||
backButton.style.borderRadius = "40px"; | ||
backButton.innerHTML = "←"; | ||
backButton.addEventListener("click", function (e) { | ||
if (popup.canGoBack) | ||
popup.goBack(); | ||
backButton.innerHTML = '←'; | ||
backButton.addEventListener('click', function (e) { | ||
if (popup.canGoBack) { popup.goBack(); } | ||
}); | ||
forwardButton = document.createElement("button"); | ||
forwardButton.style.marginLeft = "20px"; | ||
forwardButton.style.width = "40px"; | ||
forwardButton.style.height = "40px"; | ||
forwardButton.style.borderRadius = "40px"; | ||
forwardButton = document.createElement('button'); | ||
forwardButton.style.marginLeft = '20px'; | ||
forwardButton.style.width = '40px'; | ||
forwardButton.style.height = '40px'; | ||
forwardButton.style.borderRadius = '40px'; | ||
forwardButton.innerHTML = "→"; | ||
forwardButton.addEventListener("click", function (e) { | ||
if (popup.canGoForward) | ||
popup.goForward(); | ||
forwardButton.innerHTML = '→'; | ||
forwardButton.addEventListener('click', function (e) { | ||
if (popup.canGoForward) { popup.goForward(); } | ||
}); | ||
closeButton = document.createElement("button"); | ||
closeButton.style.marginLeft = "20px"; | ||
closeButton.style.width = "40px"; | ||
closeButton.style.height = "40px"; | ||
closeButton.style.borderRadius = "40px"; | ||
closeButton = document.createElement('button'); | ||
closeButton.style.marginLeft = '20px'; | ||
closeButton.style.width = '40px'; | ||
closeButton.style.height = '40px'; | ||
closeButton.style.borderRadius = '40px'; | ||
closeButton.innerHTML = "✖"; | ||
closeButton.addEventListener("click", function (e) { | ||
closeButton.innerHTML = '✖'; | ||
closeButton.addEventListener('click', function (e) { | ||
setTimeout(function () { | ||
IAB.close(win); | ||
IAB.close(); | ||
}, 0); | ||
@@ -186,3 +201,3 @@ }); | ||
} else { | ||
popup.style.height = "100%"; | ||
popup.style.height = '100%'; | ||
} | ||
@@ -198,4 +213,4 @@ | ||
injectScriptCode: function (win, fail, args) { | ||
var code = args[0], | ||
hasCallback = args[1]; | ||
var code = args[0]; | ||
var hasCallback = args[1]; | ||
@@ -208,3 +223,3 @@ if (browserWrap && popup) { | ||
} | ||
} catch(e) { | ||
} catch (e) { | ||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e)); | ||
@@ -221,3 +236,3 @@ } | ||
} | ||
}, | ||
}, | ||
@@ -243,2 +258,2 @@ injectStyleCode: function (win, fail, args) { | ||
require("cordova/exec/proxy").add("InAppBrowser", module.exports); | ||
require('cordova/exec/proxy').add('InAppBrowser', module.exports); |
@@ -35,3 +35,3 @@ /* | ||
browserWrap = null; | ||
if (typeof(win) == "function") win({type:'exit'}); | ||
if (typeof (win) === 'function') win({type: 'exit'}); | ||
} | ||
@@ -52,13 +52,13 @@ }, | ||
open: function (win, lose, args) { | ||
var strUrl = args[0], | ||
target = args[1], | ||
features_string = args[2] || "location=yes", //location=yes is default | ||
features = {}; | ||
var strUrl = args[0]; | ||
var target = args[1]; | ||
var features_string = args[2] || 'location=yes'; // location=yes is default | ||
var features = {}; | ||
var features_list = features_string.split(','); | ||
features_list.forEach(function(feature) { | ||
features_list.forEach(function (feature) { | ||
var tup = feature.split('='); | ||
if (tup[1] == 'yes') { | ||
if (tup[1] === 'yes') { | ||
tup[1] = true; | ||
} else if (tup[1] == 'no') { | ||
} else if (tup[1] === 'no') { | ||
tup[1] = false; | ||
@@ -73,4 +73,3 @@ } else { | ||
}); | ||
function updateIframeSizeNoLocation() { | ||
function updateIframeSizeNoLocation () { | ||
browserWrap.style.width = window.innerWidth + 'px'; | ||
@@ -123,3 +122,3 @@ browserWrap.style.height = window.innerHeight + 'px'; | ||
var backReq = browserElem.getCanGoBack(); | ||
backReq.onsuccess = function() { | ||
backReq.onsuccess = function () { | ||
if (this.result) { | ||
@@ -132,3 +131,3 @@ back.classList.remove('disabled'); | ||
var forwardReq = browserElem.getCanGoForward(); | ||
forwardReq.onsuccess = function() { | ||
forwardReq.onsuccess = function () { | ||
if (this.result) { | ||
@@ -166,17 +165,17 @@ forward.classList.remove('disabled'); | ||
//we use mozbrowserlocationchange instead of mozbrowserloadstart to get the url | ||
browserElem.addEventListener('mozbrowserlocationchange', function(e){ | ||
// we use mozbrowserlocationchange instead of mozbrowserloadstart to get the url | ||
browserElem.addEventListener('mozbrowserlocationchange', function (e) { | ||
win({ | ||
type:'loadstart', | ||
url : e.detail | ||
type: 'loadstart', | ||
url: e.detail | ||
}); | ||
}, false); | ||
browserElem.addEventListener('mozbrowserloadend', function(e){ | ||
win({type:'loadstop'}); | ||
browserElem.addEventListener('mozbrowserloadend', function (e) { | ||
win({type: 'loadstop'}); | ||
}, false); | ||
browserElem.addEventListener('mozbrowsererror', function(e){ | ||
win({type:'loaderror'}); | ||
browserElem.addEventListener('mozbrowsererror', function (e) { | ||
win({type: 'loaderror'}); | ||
}, false); | ||
browserElem.addEventListener('mozbrowserclose', function(e){ | ||
win({type:'exit'}); | ||
browserElem.addEventListener('mozbrowserclose', function (e) { | ||
win({type: 'exit'}); | ||
}, false); | ||
@@ -183,0 +182,0 @@ } else { |
@@ -22,12 +22,11 @@ /* | ||
/* jshint -W061 */ | ||
/* global oxide */ | ||
oxide.addMessageHandler("EXECUTE", function(msg) { | ||
oxide.addMessageHandler('EXECUTE', function (msg) { | ||
var code = msg.args.code; | ||
try { | ||
msg.reply({result: eval(code)}); | ||
} catch(e) { | ||
msg.error("Code threw exception: \"" + e + "\""); | ||
msg.reply({result: eval(code)}); // eslint-disable-line no-eval | ||
} catch (e) { | ||
msg.error('Code threw exception: "' + e + '"'); | ||
} | ||
}); |
@@ -1,2 +0,2 @@ | ||
/* | ||
/* | ||
* | ||
@@ -24,5 +24,6 @@ * Licensed to the Apache Software Foundation (ASF) under one | ||
/* global Windows:true, setImmediate */ | ||
/* eslint standard/no-callback-literal : 0 */ | ||
var cordova = require('cordova'), | ||
urlutil = require('cordova/urlutil'); | ||
var cordova = require('cordova'); | ||
var urlutil = require('cordova/urlutil'); | ||
@@ -44,34 +45,34 @@ var browserWrap, | ||
function attachNavigationEvents(element, callback) { | ||
function attachNavigationEvents (element, callback) { | ||
if (isWebViewAvailable) { | ||
element.addEventListener("MSWebViewNavigationStarting", function (e) { | ||
callback({ type: "loadstart", url: e.uri}, {keepCallback: true} ); | ||
element.addEventListener('MSWebViewNavigationStarting', function (e) { | ||
callback({ type: 'loadstart', url: e.uri }, {keepCallback: true}); | ||
}); | ||
element.addEventListener("MSWebViewNavigationCompleted", function (e) { | ||
element.addEventListener('MSWebViewNavigationCompleted', function (e) { | ||
if (e.isSuccess) { | ||
callback({ type: "loadstop", url: e.uri }, { keepCallback: true }); | ||
callback({ type: 'loadstop', url: e.uri }, { keepCallback: true }); | ||
} else { | ||
callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); | ||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true }); | ||
} | ||
}); | ||
element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) { | ||
element.addEventListener('MSWebViewUnviewableContentIdentified', function (e) { | ||
// WebView found the content to be not HTML. | ||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx | ||
callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); | ||
callback({ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true }); | ||
}); | ||
element.addEventListener("MSWebViewContentLoading", function (e) { | ||
element.addEventListener('MSWebViewContentLoading', function (e) { | ||
if (navigationButtonsDiv && popup) { | ||
if (popup.canGoBack) { | ||
backButton.removeAttribute("disabled"); | ||
backButton.removeAttribute('disabled'); | ||
} else { | ||
backButton.setAttribute("disabled", "true"); | ||
backButton.setAttribute('disabled', 'true'); | ||
} | ||
if (popup.canGoForward) { | ||
forwardButton.removeAttribute("disabled"); | ||
forwardButton.removeAttribute('disabled'); | ||
} else { | ||
forwardButton.setAttribute("disabled", "true"); | ||
forwardButton.setAttribute('disabled', 'true'); | ||
} | ||
@@ -82,15 +83,15 @@ } | ||
var onError = function () { | ||
callback({ type: "loaderror", url: this.contentWindow.location}, {keepCallback: true}); | ||
callback({ type: 'loaderror', url: this.contentWindow.location }, {keepCallback: true}); | ||
}; | ||
element.addEventListener("unload", function () { | ||
callback({ type: "loadstart", url: this.contentWindow.location}, {keepCallback: true}); | ||
element.addEventListener('unload', function () { | ||
callback({ type: 'loadstart', url: this.contentWindow.location }, {keepCallback: true}); | ||
}); | ||
element.addEventListener("load", function () { | ||
callback({ type: "loadstop", url: this.contentWindow.location}, {keepCallback: true}); | ||
element.addEventListener('load', function () { | ||
callback({ type: 'loadstop', url: this.contentWindow.location }, {keepCallback: true}); | ||
}); | ||
element.addEventListener("error", onError); | ||
element.addEventListener("abort", onError); | ||
element.addEventListener('error', onError); | ||
element.addEventListener('abort', onError); | ||
} | ||
@@ -104,3 +105,3 @@ } | ||
if (navigationEventsCallback) { | ||
navigationEventsCallback({ type: "exit" }); | ||
navigationEventsCallback({ type: 'exit' }); | ||
} | ||
@@ -114,3 +115,3 @@ | ||
document.removeEventListener("backbutton", hardwareBackCallback, false); | ||
document.removeEventListener('backbutton', hardwareBackCallback, false); | ||
} | ||
@@ -122,3 +123,3 @@ }); | ||
if (browserWrap) { | ||
browserWrap.style.display = "block"; | ||
browserWrap.style.display = 'block'; | ||
} | ||
@@ -129,3 +130,3 @@ }); | ||
if (browserWrap) { | ||
browserWrap.style.display = "none"; | ||
browserWrap.style.display = 'none'; | ||
} | ||
@@ -136,13 +137,13 @@ }, | ||
setImmediate(function () { | ||
var strUrl = args[0], | ||
target = args[1], | ||
features = args[2], | ||
url; | ||
var strUrl = args[0]; | ||
var target = args[1]; | ||
var features = args[2]; | ||
var url; | ||
navigationEventsCallback = win; | ||
if (target === "_system") { | ||
if (target === '_system') { | ||
url = new Windows.Foundation.Uri(strUrl); | ||
Windows.System.Launcher.launchUriAsync(url); | ||
} else if (target === "_self" || !target) { | ||
} else if (target === '_self' || !target) { | ||
window.location = strUrl; | ||
@@ -153,13 +154,13 @@ } else { | ||
var browserWrapStyle = document.createElement('link'); | ||
browserWrapStyle.rel = "stylesheet"; | ||
browserWrapStyle.type = "text/css"; | ||
browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css"); | ||
browserWrapStyle.rel = 'stylesheet'; | ||
browserWrapStyle.type = 'text/css'; | ||
browserWrapStyle.href = urlutil.makeAbsolute('/www/css/inappbrowser.css'); | ||
document.head.appendChild(browserWrapStyle); | ||
browserWrap = document.createElement("div"); | ||
browserWrap.className = "inAppBrowserWrap"; | ||
browserWrap = document.createElement('div'); | ||
browserWrap.className = 'inAppBrowserWrap'; | ||
if (features.indexOf("fullscreen=yes") > -1) { | ||
browserWrap.classList.add("inAppBrowserWrapFullscreen"); | ||
if (features.indexOf('fullscreen=yes') > -1) { | ||
browserWrap.classList.add('inAppBrowserWrapFullscreen'); | ||
} | ||
@@ -178,18 +179,18 @@ | ||
// Hide scrollbars for the whole body while inappbrowser's window is open | ||
document.body.style.msOverflowStyle = "none"; | ||
document.body.style.msOverflowStyle = 'none'; | ||
} | ||
if (features.indexOf("hidden=yes") !== -1) { | ||
browserWrap.style.display = "none"; | ||
if (features.indexOf('hidden=yes') !== -1) { | ||
browserWrap.style.display = 'none'; | ||
} | ||
popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe"); | ||
if (popup instanceof HTMLIFrameElement) { | ||
popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe'); | ||
if (popup instanceof HTMLIFrameElement) { // eslint-disable-line no-undef | ||
// For iframe we need to override bacground color of parent element here | ||
// otherwise pages without background color set will have transparent background | ||
popup.style.backgroundColor = "white"; | ||
popup.style.backgroundColor = 'white'; | ||
} | ||
popup.style.borderWidth = "0px"; | ||
popup.style.width = "100%"; | ||
popup.style.marginBottom = "-5px"; | ||
popup.style.borderWidth = '0px'; | ||
popup.style.width = '100%'; | ||
popup.style.marginBottom = '-5px'; | ||
@@ -204,3 +205,3 @@ browserWrap.appendChild(popup); | ||
if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) { | ||
if (features.indexOf('hardwareback=yes') > -1 || features.indexOf('hardwareback') === -1) { | ||
hardwareBackCallback = function () { | ||
@@ -212,3 +213,3 @@ if (browserWrap.style.display === 'none') { | ||
// which is to exit the app if the navigation stack is empty. | ||
throw 'Exit the app'; | ||
throw 'Exit the app'; // eslint-disable-line no-throw-literal | ||
} | ||
@@ -222,7 +223,7 @@ | ||
}; | ||
} else if (features.indexOf("hardwareback=no") > -1) { | ||
} else if (features.indexOf('hardwareback=no') > -1) { | ||
hardwareBackCallback = function () { | ||
if (browserWrap.style.display === 'none') { | ||
// See comment above | ||
throw 'Exit the app'; | ||
throw 'Exit the app'; // eslint-disable-line no-throw-literal | ||
} | ||
@@ -234,9 +235,9 @@ | ||
document.addEventListener("backbutton", hardwareBackCallback, false); | ||
document.addEventListener('backbutton', hardwareBackCallback, false); | ||
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { | ||
popup.style.height = "calc(100% - 70px)"; | ||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) { | ||
popup.style.height = 'calc(100% - 70px)'; | ||
navigationButtonsDiv = document.createElement("div"); | ||
navigationButtonsDiv.className = "inappbrowser-app-bar"; | ||
navigationButtonsDiv = document.createElement('div'); | ||
navigationButtonsDiv.className = 'inappbrowser-app-bar'; | ||
navigationButtonsDiv.onclick = function (e) { | ||
@@ -246,4 +247,4 @@ e.cancelBubble = true; | ||
navigationButtonsDivInner = document.createElement("div"); | ||
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner"; | ||
navigationButtonsDivInner = document.createElement('div'); | ||
navigationButtonsDivInner.className = 'inappbrowser-app-bar-inner'; | ||
navigationButtonsDivInner.onclick = function (e) { | ||
@@ -253,27 +254,25 @@ e.cancelBubble = true; | ||
backButton = document.createElement("div"); | ||
backButton.innerText = "back"; | ||
backButton.className = "app-bar-action action-back"; | ||
backButton.addEventListener("click", function (e) { | ||
if (popup.canGoBack) | ||
popup.goBack(); | ||
backButton = document.createElement('div'); | ||
backButton.innerText = 'back'; | ||
backButton.className = 'app-bar-action action-back'; | ||
backButton.addEventListener('click', function (e) { | ||
if (popup.canGoBack) { popup.goBack(); } | ||
}); | ||
forwardButton = document.createElement("div"); | ||
forwardButton.innerText = "forward"; | ||
forwardButton.className = "app-bar-action action-forward"; | ||
forwardButton.addEventListener("click", function (e) { | ||
if (popup.canGoForward) | ||
popup.goForward(); | ||
forwardButton = document.createElement('div'); | ||
forwardButton.innerText = 'forward'; | ||
forwardButton.className = 'app-bar-action action-forward'; | ||
forwardButton.addEventListener('click', function (e) { | ||
if (popup.canGoForward) { popup.goForward(); } | ||
}); | ||
closeButton = document.createElement("div"); | ||
closeButton.innerText = "close"; | ||
closeButton.className = "app-bar-action action-close"; | ||
closeButton.addEventListener("click", closeHandler); | ||
closeButton = document.createElement('div'); | ||
closeButton.innerText = 'close'; | ||
closeButton.className = 'app-bar-action action-close'; | ||
closeButton.addEventListener('click', closeHandler); | ||
if (!isWebViewAvailable) { | ||
// iframe navigation is not yet supported | ||
backButton.setAttribute("disabled", "true"); | ||
forwardButton.setAttribute("disabled", "true"); | ||
backButton.setAttribute('disabled', 'true'); | ||
forwardButton.setAttribute('disabled', 'true'); | ||
} | ||
@@ -288,3 +287,3 @@ | ||
} else { | ||
popup.style.height = "100%"; | ||
popup.style.height = '100%'; | ||
} | ||
@@ -296,3 +295,3 @@ | ||
if (isWebViewAvailable) { | ||
strUrl = strUrl.replace("ms-appx://", "ms-appx-web://"); | ||
strUrl = strUrl.replace('ms-appx://', 'ms-appx-web://'); | ||
} | ||
@@ -306,7 +305,7 @@ popup.src = strUrl; | ||
setImmediate(function () { | ||
var code = args[0], | ||
hasCallback = args[1]; | ||
var code = args[0]; | ||
var hasCallback = args[1]; | ||
if (isWebViewAvailable && browserWrap && popup) { | ||
var op = popup.invokeScriptAsync("eval", code); | ||
var op = popup.invokeScriptAsync('eval', code); | ||
op.oncomplete = function (e) { | ||
@@ -327,6 +326,6 @@ if (hasCallback) { | ||
setImmediate(function () { | ||
var filePath = args[0], | ||
hasCallback = args[1]; | ||
var filePath = args[0]; | ||
var hasCallback = args[1]; | ||
if (!!filePath) { | ||
if (filePath) { | ||
filePath = urlutil.makeAbsolute(filePath); | ||
@@ -340,4 +339,4 @@ } | ||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) { | ||
var op = popup.invokeScriptAsync("eval", code); | ||
op.oncomplete = function(e) { | ||
var op = popup.invokeScriptAsync('eval', code); | ||
op.oncomplete = function (e) { | ||
if (hasCallback) { | ||
@@ -358,4 +357,4 @@ var result = [e.target.result]; | ||
setImmediate(function () { | ||
var code = args[0], | ||
hasCallback = args[1]; | ||
var code = args[0]; | ||
var hasCallback = args[1]; | ||
@@ -370,4 +369,4 @@ if (isWebViewAvailable && browserWrap && popup) { | ||
setImmediate(function () { | ||
var filePath = args[0], | ||
hasCallback = args[1]; | ||
var filePath = args[0]; | ||
var hasCallback = args[1]; | ||
@@ -394,7 +393,7 @@ filePath = filePath && urlutil.makeAbsolute(filePath); | ||
var escapedCode = JSON.stringify(cssCode); | ||
var evalWrapper = "(function(d){var c=d.createElement('style');c.innerHTML=%s;d.head.appendChild(c);})(document)" | ||
var evalWrapper = '(function(d){var c=d.createElement(\'style\');c.innerHTML=%s;d.head.appendChild(c);})(document)' | ||
.replace('%s', escapedCode); | ||
var op = webView.invokeScriptAsync("eval", evalWrapper); | ||
op.oncomplete = function() { | ||
var op = webView.invokeScriptAsync('eval', evalWrapper); | ||
op.oncomplete = function () { | ||
if (callback) { | ||
@@ -410,2 +409,2 @@ callback([]); | ||
require("cordova/exec/proxy").add("InAppBrowser", module.exports); | ||
require('cordova/exec/proxy').add('InAppBrowser', module.exports); |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
var d = document.getElementById("header"); | ||
d.innerHTML = "Script file successfully injected"; | ||
var d = document.getElementById('header'); | ||
d.innerHTML = 'Script file successfully injected'; |
@@ -22,7 +22,7 @@ /* | ||
/* jshint jasmine: true */ | ||
/* global MSApp */ | ||
var cordova = require('cordova'); | ||
var isWindows = cordova.platformId == 'windows'; | ||
var isWindows = cordova.platformId === 'windows'; | ||
var isBrowser = cordova.platformId === 'browser'; | ||
@@ -39,7 +39,7 @@ window.alert = window.alert || navigator.notification.alert; | ||
it("inappbrowser.spec.1 should exist", function () { | ||
it('inappbrowser.spec.1 should exist', function () { | ||
expect(cordova.InAppBrowser).toBeDefined(); | ||
}); | ||
it("inappbrowser.spec.2 should contain open function", function () { | ||
it('inappbrowser.spec.2 should contain open function', function () { | ||
expect(cordova.InAppBrowser.open).toBeDefined(); | ||
@@ -52,3 +52,3 @@ expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function)); | ||
if (cordova.platformId == 'osx') { | ||
if (cordova.platformId === 'osx') { | ||
pending('Open method not fully supported on OSX.'); | ||
@@ -83,6 +83,7 @@ return; | ||
function verifyEvent(evt, type) { | ||
function verifyEvent (evt, type) { | ||
expect(evt).toBeDefined(); | ||
expect(evt.type).toEqual(type); | ||
if (type !== 'exit') { // `exit` event does not have url field | ||
// `exit` event does not have url field, browser returns null url for CORS requests | ||
if (type !== 'exit' && !isBrowser) { | ||
expect(evt.url).toEqual(url); | ||
@@ -92,3 +93,3 @@ } | ||
function verifyLoadErrorEvent(evt) { | ||
function verifyLoadErrorEvent (evt) { | ||
expect(evt).toBeDefined(); | ||
@@ -101,3 +102,3 @@ expect(evt.type).toEqual('loaderror'); | ||
it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () { | ||
it('inappbrowser.spec.3 should return InAppBrowser instance with required methods', function () { | ||
iabInstance = cordova.InAppBrowser.open(url, '_blank'); | ||
@@ -116,3 +117,3 @@ | ||
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) { | ||
@@ -126,3 +127,7 @@ verifyEvent(evt, 'loadstart'); | ||
verifyEvent(evt, 'loadstop'); | ||
expect(onLoadStart).toHaveBeenCalled(); | ||
if (!isBrowser) { | ||
// according to documentation, "loadstart" event is not supported on browser | ||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1 | ||
expect(onLoadStart).toHaveBeenCalled(); | ||
} | ||
done(); | ||
@@ -132,3 +137,3 @@ }); | ||
it("inappbrowser.spec.5 should support exit event", function (done) { | ||
it('inappbrowser.spec.5 should support exit event', function (done) { | ||
iabInstance = cordova.InAppBrowser.open(url, '_blank'); | ||
@@ -143,3 +148,8 @@ iabInstance.addEventListener('exit', function (evt) { | ||
it("inappbrowser.spec.6 should support loaderror event", function (done) { | ||
it('inappbrowser.spec.6 should support loaderror event', function (done) { | ||
if (isBrowser) { | ||
// according to documentation, "loaderror" event is not supported on browser | ||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1 | ||
pending('Browser platform doesn\'t support loaderror event'); | ||
} | ||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank'); | ||
@@ -156,6 +166,6 @@ iabInstance.addEventListener('loaderror', function (evt) { | ||
function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) { | ||
function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) { | ||
numExpectedRedirects = numExpectedRedirects || 0; | ||
useWindowOpen = useWindowOpen || false; | ||
console.log("Opening " + url); | ||
console.log('Opening ' + url); | ||
@@ -165,3 +175,3 @@ var counts; | ||
var wasReset = false; | ||
function reset() { | ||
function reset () { | ||
counts = { | ||
@@ -187,18 +197,17 @@ 'loaderror': 0, | ||
iab = window.open(url, target, params, callbacks); | ||
} | ||
else { | ||
} else { | ||
iab = cordova.InAppBrowser.open(url, target, params, callbacks); | ||
} | ||
if (!iab) { | ||
alert('open returned ' + iab); | ||
alert('open returned ' + iab); // eslint-disable-line no-undef | ||
return; | ||
} | ||
function logEvent(e) { | ||
function logEvent (e) { | ||
console.log('IAB event=' + JSON.stringify(e)); | ||
counts[e.type]++; | ||
// 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.'); | ||
if (e.type === 'loadstart') { | ||
if (e.url === lastLoadStartURL) { | ||
alert('Unexpected: loadstart fired multiple times for the same URL.'); // eslint-disable-line no-undef | ||
} | ||
@@ -208,13 +217,13 @@ 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'); | ||
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 | ||
} | ||
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 + ')'); | ||
if (!(e.type === 'loaderror' && counts.loadstart === 0)) { | ||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); // eslint-disable-line no-undef | ||
} | ||
} 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); // eslint-disable-line no-undef | ||
} | ||
@@ -226,8 +235,8 @@ wasReset = true; | ||
// Verify that loadend / loaderror was called. | ||
if (e.type == 'exit') { | ||
if (e.type === 'exit') { | ||
var numStopEvents = counts.loadstop + counts.loaderror; | ||
if (numStopEvents === 0 && !wasReset) { | ||
alert('Unexpected: browser closed without a loadstop or loaderror.'); | ||
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef | ||
} else if (numStopEvents > 1) { | ||
alert('Unexpected: got multiple loadstop/loaderror events.'); | ||
alert('Unexpected: got multiple loadstop/loaderror events.'); // eslint-disable-line no-undef | ||
} | ||
@@ -240,3 +249,3 @@ } | ||
function doHookOpen(url, target, params, numExpectedRedirects) { | ||
function doHookOpen (url, target, params, numExpectedRedirects) { | ||
var originalFunc = window.open; | ||
@@ -248,9 +257,7 @@ var wasClobbered = window.hasOwnProperty('open'); | ||
doOpen(url, target, params, numExpectedRedirects, true); | ||
} | ||
finally { | ||
} finally { | ||
if (wasClobbered) { | ||
window.open = originalFunc; | ||
} | ||
else { | ||
console.log('just delete, to restore open from prototype'); | ||
} else { | ||
console.log('just delete, to restore open from prototype'); | ||
delete window.open; | ||
@@ -261,10 +268,10 @@ } | ||
function openWithStyle(url, cssUrl, useCallback) { | ||
function openWithStyle (url, cssUrl, useCallback) { | ||
var iab = doOpen(url, '_blank', 'location=yes'); | ||
var callback = function (results) { | ||
if (results && results.length === 0) { | ||
alert('Results verified'); | ||
alert('Results verified'); // eslint-disable-line no-undef | ||
} else { | ||
console.log(results); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef | ||
} | ||
@@ -279,3 +286,3 @@ }; | ||
iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' }, | ||
useCallback && callback); | ||
useCallback && callback); | ||
}); | ||
@@ -285,3 +292,3 @@ } | ||
function openWithScript(url, jsUrl, useCallback) { | ||
function openWithScript (url, jsUrl, useCallback) { | ||
var iab = doOpen(url, '_blank', 'location=yes'); | ||
@@ -292,6 +299,6 @@ if (jsUrl) { | ||
if (results && results.length === 0) { | ||
alert('Results verified'); | ||
alert('Results verified'); // eslint-disable-line no-undef | ||
} else { | ||
console.log(results); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef | ||
} | ||
@@ -309,6 +316,6 @@ }); | ||
if (results && results.length === 1 && results[0] === 'abc') { | ||
alert('Results verified'); | ||
alert('Results verified'); // eslint-disable-line no-undef | ||
} else { | ||
console.log(results); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); | ||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef | ||
} | ||
@@ -320,8 +327,8 @@ }); | ||
var hiddenwnd = null; | ||
var loadlistener = function (event) { alert('background window loaded '); }; | ||
function openHidden(url, startHidden) { | ||
var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef | ||
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); | ||
alert('cordova.InAppBrowser.open returned ' + hiddenwnd); // eslint-disable-line no-undef | ||
return; | ||
@@ -331,9 +338,9 @@ } | ||
} | ||
function showHidden() { | ||
if (!!hiddenwnd) { | ||
function showHidden () { | ||
if (hiddenwnd) { | ||
hiddenwnd.show(); | ||
} | ||
} | ||
function closeHidden() { | ||
if (!!hiddenwnd) { | ||
function closeHidden () { | ||
if (hiddenwnd) { | ||
hiddenwnd.removeEventListener('loadstop', loadlistener); | ||
@@ -483,3 +490,3 @@ hiddenwnd.close(); | ||
'<p/> <div id="openHardwareBackNo"></div>' + | ||
'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history' + | ||
'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history' + | ||
'<p/> <div id="openHardwareBackDefaultAfterNo"></div>' + | ||
@@ -491,3 +498,3 @@ 'Expected result: consistently open browsers with with the appropriate option: hardwareback=defaults to yes then hardwareback=no then hardwareback=defaults to yes. By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser'; | ||
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) { | ||
MSApp.execUnsafeLocalFunction(function() { | ||
MSApp.execUnsafeLocalFunction(function () { | ||
contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests + | ||
@@ -501,14 +508,14 @@ css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests; | ||
document.getElementById("user-agent").textContent = navigator.userAgent; | ||
document.getElementById('user-agent').textContent = navigator.userAgent; | ||
// we are already in cdvtests directory | ||
var basePath = 'iab-resources/'; | ||
var localhtml = basePath + 'local.html', | ||
localpdf = basePath + 'local.pdf', | ||
injecthtml = basePath + 'inject.html', | ||
injectjs = isWindows ? basePath + 'inject.js' : 'inject.js', | ||
injectcss = isWindows ? basePath + 'inject.css' : 'inject.css', | ||
videohtml = basePath + 'video.html'; | ||
var localhtml = basePath + 'local.html'; | ||
var localpdf = basePath + 'local.pdf'; | ||
var injecthtml = basePath + 'inject.html'; | ||
var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js'; | ||
var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css'; | ||
var videohtml = basePath + 'video.html'; | ||
//Local | ||
// Local | ||
createActionButton('target=Default', function () { | ||
@@ -542,3 +549,3 @@ doOpen(localhtml); | ||
//White Listed | ||
// White Listed | ||
createActionButton('* target=Default', function () { | ||
@@ -566,3 +573,3 @@ doOpen('http://cordova.apache.org'); | ||
//Non White Listed | ||
// Non White Listed | ||
createActionButton('target=Default', function () { | ||
@@ -590,3 +597,3 @@ doOpen('http://www.apple.com'); | ||
//Page with redirect | ||
// Page with redirect | ||
createActionButton('http://google.co.uk', function () { | ||
@@ -599,3 +606,3 @@ doOpen('http://google.co.uk', 'random_string', '', 1); | ||
//PDF URL | ||
// PDF URL | ||
createActionButton('Remote URL', function () { | ||
@@ -608,3 +615,3 @@ doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf'); | ||
//Invalid URL | ||
// Invalid URL | ||
createActionButton('Invalid Scheme', function () { | ||
@@ -620,3 +627,3 @@ doOpen('x-ttp://www.invalid.com/', '_blank'); | ||
//CSS / JS injection | ||
// CSS / JS injection | ||
createActionButton('Original Document', function () { | ||
@@ -650,3 +657,3 @@ doOpen(injecthtml, '_blank'); | ||
//Open hidden | ||
// Open hidden | ||
createActionButton('Create Hidden', function () { | ||
@@ -671,3 +678,3 @@ openHidden('https://www.google.co.uk', true); | ||
//Clearing cache | ||
// Clearing cache | ||
createActionButton('Clear Browser Cache', function () { | ||
@@ -680,3 +687,3 @@ doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes'); | ||
//Video tag | ||
// Video tag | ||
createActionButton('Remote Video', function () { | ||
@@ -692,3 +699,3 @@ doOpen(videohtml, '_blank'); | ||
//Local With Anchor Tag | ||
// Local With Anchor Tag | ||
createActionButton('Anchor1', function () { | ||
@@ -711,13 +718,13 @@ doOpen(localhtml + '#bogusanchor', '_blank'); | ||
}, 'openHardwareBackNo'); | ||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function() { | ||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function () { | ||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes'); | ||
ref.addEventListener('loadstop', function() { | ||
ref.addEventListener('loadstop', function () { | ||
ref.close(); | ||
}); | ||
ref.addEventListener('exit', function() { | ||
ref.addEventListener('exit', function () { | ||
var ref2 = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes,hardwareback=no'); | ||
ref2.addEventListener('loadstop', function() { | ||
ref2.addEventListener('loadstop', function () { | ||
ref2.close(); | ||
}); | ||
ref2.addEventListener('exit', function() { | ||
ref2.addEventListener('exit', function () { | ||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes'); | ||
@@ -724,0 +731,0 @@ }); |
@@ -171,2 +171,4 @@ // Type definitions for Apache Cordova InAppBrowser plugin | ||
close(): void; | ||
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */ | ||
hide(): void; | ||
/** | ||
@@ -173,0 +175,0 @@ * Displays an InAppBrowser window that was opened hidden. Calling this has no effect |
@@ -22,3 +22,3 @@ /* | ||
(function() { | ||
(function () { | ||
// special patch to correctly work on Ripple emulator (CB-9760) | ||
@@ -35,9 +35,9 @@ if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 | ||
function InAppBrowser() { | ||
this.channels = { | ||
function InAppBrowser () { | ||
this.channels = { | ||
'loadstart': channel.create('loadstart'), | ||
'loadstop' : channel.create('loadstop'), | ||
'loaderror' : channel.create('loaderror'), | ||
'exit' : channel.create('exit') | ||
}; | ||
'loadstop': channel.create('loadstop'), | ||
'loaderror': channel.create('loaderror'), | ||
'exit': channel.create('exit') | ||
}; | ||
} | ||
@@ -52,11 +52,11 @@ | ||
close: function (eventname) { | ||
exec(null, null, "InAppBrowser", "close", []); | ||
exec(null, null, 'InAppBrowser', 'close', []); | ||
}, | ||
show: function (eventname) { | ||
exec(null, null, "InAppBrowser", "show", []); | ||
exec(null, null, 'InAppBrowser', 'show', []); | ||
}, | ||
hide: function (eventname) { | ||
exec(null, null, "InAppBrowser", "hide", []); | ||
exec(null, null, 'InAppBrowser', 'hide', []); | ||
}, | ||
addEventListener: function (eventname,f) { | ||
addEventListener: function (eventname, f) { | ||
if (eventname in this.channels) { | ||
@@ -66,3 +66,3 @@ this.channels[eventname].subscribe(f); | ||
}, | ||
removeEventListener: function(eventname, f) { | ||
removeEventListener: function (eventname, f) { | ||
if (eventname in this.channels) { | ||
@@ -73,7 +73,7 @@ this.channels[eventname].unsubscribe(f); | ||
executeScript: function(injectDetails, cb) { | ||
executeScript: function (injectDetails, cb) { | ||
if (injectDetails.code) { | ||
exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); | ||
exec(cb, null, 'InAppBrowser', 'injectScriptCode', [injectDetails.code, !!cb]); | ||
} else if (injectDetails.file) { | ||
exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); | ||
exec(cb, null, 'InAppBrowser', 'injectScriptFile', [injectDetails.file, !!cb]); | ||
} else { | ||
@@ -84,7 +84,7 @@ throw new Error('executeScript requires exactly one of code or file to be specified'); | ||
insertCSS: function(injectDetails, cb) { | ||
insertCSS: function (injectDetails, cb) { | ||
if (injectDetails.code) { | ||
exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); | ||
exec(cb, null, 'InAppBrowser', 'injectStyleCode', [injectDetails.code, !!cb]); | ||
} else if (injectDetails.file) { | ||
exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); | ||
exec(cb, null, 'InAppBrowser', 'injectStyleFile', [injectDetails.file, !!cb]); | ||
} else { | ||
@@ -96,3 +96,3 @@ throw new Error('insertCSS requires exactly one of code or file to be specified'); | ||
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). | ||
@@ -112,11 +112,11 @@ if (window.frames && window.frames[strWindowName]) { | ||
var cb = function(eventname) { | ||
iab._eventHandler(eventname); | ||
var cb = function (eventname) { | ||
iab._eventHandler(eventname); | ||
}; | ||
strWindowFeatures = strWindowFeatures || ""; | ||
strWindowFeatures = strWindowFeatures || ''; | ||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); | ||
exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]); | ||
return iab; | ||
}; | ||
})(); |
@@ -22,4 +22,4 @@ /* | ||
/*jslint sloppy:true */ | ||
/*global Windows:true, require, document, setTimeout, window, module */ | ||
/* jslint sloppy:true */ | ||
/* global Windows:true, require, document, setTimeout, window, module */ | ||
@@ -40,3 +40,3 @@ var browserWrap; | ||
}*/ | ||
} */ | ||
}, | ||
@@ -47,23 +47,23 @@ hide: function (win, lose) { | ||
}*/ | ||
} */ | ||
}, | ||
open: function (win, lose, args) { | ||
var strUrl = args[0], | ||
target = args[1], | ||
url, | ||
elem; | ||
var strUrl = args[0]; | ||
var target = args[1]; | ||
var url; | ||
var elem; | ||
if (target === "_system") { | ||
if (target === '_system') { | ||
url = new Windows.Foundation.Uri(strUrl); | ||
Windows.System.Launcher.launchUriAsync(url); | ||
} else if (target === "_blank") { | ||
} else if (target === '_blank') { | ||
if (!browserWrap) { | ||
browserWrap = document.createElement("div"); | ||
browserWrap.style.position = "absolute"; | ||
browserWrap.style.width = (window.innerWidth - 80) + "px"; | ||
browserWrap.style.height = (window.innerHeight - 80) + "px"; | ||
browserWrap.style.borderWidth = "40px"; | ||
browserWrap.style.borderStyle = "solid"; | ||
browserWrap.style.borderColor = "rgba(0,0,0,0.25)"; | ||
browserWrap.style.zIndex = "9999999"; | ||
browserWrap = document.createElement('div'); | ||
browserWrap.style.position = 'absolute'; | ||
browserWrap.style.width = (window.innerWidth - 80) + 'px'; | ||
browserWrap.style.height = (window.innerHeight - 80) + 'px'; | ||
browserWrap.style.borderWidth = '40px'; | ||
browserWrap.style.borderStyle = 'solid'; | ||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)'; | ||
browserWrap.style.zIndex = '9999999'; | ||
@@ -80,29 +80,27 @@ browserWrap.onclick = function () { | ||
if (localFile) { | ||
elem = document.createElement("x-ms-webview"); | ||
elem.style.width = (window.innerWidth - 80) + "px"; | ||
elem.style.height = (window.innerHeight - 80) + "px"; | ||
elem.style.borderWidth = "0px"; | ||
elem.name = "targetFrame"; | ||
elem = document.createElement('x-ms-webview'); | ||
elem.style.width = (window.innerWidth - 80) + 'px'; | ||
elem.style.height = (window.innerHeight - 80) + 'px'; | ||
elem.style.borderWidth = '0px'; | ||
elem.name = 'targetFrame'; | ||
elem.src = strUrl; | ||
window.addEventListener("resize", function () { | ||
window.addEventListener('resize', function () { | ||
if (browserWrap && elem) { | ||
elem.style.width = (window.innerWidth - 80) + "px"; | ||
elem.style.height = (window.innerHeight - 80) + "px"; | ||
elem.style.width = (window.innerWidth - 80) + 'px'; | ||
elem.style.height = (window.innerHeight - 80) + 'px'; | ||
} | ||
}); | ||
} else { | ||
elem = document.createElement("iframe"); | ||
elem.style.width = (window.innerWidth - 80) + "px"; | ||
elem.style.height = (window.innerHeight - 80) + "px"; | ||
elem.style.borderWidth = "0px"; | ||
elem.name = "targetFrame"; | ||
elem = document.createElement('iframe'); | ||
elem.style.width = (window.innerWidth - 80) + 'px'; | ||
elem.style.height = (window.innerHeight - 80) + 'px'; | ||
elem.style.borderWidth = '0px'; | ||
elem.name = 'targetFrame'; | ||
elem.src = strUrl; | ||
window.addEventListener("resize", function () { | ||
window.addEventListener('resize', function () { | ||
if (browserWrap && elem) { | ||
elem.style.width = (window.innerWidth - 80) + "px"; | ||
elem.style.height = (window.innerHeight - 80) + "px"; | ||
elem.style.width = (window.innerWidth - 80) + 'px'; | ||
elem.style.height = (window.innerHeight - 80) + 'px'; | ||
} | ||
@@ -117,4 +115,3 @@ }); | ||
//var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl }); | ||
// var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl }); | ||
}, | ||
@@ -134,3 +131,2 @@ | ||
require("cordova/exec/proxy").add("InAppBrowser", module.exports); | ||
require('cordova/exec/proxy').add('InAppBrowser', module.exports); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
700589
82
1935
0
713
0
7